copious-mail 0.0.0-stage → 0.9.1

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 (182) hide show
  1. package/LICENSE +504 -0
  2. package/README.md +143 -2
  3. package/bin/index.js +345 -0
  4. package/client/copiousLogo.svg +123 -0
  5. package/client/hosted.html +5259 -0
  6. package/client/mail_styles.css +40 -0
  7. package/client/mikado.bundle.debug.js +1406 -0
  8. package/client/mikado.bundle.min.js +68 -0
  9. package/client/mikado.bundle.module.debug.js +1401 -0
  10. package/client/mikado.bundle.module.min.js +67 -0
  11. package/client/mikado.bundle.profiler.debug.js +1490 -0
  12. package/client/mikado.es5.debug.js +1995 -0
  13. package/client/mikado.es5.min.js +85 -0
  14. package/client/mikado.light.debug.js +535 -0
  15. package/client/mikado.light.min.js +29 -0
  16. package/client/mikado.light.module.debug.js +530 -0
  17. package/data/user_list.db +14 -0
  18. package/index.html +7242 -0
  19. package/index.js +5 -0
  20. package/jsconfig.json +32 -0
  21. package/lib/mail_repo_bridge_ops.js +1177 -0
  22. package/lib/utils.js +70 -0
  23. package/lib/websocket_con.js +249 -0
  24. package/mail_bridge.conf +10 -0
  25. package/package.json +41 -5
  26. package/svelte-src/App.svelte +2513 -0
  27. package/svelte-src/ContactGrid.svelte +98 -0
  28. package/svelte-src/FloatWindow.svelte +181 -0
  29. package/svelte-src/MessageDisplay.svelte +230 -0
  30. package/svelte-src/MessageEditor.svelte +664 -0
  31. package/svelte-src/MessageListEditor.svelte +133 -0
  32. package/svelte-src/Thing.svelte +190 -0
  33. package/svelte-src/ThingFull.svelte +117 -0
  34. package/svelte-src/ipfs_profile_proxy.js +923 -0
  35. package/svelte-src/main.js +10 -0
  36. package/svelte-src/search_box.js +69 -0
  37. package/svelte-src/utilities.js +180 -0
  38. package/test/c +28 -0
  39. package/test/copiousLogo.svg +123 -0
  40. package/test/index.html +4408 -0
  41. package/test/index.js +244 -0
  42. package/test/mail_styles.css +40 -0
  43. package/test/mikado.bundle.debug.js +1406 -0
  44. package/test/mikado.bundle.min.js +68 -0
  45. package/test/mikado.bundle.module.debug.js +1401 -0
  46. package/test/mikado.bundle.module.min.js +67 -0
  47. package/test/mikado.bundle.profiler.debug.js +1490 -0
  48. package/test/mikado.es5.debug.js +1995 -0
  49. package/test/mikado.es5.min.js +85 -0
  50. package/test/mikado.light.debug.js +535 -0
  51. package/test/mikado.light.min.js +29 -0
  52. package/test/mikado.light.module.debug.js +530 -0
  53. package/test/tpl/partial/attachment_edit.es5.js +1 -0
  54. package/test/tpl/partial/attachment_edit.html +5 -0
  55. package/test/tpl/partial/attachment_edit.js +1 -0
  56. package/test/tpl/partial/attachment_view.es5.js +1 -0
  57. package/test/tpl/partial/attachment_view.html +1 -0
  58. package/test/tpl/partial/attachment_view.js +1 -0
  59. package/test/tpl/partial/contact_list.es5.js +1 -0
  60. package/test/tpl/partial/contact_list.html +9 -0
  61. package/test/tpl/partial/contact_list.js +1 -0
  62. package/test/tpl/partial/draft_list.es5.js +1 -0
  63. package/test/tpl/partial/draft_list.html +8 -0
  64. package/test/tpl/partial/draft_list.js +1 -0
  65. package/test/tpl/partial/inbox_list.es5.js +1 -0
  66. package/test/tpl/partial/inbox_list.html +7 -0
  67. package/test/tpl/partial/inbox_list.js +1 -0
  68. package/test/tpl/partial/notify_list.es5.js +1 -0
  69. package/test/tpl/partial/notify_list.html +8 -0
  70. package/test/tpl/partial/notify_list.js +1 -0
  71. package/test/tpl/partial/sent_list.es5.js +1 -0
  72. package/test/tpl/partial/sent_list.html +7 -0
  73. package/test/tpl/partial/sent_list.js +1 -0
  74. package/test/tpl/partial/spam_list.es5.js +1 -0
  75. package/test/tpl/partial/spam_list.html +8 -0
  76. package/test/tpl/partial/spam_list.js +1 -0
  77. package/test/tpl/partial/trash_list.es5.js +1 -0
  78. package/test/tpl/partial/trash_list.html +7 -0
  79. package/test/tpl/partial/trash_list.js +1 -0
  80. package/test/tpl/partial/user.es5.js +1 -0
  81. package/test/tpl/partial/user.html +18 -0
  82. package/test/tpl/partial/user.js +1 -0
  83. package/tools/jsdoc.conf +47 -0
  84. package/tools/templates/docdash/publish.js +843 -0
  85. package/tools/templates/docdash/static/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  86. package/tools/templates/docdash/static/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  87. package/tools/templates/docdash/static/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  88. package/tools/templates/docdash/static/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  89. package/tools/templates/docdash/static/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  90. package/tools/templates/docdash/static/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  91. package/tools/templates/docdash/static/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  92. package/tools/templates/docdash/static/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  93. package/tools/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  94. package/tools/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
  95. package/tools/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  96. package/tools/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  97. package/tools/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  98. package/tools/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  99. package/tools/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
  100. package/tools/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  101. package/tools/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  102. package/tools/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  103. package/tools/templates/docdash/static/scripts/collapse.js +67 -0
  104. package/tools/templates/docdash/static/scripts/commonNav.js +28 -0
  105. package/tools/templates/docdash/static/scripts/linenumber.js +25 -0
  106. package/tools/templates/docdash/static/scripts/nav.js +12 -0
  107. package/tools/templates/docdash/static/scripts/polyfill.js +4 -0
  108. package/tools/templates/docdash/static/scripts/prettify/Apache-License-2.0.txt +202 -0
  109. package/tools/templates/docdash/static/scripts/prettify/lang-css.js +2 -0
  110. package/tools/templates/docdash/static/scripts/prettify/prettify.js +28 -0
  111. package/tools/templates/docdash/static/scripts/search.js +99 -0
  112. package/tools/templates/docdash/static/styles/jsdoc.css +803 -0
  113. package/tools/templates/docdash/static/styles/prettify.css +80 -0
  114. package/tools/templates/docdash/tmpl/augments.tmpl +10 -0
  115. package/tools/templates/docdash/tmpl/container.tmpl +203 -0
  116. package/tools/templates/docdash/tmpl/details.tmpl +152 -0
  117. package/tools/templates/docdash/tmpl/example.tmpl +2 -0
  118. package/tools/templates/docdash/tmpl/examples.tmpl +13 -0
  119. package/tools/templates/docdash/tmpl/exceptions.tmpl +32 -0
  120. package/tools/templates/docdash/tmpl/layout.tmpl +102 -0
  121. package/tools/templates/docdash/tmpl/mainpage.tmpl +15 -0
  122. package/tools/templates/docdash/tmpl/members.tmpl +38 -0
  123. package/tools/templates/docdash/tmpl/method.tmpl +132 -0
  124. package/tools/templates/docdash/tmpl/modifies.tmpl +14 -0
  125. package/tools/templates/docdash/tmpl/namespace.tmpl +133 -0
  126. package/tools/templates/docdash/tmpl/params.tmpl +132 -0
  127. package/tools/templates/docdash/tmpl/properties.tmpl +107 -0
  128. package/tools/templates/docdash/tmpl/returns.tmpl +19 -0
  129. package/tools/templates/docdash/tmpl/source.tmpl +8 -0
  130. package/tools/templates/docdash/tmpl/tutorial.tmpl +19 -0
  131. package/tools/templates/docdash/tmpl/type.tmpl +26 -0
  132. package/tools/templates/templates/docdash/publish.js +843 -0
  133. package/tools/templates/templates/docdash/static/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  134. package/tools/templates/templates/docdash/static/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  135. package/tools/templates/templates/docdash/static/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  136. package/tools/templates/templates/docdash/static/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  137. package/tools/templates/templates/docdash/static/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  138. package/tools/templates/templates/docdash/static/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  139. package/tools/templates/templates/docdash/static/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  140. package/tools/templates/templates/docdash/static/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  141. package/tools/templates/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  142. package/tools/templates/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
  143. package/tools/templates/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  144. package/tools/templates/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  145. package/tools/templates/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  146. package/tools/templates/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  147. package/tools/templates/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
  148. package/tools/templates/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  149. package/tools/templates/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  150. package/tools/templates/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  151. package/tools/templates/templates/docdash/static/scripts/collapse.js +67 -0
  152. package/tools/templates/templates/docdash/static/scripts/commonNav.js +28 -0
  153. package/tools/templates/templates/docdash/static/scripts/linenumber.js +25 -0
  154. package/tools/templates/templates/docdash/static/scripts/nav.js +12 -0
  155. package/tools/templates/templates/docdash/static/scripts/polyfill.js +4 -0
  156. package/tools/templates/templates/docdash/static/scripts/prettify/Apache-License-2.0.txt +202 -0
  157. package/tools/templates/templates/docdash/static/scripts/prettify/lang-css.js +2 -0
  158. package/tools/templates/templates/docdash/static/scripts/prettify/prettify.js +28 -0
  159. package/tools/templates/templates/docdash/static/scripts/search.js +99 -0
  160. package/tools/templates/templates/docdash/static/styles/jsdoc.css +803 -0
  161. package/tools/templates/templates/docdash/static/styles/prettify.css +80 -0
  162. package/tools/templates/templates/docdash/tmpl/augments.tmpl +10 -0
  163. package/tools/templates/templates/docdash/tmpl/container.tmpl +203 -0
  164. package/tools/templates/templates/docdash/tmpl/details.tmpl +152 -0
  165. package/tools/templates/templates/docdash/tmpl/example.tmpl +2 -0
  166. package/tools/templates/templates/docdash/tmpl/examples.tmpl +13 -0
  167. package/tools/templates/templates/docdash/tmpl/exceptions.tmpl +32 -0
  168. package/tools/templates/templates/docdash/tmpl/layout.tmpl +102 -0
  169. package/tools/templates/templates/docdash/tmpl/mainpage.tmpl +15 -0
  170. package/tools/templates/templates/docdash/tmpl/members.tmpl +38 -0
  171. package/tools/templates/templates/docdash/tmpl/method.tmpl +132 -0
  172. package/tools/templates/templates/docdash/tmpl/modifies.tmpl +14 -0
  173. package/tools/templates/templates/docdash/tmpl/namespace.tmpl +133 -0
  174. package/tools/templates/templates/docdash/tmpl/params.tmpl +132 -0
  175. package/tools/templates/templates/docdash/tmpl/properties.tmpl +107 -0
  176. package/tools/templates/templates/docdash/tmpl/returns.tmpl +19 -0
  177. package/tools/templates/templates/docdash/tmpl/source.tmpl +8 -0
  178. package/tools/templates/templates/docdash/tmpl/tutorial.tmpl +19 -0
  179. package/tools/templates/templates/docdash/tmpl/type.tmpl +26 -0
  180. package/tpl/partial/user.es5.js +1 -0
  181. package/tpl/partial/user.html +10 -0
  182. package/tpl/partial/user.js +1 -0
