@seafile/seafile-editor 0.3.76

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 (156) hide show
  1. package/README.md +119 -0
  2. package/TODO.md +55 -0
  3. package/dist/components/add-formula-dialog.js +135 -0
  4. package/dist/components/add-image-dialog.js +78 -0
  5. package/dist/components/add-link-dialog.js +148 -0
  6. package/dist/components/comment-dialog.js +107 -0
  7. package/dist/components/comment-panel.js +452 -0
  8. package/dist/components/context-menu.js +112 -0
  9. package/dist/components/detail-list-view.js +119 -0
  10. package/dist/components/generate-share-link.js +412 -0
  11. package/dist/components/internal-link-dialog.js +96 -0
  12. package/dist/components/loading.js +32 -0
  13. package/dist/components/markdown-lint.js +87 -0
  14. package/dist/components/modal-portal.js +46 -0
  15. package/dist/components/outline.js +130 -0
  16. package/dist/components/participants-list.js +126 -0
  17. package/dist/components/related-files-list.js +75 -0
  18. package/dist/components/shortcut-dialog.js +167 -0
  19. package/dist/components/side-panel.js +175 -0
  20. package/dist/components/toast/alert.js +150 -0
  21. package/dist/components/toast/index.js +3 -0
  22. package/dist/components/toast/toast.js +179 -0
  23. package/dist/components/toast/toastManager.js +158 -0
  24. package/dist/components/toast/toaster.js +76 -0
  25. package/dist/components/toolbar.js +235 -0
  26. package/dist/components/topbar-component/button-group.js +31 -0
  27. package/dist/components/topbar-component/editor-toolbar.js +545 -0
  28. package/dist/components/topbar-component/file-info.js +65 -0
  29. package/dist/components/topbar-component/header-list.js +128 -0
  30. package/dist/components/topbar-component/icon-button.js +99 -0
  31. package/dist/components/topbar-component/insert-file.js +67 -0
  32. package/dist/components/topbar-component/table-toolbar.js +175 -0
  33. package/dist/components/topbar-component/upload-img.js +122 -0
  34. package/dist/components/user-help.js +205 -0
  35. package/dist/css/diff-viewer.css +105 -0
  36. package/dist/css/history-viewer.css +104 -0
  37. package/dist/css/keyboard-shortcuts.css +59 -0
  38. package/dist/css/layout.css +110 -0
  39. package/dist/css/markdown-viewer-slate/file-tags-list.css +76 -0
  40. package/dist/css/markdown-viewer.css +69 -0
  41. package/dist/css/plaineditor/markdown-editor.css +12 -0
  42. package/dist/css/react-mentions-default-style.js +72 -0
  43. package/dist/css/related-files-list.css +56 -0
  44. package/dist/css/richeditor/comments-list.css +184 -0
  45. package/dist/css/richeditor/detail-list-view.css +114 -0
  46. package/dist/css/richeditor/document-info.css +57 -0
  47. package/dist/css/richeditor/formula.css +19 -0
  48. package/dist/css/richeditor/image.css +141 -0
  49. package/dist/css/richeditor/link.css +7 -0
  50. package/dist/css/richeditor/navbar-imgbutton.css +79 -0
  51. package/dist/css/richeditor/participants-list.css +22 -0
  52. package/dist/css/richeditor/rich-editor-main.css +42 -0
  53. package/dist/css/richeditor/right-panel.css +84 -0
  54. package/dist/css/richeditor/side-panel.css +190 -0
  55. package/dist/css/richeditor/table.css +57 -0
  56. package/dist/css/richeditor/textlink-hovermenu.css +47 -0
  57. package/dist/css/richeditor/tree-view.css +67 -0
  58. package/dist/css/topbar.css +400 -0
  59. package/dist/editor/code-highlight-package.js +27 -0
  60. package/dist/editor/controller/block-element-controller.js +376 -0
  61. package/dist/editor/controller/inline-element-controller.js +129 -0
  62. package/dist/editor/controller/normalize-controller.js +107 -0
  63. package/dist/editor/controller/shortcut-controller.js +394 -0
  64. package/dist/editor/controller/void-element-controller.js +12 -0
  65. package/dist/editor/custom/custom.js +17 -0
  66. package/dist/editor/custom/get-event-transfer.js +34 -0
  67. package/dist/editor/custom/getNodesByTypeAtRange.js +69 -0
  68. package/dist/editor/custom/insertNodes.js +140 -0
  69. package/dist/editor/custom/is-empty-paragraph.js +13 -0
  70. package/dist/editor/custom/set-event-transfer.js +31 -0
  71. package/dist/editor/custom/split-nodes-at-point.js +162 -0
  72. package/dist/editor/custom/unwrap-node-by-type-at-range.js +81 -0
  73. package/dist/editor/editor-component/check-list-item.js +64 -0
  74. package/dist/editor/editor-component/code-block.js +150 -0
  75. package/dist/editor/editor-component/formula.js +79 -0
  76. package/dist/editor/editor-component/image.js +215 -0
  77. package/dist/editor/editor-component/link.js +11 -0
  78. package/dist/editor/editor-component/table.js +172 -0
  79. package/dist/editor/editor-component/textlink-hovermenu.js +136 -0
  80. package/dist/editor/editor-plugin.js +249 -0
  81. package/dist/editor/editor-utils/block-element-utils/blockquote-utils.js +96 -0
  82. package/dist/editor/editor-utils/block-element-utils/code-utils.js +162 -0
  83. package/dist/editor/editor-utils/block-element-utils/formula-utils.js +58 -0
  84. package/dist/editor/editor-utils/block-element-utils/index.js +38 -0
  85. package/dist/editor/editor-utils/block-element-utils/list-utils.js +398 -0
  86. package/dist/editor/editor-utils/block-element-utils/table-utils.js +418 -0
  87. package/dist/editor/editor-utils/common-editor-utils.js +587 -0
  88. package/dist/editor/editor-utils/inline-element-utils/index.js +95 -0
  89. package/dist/editor/editor-utils/mark-utils.js +25 -0
  90. package/dist/editor/editor-utils/range-utils.js +9 -0
  91. package/dist/editor/editor-utils/selection-utils.js +33 -0
  92. package/dist/editor/editor-utils/text-utils.js +130 -0
  93. package/dist/editor/editor.js +66 -0
  94. package/dist/editor/element-model/blockquote.js +16 -0
  95. package/dist/editor/element-model/image.js +19 -0
  96. package/dist/editor/element-model/link.js +19 -0
  97. package/dist/editor/element-model/table.js +50 -0
  98. package/dist/editor/element-model/text.js +13 -0
  99. package/dist/editor/load-script.js +83 -0
  100. package/dist/editor/plain-markdown-editor.js +324 -0
  101. package/dist/editor/rich-markdown-editor.js +580 -0
  102. package/dist/editor/seafile-editor.js +326 -0
  103. package/dist/editor/simple-editor.js +245 -0
  104. package/dist/editor-api.js +261 -0
  105. package/dist/index.css +97 -0
  106. package/dist/lib/slate-hyperscript/creators.js +263 -0
  107. package/dist/lib/slate-hyperscript/hyperscript.js +92 -0
  108. package/dist/lib/slate-hyperscript/index.js +3 -0
  109. package/dist/lib/slate-hyperscript/tokens.js +102 -0
  110. package/dist/lib/unified/index.js +470 -0
  111. package/dist/lib/vfile/core.js +172 -0
  112. package/dist/lib/vfile/index.js +48 -0
  113. package/dist/seafile-editor-chooser.js +45 -0
  114. package/dist/seafile-markdown-editor.js +301 -0
  115. package/dist/seafile-markdown-viewer.js +79 -0
  116. package/dist/seafile-simple-editor.js +56 -0
  117. package/dist/utils/copy-to-clipboard.js +47 -0
  118. package/dist/utils/deserialize-html.js +282 -0
  119. package/dist/utils/diff/compare-strings.js +46 -0
  120. package/dist/utils/diff/diff.js +855 -0
  121. package/dist/utils/diff/index.js +2 -0
  122. package/dist/utils/render-slate.js +219 -0
  123. package/dist/utils/seafile-markdown2html.js +62 -0
  124. package/dist/utils/slate2markdown/deserialize.js +689 -0
  125. package/dist/utils/slate2markdown/index.js +3 -0
  126. package/dist/utils/slate2markdown/serialize.js +407 -0
  127. package/dist/utils/utils.js +28 -0
  128. package/dist/viewer/diff-viewer.js +98 -0
  129. package/dist/viewer/markdown-viewer.js +139 -0
  130. package/dist/viewer/slate-viewer.js +73 -0
  131. package/dist/viewer/viewer-formula.js +67 -0
  132. package/dist/viewer/viewer-image.js +93 -0
  133. package/dist/viewer/viewer-outline.js +118 -0
  134. package/package.json +215 -0
  135. package/public/favicon.ico +0 -0
  136. package/public/index.html +45 -0
  137. package/public/locales/cs/seafile-editor.json +169 -0
  138. package/public/locales/de/seafile-editor.json +169 -0
  139. package/public/locales/en/seafile-editor.json +222 -0
  140. package/public/locales/es/seafile-editor.json +169 -0
  141. package/public/locales/es-AR/seafile-editor.json +169 -0
  142. package/public/locales/es-MX/seafile-editor.json +169 -0
  143. package/public/locales/fr/seafile-editor.json +169 -0
  144. package/public/locales/it/seafile-editor.json +169 -0
  145. package/public/locales/ru/seafile-editor.json +169 -0
  146. package/public/locales/zh-CN/seafile-editor.json +219 -0
  147. package/public/manifest.json +15 -0
  148. package/public/media/scripts/mathjax/tex-svg.js +1 -0
  149. package/public/media/seafile-editor-font/iconfont.eot +0 -0
  150. package/public/media/seafile-editor-font/iconfont.svg +164 -0
  151. package/public/media/seafile-editor-font/iconfont.ttf +0 -0
  152. package/public/media/seafile-editor-font/iconfont.woff +0 -0
  153. package/public/media/seafile-editor-font/iconfont.woff2 +0 -0
  154. package/public/media/seafile-editor-font.css +201 -0
  155. package/public/media/seafile-logo.png +0 -0
  156. package/public/media/seafile-ui.css +11169 -0
@@ -0,0 +1,102 @@
1
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
2
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
3
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
+
5
+ /**
6
+ * A weak map to hold anchor tokens.
7
+ */
8
+ var ANCHOR = new WeakMap();
9
+ /**
10
+ * A weak map to hold focus tokens.
11
+ */
12
+
13
+ var FOCUS = new WeakMap();
14
+ /**
15
+ * All tokens inherit from a single constructor for `instanceof` checking.
16
+ */
17
+
18
+ export var Token = function Token() {
19
+ _classCallCheck(this, Token);
20
+ };
21
+ /**
22
+ * Anchor tokens represent the selection's anchor point.
23
+ */
24
+
25
+ export var AnchorToken = /*#__PURE__*/function (_Token) {
26
+ _inherits(AnchorToken, _Token);
27
+
28
+ var _super = _createSuper(AnchorToken);
29
+
30
+ function AnchorToken() {
31
+ var _this;
32
+
33
+ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
34
+
35
+ _classCallCheck(this, AnchorToken);
36
+
37
+ _this = _super.call(this);
38
+ var offset = props.offset,
39
+ path = props.path;
40
+ _this.offset = offset;
41
+ _this.path = path;
42
+ return _this;
43
+ }
44
+
45
+ return AnchorToken;
46
+ }(Token);
47
+ /**
48
+ * Focus tokens represent the selection's focus point.
49
+ */
50
+
51
+ export var FocusToken = /*#__PURE__*/function (_Token2) {
52
+ _inherits(FocusToken, _Token2);
53
+
54
+ var _super2 = _createSuper(FocusToken);
55
+
56
+ function FocusToken() {
57
+ var _this2;
58
+
59
+ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
60
+
61
+ _classCallCheck(this, FocusToken);
62
+
63
+ _this2 = _super2.call(this);
64
+ var offset = props.offset,
65
+ path = props.path;
66
+ _this2.offset = offset;
67
+ _this2.path = path;
68
+ return _this2;
69
+ }
70
+
71
+ return FocusToken;
72
+ }(Token);
73
+ /**
74
+ * Add an anchor token to the end of a text node.
75
+ */
76
+
77
+ export var addAnchorToken = function addAnchorToken(text, token) {
78
+ var offset = text.text.length;
79
+ ANCHOR.set(text, [offset, token]);
80
+ };
81
+ /**
82
+ * Get the offset if a text node has an associated anchor token.
83
+ */
84
+
85
+ export var getAnchorOffset = function getAnchorOffset(text) {
86
+ return ANCHOR.get(text);
87
+ };
88
+ /**
89
+ * Add a focus token to the end of a text node.
90
+ */
91
+
92
+ export var addFocusToken = function addFocusToken(text, token) {
93
+ var offset = text.text.length;
94
+ FOCUS.set(text, [offset, token]);
95
+ };
96
+ /**
97
+ * Get the offset if a text node has an associated focus token.
98
+ */
99
+
100
+ export var getFocusOffset = function getFocusOffset(text) {
101
+ return FOCUS.get(text);
102
+ };
@@ -0,0 +1,470 @@
1
+ 'use strict';
2
+ /* Dependencies. */
3
+
4
+ var extend = require('extend');
5
+
6
+ var bail = require('bail');
7
+
8
+ var vfile = require('../vfile');
9
+
10
+ var trough = require('trough');
11
+
12
+ var string = require('x-is-string');
13
+
14
+ var plain = require('is-plain-obj');
15
+ /* Expose a frozen processor. */
16
+
17
+
18
+ module.exports = unified().freeze();
19
+ var slice = [].slice;
20
+ var own = {}.hasOwnProperty;
21
+ /* Process pipeline. */
22
+
23
+ var pipeline = trough().use(pipelineParse).use(pipelineRun).use(pipelineStringify);
24
+
25
+ function pipelineParse(p, ctx) {
26
+ ctx.tree = p.parse(ctx.file);
27
+ }
28
+
29
+ function pipelineRun(p, ctx, next) {
30
+ p.run(ctx.tree, ctx.file, done);
31
+
32
+ function done(err, tree, file) {
33
+ if (err) {
34
+ next(err);
35
+ } else {
36
+ ctx.tree = tree;
37
+ ctx.file = file;
38
+ next();
39
+ }
40
+ }
41
+ }
42
+
43
+ function pipelineStringify(p, ctx) {
44
+ ctx.file.contents = p.stringify(ctx.tree, ctx.file);
45
+ }
46
+ /* Function to create the first processor. */
47
+
48
+
49
+ function unified() {
50
+ var attachers = [];
51
+ var transformers = trough();
52
+ var namespace = {};
53
+ var frozen = false;
54
+ var freezeIndex = -1;
55
+ /* Data management. */
56
+
57
+ processor.data = data;
58
+ /* Lock. */
59
+
60
+ processor.freeze = freeze;
61
+ /* Plug-ins. */
62
+
63
+ processor.attachers = attachers;
64
+ processor.use = use;
65
+ /* API. */
66
+
67
+ processor.parse = parse;
68
+ processor.stringify = stringify;
69
+ processor.run = run;
70
+ processor.runSync = runSync;
71
+ processor.process = process;
72
+ processor.processSync = processSync;
73
+ /* Expose. */
74
+
75
+ return processor;
76
+ /* Create a new processor based on the processor
77
+ * in the current scope. */
78
+
79
+ function processor() {
80
+ var destination = unified();
81
+ var length = attachers.length;
82
+ var index = -1;
83
+
84
+ while (++index < length) {
85
+ destination.use.apply(null, attachers[index]);
86
+ }
87
+
88
+ destination.data(extend(true, {}, namespace));
89
+ return destination;
90
+ }
91
+ /* Freeze: used to signal a processor that has finished
92
+ * configuration.
93
+ *
94
+ * For example, take unified itself. It’s frozen.
95
+ * Plug-ins should not be added to it. Rather, it should
96
+ * be extended, by invoking it, before modifying it.
97
+ *
98
+ * In essence, always invoke this when exporting a
99
+ * processor. */
100
+
101
+
102
+ function freeze() {
103
+ var values;
104
+ var plugin;
105
+ var options;
106
+ var transformer;
107
+
108
+ if (frozen) {
109
+ return processor;
110
+ }
111
+
112
+ while (++freezeIndex < attachers.length) {
113
+ values = attachers[freezeIndex];
114
+ plugin = values[0];
115
+ options = values[1];
116
+ transformer = null;
117
+
118
+ if (options === false) {
119
+ continue;
120
+ }
121
+
122
+ if (options === true) {
123
+ values[1] = undefined;
124
+ }
125
+
126
+ transformer = plugin.apply(processor, values.slice(1));
127
+
128
+ if (typeof transformer === 'function') {
129
+ transformers.use(transformer);
130
+ }
131
+ }
132
+
133
+ frozen = true;
134
+ freezeIndex = Infinity;
135
+ return processor;
136
+ }
137
+ /* Data management.
138
+ * Getter / setter for processor-specific informtion. */
139
+
140
+
141
+ function data(key, value) {
142
+ if (string(key)) {
143
+ /* Set `key`. */
144
+ if (arguments.length === 2) {
145
+ assertUnfrozen('data', frozen);
146
+ namespace[key] = value;
147
+ return processor;
148
+ }
149
+ /* Get `key`. */
150
+
151
+
152
+ return own.call(namespace, key) && namespace[key] || null;
153
+ }
154
+ /* Set space. */
155
+
156
+
157
+ if (key) {
158
+ assertUnfrozen('data', frozen);
159
+ namespace = key;
160
+ return processor;
161
+ }
162
+ /* Get space. */
163
+
164
+
165
+ return namespace;
166
+ }
167
+ /* Plug-in management.
168
+ *
169
+ * Pass it:
170
+ * * an attacher and options,
171
+ * * a preset,
172
+ * * a list of presets, attachers, and arguments (list
173
+ * of attachers and options). */
174
+
175
+
176
+ function use(value) {
177
+ var settings;
178
+ assertUnfrozen('use', frozen);
179
+
180
+ if (value === null || value === undefined) {
181
+ /* Empty */
182
+ } else if (typeof value === 'function') {
183
+ addPlugin.apply(null, arguments);
184
+ } else if (typeof value === 'object') {
185
+ if ('length' in value) {
186
+ addList(value);
187
+ } else {
188
+ addPreset(value);
189
+ }
190
+ } else {
191
+ throw new Error('Expected usable value, not `' + value + '`');
192
+ }
193
+
194
+ if (settings) {
195
+ namespace.settings = extend(namespace.settings || {}, settings);
196
+ }
197
+
198
+ return processor;
199
+
200
+ function addPreset(result) {
201
+ addList(result.plugins);
202
+
203
+ if (result.settings) {
204
+ settings = extend(settings || {}, result.settings);
205
+ }
206
+ }
207
+
208
+ function add(value) {
209
+ if (typeof value === 'function') {
210
+ addPlugin(value);
211
+ } else if (typeof value === 'object') {
212
+ if ('length' in value) {
213
+ addPlugin.apply(null, value);
214
+ } else {
215
+ addPreset(value);
216
+ }
217
+ } else {
218
+ throw new Error('Expected usable value, not `' + value + '`');
219
+ }
220
+ }
221
+
222
+ function addList(plugins) {
223
+ var length;
224
+ var index;
225
+
226
+ if (plugins === null || plugins === undefined) {
227
+ /* Empty */
228
+ } else if (typeof plugins === 'object' && 'length' in plugins) {
229
+ length = plugins.length;
230
+ index = -1;
231
+
232
+ while (++index < length) {
233
+ add(plugins[index]);
234
+ }
235
+ } else {
236
+ throw new Error('Expected a list of plugins, not `' + plugins + '`');
237
+ }
238
+ }
239
+
240
+ function addPlugin(plugin, value) {
241
+ var entry = find(plugin);
242
+
243
+ if (entry) {
244
+ if (plain(entry[1]) && plain(value)) {
245
+ value = extend(entry[1], value);
246
+ }
247
+
248
+ entry[1] = value;
249
+ } else {
250
+ attachers.push(slice.call(arguments));
251
+ }
252
+ }
253
+ }
254
+
255
+ function find(plugin) {
256
+ var length = attachers.length;
257
+ var index = -1;
258
+ var entry;
259
+
260
+ while (++index < length) {
261
+ entry = attachers[index];
262
+
263
+ if (entry[0] === plugin) {
264
+ return entry;
265
+ }
266
+ }
267
+ }
268
+ /* Parse a file (in string or VFile representation)
269
+ * into a Unist node using the `Parser` on the
270
+ * processor. */
271
+
272
+
273
+ function parse(doc) {
274
+ var file = vfile(doc);
275
+ var Parser;
276
+ freeze();
277
+ Parser = processor.Parser;
278
+ assertParser('parse', Parser);
279
+
280
+ if (newable(Parser)) {
281
+ return new Parser(String(file), file).parse();
282
+ }
283
+
284
+ return Parser(String(file), file); // eslint-disable-line new-cap
285
+ }
286
+ /* Run transforms on a Unist node representation of a file
287
+ * (in string or VFile representation), async. */
288
+
289
+
290
+ function run(node, file, cb) {
291
+ assertNode(node);
292
+ freeze();
293
+
294
+ if (!cb && typeof file === 'function') {
295
+ cb = file;
296
+ file = null;
297
+ }
298
+
299
+ if (!cb) {
300
+ return new Promise(executor);
301
+ }
302
+
303
+ executor(null, cb);
304
+
305
+ function executor(resolve, reject) {
306
+ transformers.run(node, vfile(file), done);
307
+
308
+ function done(err, tree, file) {
309
+ tree = tree || node;
310
+
311
+ if (err) {
312
+ reject(err);
313
+ } else if (resolve) {
314
+ resolve(tree);
315
+ } else {
316
+ cb(null, tree, file);
317
+ }
318
+ }
319
+ }
320
+ }
321
+ /* Run transforms on a Unist node representation of a file
322
+ * (in string or VFile representation), sync. */
323
+
324
+
325
+ function runSync(node, file) {
326
+ var complete = false;
327
+ var result;
328
+ run(node, file, done);
329
+ assertDone('runSync', 'run', complete);
330
+ return result;
331
+
332
+ function done(err, tree) {
333
+ complete = true;
334
+ bail(err);
335
+ result = tree;
336
+ }
337
+ }
338
+ /* Stringify a Unist node representation of a file
339
+ * (in string or VFile representation) into a string
340
+ * using the `Compiler` on the processor. */
341
+
342
+
343
+ function stringify(node, doc) {
344
+ var file = vfile(doc);
345
+ var Compiler;
346
+ freeze();
347
+ Compiler = processor.Compiler;
348
+ assertCompiler('stringify', Compiler);
349
+ assertNode(node);
350
+
351
+ if (newable(Compiler)) {
352
+ return new Compiler(node, file).compile();
353
+ }
354
+
355
+ return Compiler(node, file); // eslint-disable-line new-cap
356
+ }
357
+ /* Parse a file (in string or VFile representation)
358
+ * into a Unist node using the `Parser` on the processor,
359
+ * then run transforms on that node, and compile the
360
+ * resulting node using the `Compiler` on the processor,
361
+ * and store that result on the VFile. */
362
+
363
+
364
+ function process(doc, cb) {
365
+ freeze();
366
+ assertParser('process', processor.Parser);
367
+ assertCompiler('process', processor.Compiler);
368
+
369
+ if (!cb) {
370
+ return new Promise(executor);
371
+ }
372
+
373
+ executor(null, cb);
374
+
375
+ function executor(resolve, reject) {
376
+ var file = vfile(doc);
377
+ pipeline.run(processor, {
378
+ file: file
379
+ }, done);
380
+
381
+ function done(err) {
382
+ if (err) {
383
+ reject(err);
384
+ } else if (resolve) {
385
+ resolve(file);
386
+ } else {
387
+ cb(null, file);
388
+ }
389
+ }
390
+ }
391
+ }
392
+ /* Process the given document (in string or VFile
393
+ * representation), sync. */
394
+
395
+
396
+ function processSync(doc) {
397
+ var complete = false;
398
+ var file;
399
+ freeze();
400
+ assertParser('processSync', processor.Parser);
401
+ assertCompiler('processSync', processor.Compiler);
402
+ file = vfile(doc);
403
+ process(file, done);
404
+ assertDone('processSync', 'process', complete);
405
+ return file;
406
+
407
+ function done(err) {
408
+ complete = true;
409
+ bail(err);
410
+ }
411
+ }
412
+ }
413
+ /* Check if `func` is a constructor. */
414
+
415
+
416
+ function newable(value) {
417
+ return typeof value === 'function' && keys(value.prototype);
418
+ }
419
+ /* Check if `value` is an object with keys. */
420
+
421
+
422
+ function keys(value) {
423
+ var key;
424
+
425
+ for (key in value) {
426
+ return true;
427
+ }
428
+
429
+ return false;
430
+ }
431
+ /* Assert a parser is available. */
432
+
433
+
434
+ function assertParser(name, Parser) {
435
+ if (typeof Parser !== 'function') {
436
+ throw new Error('Cannot `' + name + '` without `Parser`');
437
+ }
438
+ }
439
+ /* Assert a compiler is available. */
440
+
441
+
442
+ function assertCompiler(name, Compiler) {
443
+ if (typeof Compiler !== 'function') {
444
+ throw new Error('Cannot `' + name + '` without `Compiler`');
445
+ }
446
+ }
447
+ /* Assert the processor is not frozen. */
448
+
449
+
450
+ function assertUnfrozen(name, frozen) {
451
+ if (frozen) {
452
+ throw new Error(['Cannot invoke `' + name + '` on a frozen processor.\nCreate a new ', 'processor first, by invoking it: use `processor()` instead of ', '`processor`.'].join(''));
453
+ }
454
+ }
455
+ /* Assert `node` is a Unist node. */
456
+
457
+
458
+ function assertNode(node) {
459
+ if (!node || !string(node.type)) {
460
+ throw new Error('Expected node, got `' + node + '`');
461
+ }
462
+ }
463
+ /* Assert that `complete` is `true`. */
464
+
465
+
466
+ function assertDone(name, asyncName, complete) {
467
+ if (!complete) {
468
+ throw new Error('`' + name + '` finished async. Use `' + asyncName + '` instead');
469
+ }
470
+ }