@@ -0,0 +1,843 @@
1
+ /*global env: true */
2
+ 'use strict';
3
+
4
+ var doop = require('jsdoc/util/doop');
5
+ var fs = require('jsdoc/fs');
6
+ var helper = require('jsdoc/util/templateHelper');
7
+ var logger = require('jsdoc/util/logger');
8
+ var path = require('jsdoc/path');
9
+ var taffy = require('@jsdoc/salty').taffy;
10
+ var template = require('jsdoc/template');
11
+ var util = require('util');
12
+
13
+ var htmlsafe = helper.htmlsafe;
14
+ var linkto = helper.linkto;
15
+ var resolveAuthorLinks = helper.resolveAuthorLinks;
16
+ var scopeToPunc = helper.scopeToPunc;
17
+ var hasOwnProp = Object.prototype.hasOwnProperty;
18
+
19
+ var data;
20
+ var view;
21
+
22
+ var outdir = path.normalize(env.opts.destination);
23
+
24
+ function copyFile(source, target, cb) {
25
+ var cbCalled = false;
26
+
27
+ var rd = fs.createReadStream(source);
28
+ rd.on("error", function(err) {
29
+ done(err);
30
+ });
31
+ var wr = fs.createWriteStream(target);
32
+ wr.on("error", function(err) {
33
+ done(err);
34
+ });
35
+ wr.on("close", function(ex) {
36
+ done();
37
+ });
38
+ rd.pipe(wr);
39
+
40
+ function done(err) {
41
+ if (!cbCalled) {
42
+ cb(err);
43
+ cbCalled = true;
44
+ }
45
+ }
46
+ }
47
+
48
+ function find(spec) {
49
+ return helper.find(data, spec);
50
+ }
51
+
52
+ function tutoriallink(tutorial) {
53
+ return helper.toTutorial(tutorial, null, { tag: 'em', classname: 'disabled', prefix: 'Tutorial: ' });
54
+ }
55
+
56
+ function getAncestorLinks(doclet) {
57
+ return helper.getAncestorLinks(data, doclet);
58
+ }
59
+
60
+ function hashToLink(doclet, hash) {
61
+ if ( !/^(#.+)/.test(hash) ) { return hash; }
62
+
63
+ var url = helper.createLink(doclet);
64
+
65
+ url = url.replace(/(#.+|$)/, hash);
66
+ return '<a href="' + url + '">' + hash + '</a>';
67
+ }
68
+
69
+ function needsSignature(doclet) {
70
+ var needsSig = false;
71
+
72
+ // function and class definitions always get a signature
73
+ if (doclet.kind === 'function' || doclet.kind === 'class' && !doclet.hideconstructor) {
74
+ needsSig = true;
75
+ }
76
+ // typedefs that contain functions get a signature, too
77
+ else if (doclet.kind === 'typedef' && doclet.type && doclet.type.names &&
78
+ doclet.type.names.length) {
79
+ for (var i = 0, l = doclet.type.names.length; i < l; i++) {
80
+ if (doclet.type.names[i].toLowerCase() === 'function') {
81
+ needsSig = true;
82
+ break;
83
+ }
84
+ }
85
+ }
86
+ // and namespaces that are functions get a signature (but finding them is a
87
+ // bit messy)
88
+ else if (doclet.kind === 'namespace' && doclet.meta && doclet.meta.code &&
89
+ doclet.meta.code.type && doclet.meta.code.type.match(/[Ff]unction/)) {
90
+ needsSig = true;
91
+ }
92
+
93
+ return needsSig;
94
+ }
95
+
96
+ function getSignatureAttributes(item) {
97
+ var attributes = [];
98
+
99
+ if (item.optional) {
100
+ attributes.push('opt');
101
+ }
102
+
103
+ if (item.nullable === true) {
104
+ attributes.push('nullable');
105
+ }
106
+ else if (item.nullable === false) {
107
+ attributes.push('non-null');
108
+ }
109
+
110
+ return attributes;
111
+ }
112
+
113
+ function updateItemName(item) {
114
+ var attributes = getSignatureAttributes(item);
115
+ var itemName = item.name || '';
116
+
117
+ if (item.variable) {
118
+ itemName = '&hellip;' + itemName;
119
+ }
120
+
121
+ if (attributes && attributes.length) {
122
+ itemName = util.format( '%s<span class="signature-attributes">%s</span>', itemName,
123
+ attributes.join(', ') );
124
+ }
125
+
126
+ return itemName;
127
+ }
128
+
129
+ function addParamAttributes(params) {
130
+ return params.filter(function(param) {
131
+ return param.name && param.name.indexOf('.') === -1;
132
+ }).map(updateItemName);
133
+ }
134
+
135
+ function buildItemTypeStrings(item) {
136
+ var types = [];
137
+
138
+ if (item && item.type && item.type.names) {
139
+ item.type.names.forEach(function(name) {
140
+ types.push( linkto(name, htmlsafe(name)) );
141
+ });
142
+ }
143
+
144
+ return types;
145
+ }
146
+
147
+ function buildAttribsString(attribs) {
148
+ var attribsString = '';
149
+
150
+ if (attribs && attribs.length) {
151
+ attribsString = htmlsafe( util.format('(%s) ', attribs.join(', ')) );
152
+ }
153
+
154
+ return attribsString;
155
+ }
156
+
157
+ function addNonParamAttributes(items) {
158
+ var types = [];
159
+
160
+ items.forEach(function(item) {
161
+ types = types.concat( buildItemTypeStrings(item) );
162
+ });
163
+
164
+ return types;
165
+ }
166
+
167
+ function addSignatureParams(f) {
168
+ var params = f.params ? addParamAttributes(f.params) : [];
169
+ f.signature = util.format( '%s(%s)', (f.signature || ''), params.join(', ') );
170
+ }
171
+
172
+ function addSignatureReturns(f) {
173
+ var attribs = [];
174
+ var attribsString = '';
175
+ var returnTypes = [];
176
+ var returnTypesString = '';
177
+ var source = f.yields || f.returns;
178
+
179
+ // jam all the return-type attributes into an array. this could create odd results (for example,
180
+ // if there are both nullable and non-nullable return types), but let's assume that most people
181
+ // who use multiple @return tags aren't using Closure Compiler type annotations, and vice-versa.
182
+ if (source) {
183
+ source.forEach(function(item) {
184
+ helper.getAttribs(item).forEach(function(attrib) {
185
+ if (attribs.indexOf(attrib) === -1) {
186
+ attribs.push(attrib);
187
+ }
188
+ });
189
+ });
190
+
191
+ attribsString = buildAttribsString(attribs);
192
+ }
193
+
194
+ if (source) {
195
+ returnTypes = addNonParamAttributes(source);
196
+ }
197
+ if (returnTypes.length) {
198
+ returnTypesString = util.format( ' &rarr; %s{%s}', attribsString, returnTypes.join('|') );
199
+ }
200
+
201
+ f.signature = '<span class="signature">' + (f.signature || '') + '</span>' +
202
+ '<span class="type-signature">' + returnTypesString + '</span>';
203
+ }
204
+
205
+ function addSignatureTypes(f) {
206
+ var types = f.type ? buildItemTypeStrings(f) : [];
207
+
208
+ f.signature = (f.signature || '') + '<span class="type-signature">' +
209
+ (types.length ? ' :' + types.join('|') : '') + '</span>';
210
+ }
211
+
212
+ function addAttribs(f) {
213
+ var attribs = helper.getAttribs(f);
214
+ var attribsString = buildAttribsString(attribs);
215
+ if (attribsString && attribsString.length) {
216
+ f.attribs = util.format('<span class="type-signature type-signature-' + attribsString.replace(/\(/g, '').replace(/\)/g, '').trim() +'">%s</span>', attribsString);
217
+ }
218
+ else {
219
+ f.attribs = util.format('<span class="type-signature">%s</span>', attribsString);
220
+ }
221
+ }
222
+
223
+ function shortenPaths(files, commonPrefix) {
224
+ Object.keys(files).forEach(function(file) {
225
+ files[file].shortened = files[file].resolved.replace(commonPrefix, '')
226
+ // always use forward slashes
227
+ .replace(/\\/g, '/');
228
+ });
229
+
230
+ return files;
231
+ }
232
+
233
+ function getPathFromDoclet(doclet) {
234
+ if (!doclet.meta) {
235
+ return null;
236
+ }
237
+
238
+ return doclet.meta.path && doclet.meta.path !== 'null' ?
239
+ path.join(doclet.meta.path, doclet.meta.filename) :
240
+ doclet.meta.filename;
241
+ }
242
+
243
+ function generate(type, title, docs, filename, resolveLinks) {
244
+ resolveLinks = resolveLinks === false ? false : true;
245
+
246
+ var docData = {
247
+ type: type,
248
+ title: title,
249
+ docs: docs
250
+ };
251
+
252
+ var outpath = path.join(outdir, filename),
253
+ html = view.render('container.tmpl', docData);
254
+
255
+ if (resolveLinks) {
256
+ html = helper.resolveLinks(html); // turn {@link foo} into <a href="foodoc.html">foo</a>
257
+ }
258
+
259
+ fs.writeFileSync(outpath, html, 'utf8');
260
+ }
261
+
262
+ function generateSourceFiles(sourceFiles, encoding) {
263
+ encoding = encoding || 'utf8';
264
+ Object.keys(sourceFiles).forEach(function(file) {
265
+ var source;
266
+ // links are keyed to the shortened path in each doclet's `meta.shortpath` property
267
+ var sourceOutfile = helper.getUniqueFilename(sourceFiles[file].shortened);
268
+ helper.registerLink(sourceFiles[file].shortened, sourceOutfile);
269
+
270
+ try {
271
+ source = {
272
+ kind: 'source',
273
+ code: helper.htmlsafe( fs.readFileSync(sourceFiles[file].resolved, encoding) )
274
+ };
275
+ }
276
+ catch(e) {
277
+ logger.error('Error while generating source file %s: %s', file, e.message);
278
+ }
279
+
280
+ generate('Source', sourceFiles[file].shortened, [source], sourceOutfile, false);
281
+ });
282
+ }
283
+
284
+ /**
285
+ * Look for classes or functions with the same name as modules (which indicates that the module
286
+ * exports only that class or function), then attach the classes or functions to the `module`
287
+ * property of the appropriate module doclets. The name of each class or function is also updated
288
+ * for display purposes. This function mutates the original arrays.
289
+ *
290
+ * @private
291
+ * @param {Array.<module:jsdoc/doclet.Doclet>} doclets - The array of classes and functions to
292
+ * check.
293
+ * @param {Array.<module:jsdoc/doclet.Doclet>} modules - The array of module doclets to search.
294
+ */
295
+ function attachModuleSymbols(doclets, modules) {
296
+ var symbols = {};
297
+
298
+ // build a lookup table
299
+ doclets.forEach(function(symbol) {
300
+ symbols[symbol.longname] = symbols[symbol.longname] || [];
301
+ symbols[symbol.longname].push(symbol);
302
+ });
303
+
304
+ return modules.map(function(module) {
305
+ if (symbols[module.longname]) {
306
+ module.modules = symbols[module.longname]
307
+ // Only show symbols that have a description. Make an exception for classes, because
308
+ // we want to show the constructor-signature heading no matter what.
309
+ .filter(function(symbol) {
310
+ return symbol.description || symbol.kind === 'class';
311
+ })
312
+ .map(function(symbol) {
313
+ symbol = doop(symbol);
314
+
315
+ if (symbol.kind === 'class' || symbol.kind === 'function' && !symbol.hideconstructor) {
316
+ symbol.name = symbol.name.replace('module:', '(require("') + '"))';
317
+ }
318
+
319
+ return symbol;
320
+ });
321
+ }
322
+ });
323
+ }
324
+
325
+ function buildMemberNav(items, itemHeading, itemsSeen, linktoFn) {
326
+ var nav = '';
327
+
328
+ let classes_boxed = false;
329
+
330
+ if (items && items.length) {
331
+ var itemsNav = '';
332
+ var docdash = env && env.conf && env.conf.docdash || {};
333
+ var level = typeof docdash.navLevel === 'number' && docdash.navLevel >= 0 ?
334
+ docdash.navLevel :
335
+ Infinity;
336
+
337
+ items.forEach(function(item) {
338
+ var displayName;
339
+ var methods = find({kind:'function', memberof: item.longname});
340
+ var members = find({kind:'member', memberof: item.longname});
341
+ var conf = env && env.conf || {};
342
+ var classes = '';
343
+
344
+ // show private class?
345
+ if (docdash.private === false && item.access === 'private') return;
346
+
347
+ // depth to show?
348
+ if (item.ancestors && item.ancestors.length > level) {
349
+ classes += 'level-hide';
350
+ }
351
+
352
+ classes = classes ? ' class="'+ classes + '"' : '';
353
+ itemsNav += '<li'+ classes +'>';
354
+ if ( !hasOwnProp.call(item, 'longname') ) {
355
+ itemsNav += linktoFn('', item.name);
356
+ } else if ( !hasOwnProp.call(itemsSeen, item.longname) ) {
357
+ if (conf.templates.default.useLongnameInNav) {
358
+ displayName = item.longname;
359
+ } else {
360
+ displayName = item.name;
361
+ }
362
+ itemsNav += linktoFn(item.longname, displayName.replace(/\b(module|event):/g, ''));
363
+
364
+ if (docdash.static && members.find(function (m) { return m.scope === 'static'; } )) {
365
+ itemsNav += "<ul class='members'>";
366
+
367
+ members.forEach(function (member) {
368
+ if (!member.scope === 'static') return;
369
+ itemsNav += "<li data-type='member'";
370
+ if(docdash.collapse)
371
+ itemsNav += " style='display: none;'";
372
+ itemsNav += ">";
373
+ itemsNav += linkto(member.longname, member.name);
374
+ itemsNav += "</li>";
375
+ });
376
+
377
+ itemsNav += "</ul>";
378
+ }
379
+
380
+ if (methods.length) {
381
+ itemsNav += "<ul class='methods'>";
382
+
383
+ methods.forEach(function (method) {
384
+ if (docdash.static === false && method.scope === 'static') return;
385
+ if (docdash.private === false && method.access === 'private') return;
386
+
387
+ var navItem = '';
388
+ var navItemLink = linkto(method.longname, method.name);
389
+
390
+ navItem += "<li data-type='method'";
391
+ if(docdash.collapse)
392
+ navItem += " style='display: none;'";
393
+ navItem += ">";
394
+ navItem += navItemLink;
395
+ navItem += "</li>";
396
+
397
+ itemsNav += navItem;
398
+ });
399
+
400
+ itemsNav += "</ul>";
401
+ }
402
+
403
+ itemsSeen[item.longname] = true;
404
+ }
405
+ itemsNav += '</li>';
406
+ });
407
+
408
+ if (itemsNav !== '') {
409
+ if( docdash.collapse === "top" ) {
410
+ nav += `<h3 class="collapsed_header">${itemHeading}</h3>
411
+ <ul class="collapse_top menu-contained-nav">
412
+ ${itemsNav}
413
+ </ul>`
414
+ } else {
415
+ if ( itemHeading === "Classes" ) {
416
+ nav += `<h3>${itemHeading}</h3>
417
+ <ul id="classes-ul-overflow" class="menu-contained-nav" >${itemsNav}</ul>
418
+ `
419
+ } else {
420
+ nav += `<h3>${itemHeading}</h3>
421
+ <ul>${itemsNav}</ul>
422
+ `
423
+ }
424
+ }
425
+ }
426
+ }
427
+
428
+ return nav;
429
+ }
430
+
431
+ function linktoTutorial(longName, name) {
432
+ return tutoriallink(name);
433
+ }
434
+
435
+ function linktoExternal(longName, name) {
436
+ return linkto(longName, name.replace(/(^"|"$)/g, ''));
437
+ }
438
+
439
+ /**
440
+ * Create the navigation sidebar.
441
+ * @param {object} members The members that will be used to create the sidebar.
442
+ * @param {array<object>} members.classes
443
+ * @param {array<object>} members.externals
444
+ * @param {array<object>} members.globals
445
+ * @param {array<object>} members.mixins
446
+ * @param {array<object>} members.modules
447
+ * @param {array<object>} members.namespaces
448
+ * @param {array<object>} members.tutorials
449
+ * @param {array<object>} members.events
450
+ * @param {array<object>} members.interfaces
451
+ * @return {string} The HTML for the navigation sidebar.
452
+ */
453
+
454
+ function buildNav(members) {
455
+ var nav = '<h2><a href="index.html">Overview</a></h2>';
456
+ var seen = {};
457
+ var seenTutorials = {};
458
+ var docdash = env && env.conf && env.conf.docdash || {};
459
+ if(docdash.menu){
460
+ for(var menu in docdash.menu){
461
+ nav += '<h2><a ';
462
+ //add attributes
463
+ for(var attr in docdash.menu[menu]){
464
+ nav += attr+'="' + docdash.menu[menu][attr] + '" ';
465
+ }
466
+ nav += '>' + menu + '</a></h2>';
467
+ }
468
+ }
469
+
470
+ function buildMemberNavGlobal() {
471
+ var ret = "";
472
+ if (members.globals.length) {
473
+ var globalNav = '';
474
+
475
+ members.globals.forEach(function(g) {
476
+ if ( (docdash.typedefs || g.kind !== 'typedef') && !hasOwnProp.call(seen, g.longname) ) {
477
+ globalNav += '<li>' + linkto(g.longname, g.name) + '</li>';
478
+ }
479
+ seen[g.longname] = true;
480
+ });
481
+
482
+ if (!globalNav) {
483
+ // turn the heading into a link so you can actually get to the global page
484
+ ret += '<h3>' + linkto('global', 'Global') + '</h3>';
485
+ }
486
+ else {
487
+ if(docdash.collapse === "top") {
488
+ ret += '<h3 class="collapsed_header">Global</h3><ul class="collapse_top">' + globalNav + '</ul>';
489
+ }
490
+ else {
491
+ ret += '<h3>Global</h3><ul>' + globalNav + '</ul>';
492
+ }
493
+ }
494
+ }
495
+ return ret;
496
+ }
497
+ var defaultOrder = [
498
+ 'Classes', 'Modules', 'Externals', 'Events', 'Namespaces', 'Mixins', 'Tutorials', 'Interfaces', 'Global'
499
+ ];
500
+ var order = docdash.sectionOrder || defaultOrder;
501
+ var sections = {
502
+ Classes: buildMemberNav(members.classes, 'Classes', seen, linkto),
503
+ Modules: buildMemberNav(members.modules, 'Modules', {}, linkto),
504
+ Externals: buildMemberNav(members.externals, 'Externals', seen, linktoExternal),
505
+ Events: buildMemberNav(members.events, 'Events', seen, linkto),
506
+ Namespaces: buildMemberNav(members.namespaces, 'Namespaces', seen, linkto),
507
+ Mixins: buildMemberNav(members.mixins, 'Mixins', seen, linkto),
508
+ Tutorials: buildMemberNav(members.tutorials, 'Tutorials', seenTutorials, linktoTutorial),
509
+ Interfaces: buildMemberNav(members.interfaces, 'Interfaces', seen, linkto),
510
+ Global: buildMemberNavGlobal()
511
+ };
512
+ order.forEach(member => nav += sections[member]);
513
+
514
+ return nav;
515
+ }
516
+
517
+ /**
518
+ @param {TAFFY} taffyData See <http://taffydb.com/>.
519
+ @param {object} opts
520
+ @param {Tutorial} tutorials
521
+ */
522
+ exports.publish = function(taffyData, opts, tutorials) {
523
+ var docdash = env && env.conf && env.conf.docdash || {};
524
+ data = taffyData;
525
+
526
+ var conf = env.conf.templates || {};
527
+ conf.default = conf.default || {};
528
+
529
+ var templatePath = path.normalize(opts.template);
530
+ view = new template.Template( path.join(templatePath, 'tmpl') );
531
+
532
+ // claim some special filenames in advance, so the All-Powerful Overseer of Filename Uniqueness
533
+ // doesn't try to hand them out later
534
+ var indexUrl = helper.getUniqueFilename('index');
535
+ // don't call registerLink() on this one! 'index' is also a valid longname
536
+
537
+ var globalUrl = helper.getUniqueFilename('global');
538
+ helper.registerLink('global', globalUrl);
539
+
540
+ // set up templating
541
+ view.layout = conf.default.layoutFile ?
542
+ path.getResourcePath(path.dirname(conf.default.layoutFile),
543
+ path.basename(conf.default.layoutFile) ) :
544
+ 'layout.tmpl';
545
+
546
+ // set up tutorials for helper
547
+ helper.setTutorials(tutorials);
548
+
549
+ data = helper.prune(data);
550
+
551
+ docdash.sort !== false && data.sort('longname, version, since');
552
+ helper.addEventListeners(data);
553
+
554
+ var sourceFiles = {};
555
+ var sourceFilePaths = [];
556
+ data().each(function(doclet) {
557
+ if(docdash.removeQuotes){
558
+ if(docdash.removeQuotes === "all"){
559
+ if(doclet.name){
560
+ doclet.name = doclet.name.replace(/"/g, '');
561
+ doclet.name = doclet.name.replace(/'/g, '');
562
+ }
563
+ if(doclet.longname){
564
+ doclet.longname = doclet.longname.replace(/"/g, '');
565
+ doclet.longname = doclet.longname.replace(/'/g, '');
566
+ }
567
+ }
568
+ else if(docdash.removeQuotes === "trim"){
569
+ if(doclet.name){
570
+ doclet.name = doclet.name.replace(/^"(.*)"$/, '$1');
571
+ doclet.name = doclet.name.replace(/^'(.*)'$/, '$1');
572
+ }
573
+ if(doclet.longname){
574
+ doclet.longname = doclet.longname.replace(/^"(.*)"$/, '$1');
575
+ doclet.longname = doclet.longname.replace(/^'(.*)'$/, '$1');
576
+ }
577
+ }
578
+ }
579
+ doclet.attribs = '';
580
+
581
+ if (doclet.examples) {
582
+ doclet.examples = doclet.examples.map(function(example) {
583
+ var caption, code;
584
+
585
+ if (example && example.match(/^\s*<caption>([\s\S]+?)<\/caption>(\s*[\n\r])([\s\S]+)$/i)) {
586
+ caption = RegExp.$1;
587
+ code = RegExp.$3;
588
+ }
589
+
590
+ return {
591
+ caption: caption || '',
592
+ code: code || example || ''
593
+ };
594
+ });
595
+ }
596
+ if (doclet.see) {
597
+ doclet.see.forEach(function(seeItem, i) {
598
+ doclet.see[i] = hashToLink(doclet, seeItem);
599
+ });
600
+ }
601
+
602
+ // build a list of source files
603
+ var sourcePath;
604
+ if (doclet.meta) {
605
+ sourcePath = getPathFromDoclet(doclet);
606
+ sourceFiles[sourcePath] = {
607
+ resolved: sourcePath,
608
+ shortened: null
609
+ };
610
+ if (sourceFilePaths.indexOf(sourcePath) === -1) {
611
+ sourceFilePaths.push(sourcePath);
612
+ }
613
+ }
614
+ });
615
+
616
+ // update outdir if necessary, then create outdir
617
+ var packageInfo = ( find({kind: 'package'}) || [] ) [0];
618
+ if (packageInfo) {
619
+ var subdirs = [outdir];
620
+
621
+ if (packageInfo.name) {
622
+ var packageName = packageInfo.name.split('/');
623
+
624
+ if (packageName.length > 1 && docdash.scopeInOutputPath !== false) {
625
+ subdirs.push(packageName[0]);
626
+ }
627
+
628
+ if (docdash.nameInOutputPath !== false) {
629
+ subdirs.push((packageName.length > 1 ? packageName[1] : packageName[0]));
630
+ }
631
+ }
632
+
633
+ if (packageInfo.version && docdash.versionInOutputPath !== false) {
634
+ subdirs.push(packageInfo.version);
635
+ }
636
+
637
+ if (subdirs.length > 1) {
638
+ outdir = path.join.apply(null, subdirs);
639
+ }
640
+ }
641
+
642
+ fs.mkPath(outdir);
643
+
644
+ // copy the template's static files to outdir
645
+ var fromDir = path.join(templatePath, 'static');
646
+ var staticFiles = fs.ls(fromDir, 3);
647
+
648
+ staticFiles.forEach(function(fileName) {
649
+ var toDir = fs.toDir( fileName.replace(fromDir, outdir) );
650
+ fs.mkPath(toDir);
651
+ copyFile(fileName, path.join(toDir, path.basename(fileName)), function(err){if(err) console.err(err);});
652
+ });
653
+
654
+ // copy user-specified static files to outdir
655
+ var staticFilePaths;
656
+ var staticFileFilter;
657
+ var staticFileScanner;
658
+ if (conf.default.staticFiles) {
659
+ // The canonical property name is `include`. We accept `paths` for backwards compatibility
660
+ // with a bug in JSDoc 3.2.x.
661
+ staticFilePaths = conf.default.staticFiles.include ||
662
+ conf.default.staticFiles.paths ||
663
+ [];
664
+ staticFileFilter = new (require('jsdoc/src/filter')).Filter(conf.default.staticFiles);
665
+ staticFileScanner = new (require('jsdoc/src/scanner')).Scanner();
666
+
667
+ staticFilePaths.forEach(function(filePath) {
668
+ var extraStaticFiles = staticFileScanner.scan([filePath], 10, staticFileFilter);
669
+
670
+ extraStaticFiles.forEach(function(fileName) {
671
+ var sourcePath = fs.toDir(filePath);
672
+ var toDir = fs.toDir( fileName.replace(sourcePath, outdir) );
673
+ fs.mkPath(toDir);
674
+ copyFile(fileName, path.join(toDir, path.basename(fileName)), function(err){if(err) console.err(err);});
675
+ });
676
+ });
677
+ }
678
+
679
+ if (sourceFilePaths.length) {
680
+ sourceFiles = shortenPaths( sourceFiles, path.commonPrefix(sourceFilePaths) );
681
+ }
682
+ data().each(function(doclet) {
683
+ var url = helper.createLink(doclet);
684
+ if (docdash.noURLEncode) {
685
+ url = decodeURI(url);
686
+ }
687
+ helper.registerLink(doclet.longname, url);
688
+
689
+ // add a shortened version of the full path
690
+ var docletPath;
691
+ if (doclet.meta) {
692
+ docletPath = getPathFromDoclet(doclet);
693
+ docletPath = sourceFiles[docletPath].shortened;
694
+ if (docletPath) {
695
+ doclet.meta.shortpath = docletPath;
696
+ }
697
+ }
698
+ });
699
+
700
+ data().each(function(doclet) {
701
+ var url = helper.longnameToUrl[doclet.longname];
702
+
703
+ if (url.indexOf('#') > -1) {
704
+ doclet.id = helper.longnameToUrl[doclet.longname].split(/#/).pop();
705
+ }
706
+ else {
707
+ doclet.id = doclet.name;
708
+ }
709
+
710
+ if ( needsSignature(doclet) ) {
711
+ addSignatureParams(doclet);
712
+ addSignatureReturns(doclet);
713
+ addAttribs(doclet);
714
+ }
715
+ });
716
+
717
+ // do this after the urls have all been generated
718
+ data().each(function(doclet) {
719
+ doclet.ancestors = getAncestorLinks(doclet);
720
+
721
+ if (doclet.kind === 'member') {
722
+ addSignatureTypes(doclet);
723
+ addAttribs(doclet);
724
+ }
725
+
726
+ if (doclet.kind === 'constant') {
727
+ addSignatureTypes(doclet);
728
+ addAttribs(doclet);
729
+ doclet.kind = 'member';
730
+ }
731
+ });
732
+
733
+ var members = helper.getMembers(data);
734
+ members.tutorials = tutorials.children;
735
+
736
+ // output pretty-printed source files by default
737
+ var outputSourceFiles = conf.default && conf.default.outputSourceFiles !== false
738
+ ? true
739
+ : false;
740
+
741
+ // add template helpers
742
+ view.find = find;
743
+ view.linkto = linkto;
744
+ view.resolveAuthorLinks = resolveAuthorLinks;
745
+ view.tutoriallink = tutoriallink;
746
+ view.htmlsafe = htmlsafe;
747
+ view.outputSourceFiles = outputSourceFiles;
748
+
749
+ // once for all
750
+ view.nav = buildNav(members);
751
+ attachModuleSymbols( find({ longname: {left: 'module:'} }), members.modules );
752
+
753
+ // generate the pretty-printed source files first so other pages can link to them
754
+ if (outputSourceFiles) {
755
+ generateSourceFiles(sourceFiles, opts.encoding);
756
+ }
757
+
758
+ if (members.globals.length) {
759
+ generate('', 'Global', [{kind: 'globalobj'}], globalUrl);
760
+ }
761
+
762
+ // index page displays information from package.json and lists files
763
+ var files = find({kind: 'file'});
764
+ var packages = find({kind: 'package'});
765
+
766
+ generate('', 'Home',
767
+ packages.concat(
768
+ [{kind: 'mainpage', readme: opts.readme, longname: (opts.mainpagetitle) ? opts.mainpagetitle : 'Main Page'}]
769
+ ).concat(files),
770
+ indexUrl);
771
+
772
+ // common nav generation, no need for templating here, we already have full html
773
+ if (docdash.commonNav) {
774
+ fs.writeFileSync(path.join(outdir, 'nav.inc.html'), view.nav, 'utf8');
775
+ }
776
+
777
+ // set up the lists that we'll use to generate pages
778
+ var classes = taffy(members.classes);
779
+ var modules = taffy(members.modules);
780
+ var namespaces = taffy(members.namespaces);
781
+ var mixins = taffy(members.mixins);
782
+ var externals = taffy(members.externals);
783
+ var interfaces = taffy(members.interfaces);
784
+
785
+ Object.keys(helper.longnameToUrl).forEach(function(longname) {
786
+ var myModules = helper.find(modules, {longname: longname});
787
+ if (myModules.length) {
788
+ generate('Module', myModules[0].name, myModules, helper.longnameToUrl[longname]);
789
+ }
790
+
791
+ var myClasses = helper.find(classes, {longname: longname});
792
+ if (myClasses.length) {
793
+ generate('Class', myClasses[0].name, myClasses, helper.longnameToUrl[longname]);
794
+ }
795
+
796
+ var myNamespaces = helper.find(namespaces, {longname: longname});
797
+ if (myNamespaces.length) {
798
+ generate('Namespace', myNamespaces[0].name, myNamespaces, helper.longnameToUrl[longname]);
799
+ }
800
+
801
+ var myMixins = helper.find(mixins, {longname: longname});
802
+ if (myMixins.length) {
803
+ generate('Mixin', myMixins[0].name, myMixins, helper.longnameToUrl[longname]);
804
+ }
805
+
806
+ var myExternals = helper.find(externals, {longname: longname});
807
+ if (myExternals.length) {
808
+ generate('External', myExternals[0].name, myExternals, helper.longnameToUrl[longname]);
809
+ }
810
+
811
+ var myInterfaces = helper.find(interfaces, {longname: longname});
812
+ if (myInterfaces.length) {
813
+ generate('Interface', myInterfaces[0].name, myInterfaces, helper.longnameToUrl[longname]);
814
+ }
815
+ });
816
+
817
+ // TODO: move the tutorial functions to templateHelper.js
818
+ function generateTutorial(title, tutorial, filename) {
819
+ var tutorialData = {
820
+ title: title,
821
+ header: tutorial.title,
822
+ content: tutorial.parse(),
823
+ children: tutorial.children
824
+ };
825
+
826
+ var tutorialPath = path.join(outdir, filename);
827
+ var html = view.render('tutorial.tmpl', tutorialData);
828
+
829
+ // yes, you can use {@link} in tutorials too!
830
+ html = helper.resolveLinks(html); // turn {@link foo} into <a href="foodoc.html">foo</a>
831
+ fs.writeFileSync(tutorialPath, html, 'utf8');
832
+ }
833
+
834
+ // tutorials can have only one parent so there is no risk for loops
835
+ function saveChildren(node) {
836
+ node.children.forEach(function(child) {
837
+ generateTutorial('Tutorial: ' + child.title, child, helper.tutorialToUrl(child.name));
838
+ saveChildren(child);
839
+ });
840
+ }
841
+
842
+ saveChildren(tutorials);
843
+ };