bookish-press 0.4.47 → 0.4.49

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 (533) hide show
  1. package/components/Auth.svelte +55 -0
  2. package/components/Auth.svelte.d.ts +16 -0
  3. package/{src/lib/components/Authentication.ts → components/Authentication.d.ts} +0 -2
  4. package/components/Authentication.js +1 -0
  5. package/{src/lib/components → components}/BookPreview.svelte +22 -27
  6. package/components/BookPreview.svelte.d.ts +18 -0
  7. package/{src/lib/components → components}/External.svelte +1 -2
  8. package/components/External.svelte.d.ts +18 -0
  9. package/components/Link.svelte +51 -0
  10. package/components/Link.svelte.d.ts +18 -0
  11. package/{src/lib/components → components}/app/BookList.svelte +3 -6
  12. package/components/app/BookList.svelte.d.ts +18 -0
  13. package/{src/lib/components → components}/app/Button.svelte +4 -5
  14. package/components/app/Button.svelte.d.ts +22 -0
  15. package/{src/lib/components → components}/app/Feedback.svelte +7 -11
  16. package/components/app/Feedback.svelte.d.ts +18 -0
  17. package/{src/lib/components → components}/app/Head.svelte +1 -2
  18. package/components/app/Head.svelte.d.ts +18 -0
  19. package/{src/lib/components → components}/app/Large.svelte +0 -0
  20. package/components/app/Large.svelte.d.ts +27 -0
  21. package/{src/lib/components → components}/app/Lead.svelte +0 -0
  22. package/components/app/Lead.svelte.d.ts +27 -0
  23. package/{src/lib/components → components}/app/Link.svelte +3 -4
  24. package/components/app/Link.svelte.d.ts +20 -0
  25. package/{src/lib/components → components}/app/Options.svelte +4 -5
  26. package/components/app/Options.svelte.d.ts +19 -0
  27. package/{src/lib/components → components}/app/Paragraph.svelte +1 -2
  28. package/components/app/Paragraph.svelte.d.ts +18 -0
  29. package/{src/lib/components → components}/app/Section.svelte +0 -0
  30. package/components/app/Section.svelte.d.ts +27 -0
  31. package/{src/lib/components → components}/app/Table.svelte +0 -0
  32. package/components/app/Table.svelte.d.ts +27 -0
  33. package/{src/lib/components → components}/app/TextInput.svelte +9 -12
  34. package/components/app/TextInput.svelte.d.ts +22 -0
  35. package/{src/lib/components → components}/chapter/Atom.svelte +12 -18
  36. package/components/chapter/Atom.svelte.d.ts +19 -0
  37. package/components/chapter/Block.svelte +37 -0
  38. package/components/chapter/Block.svelte.d.ts +17 -0
  39. package/{src/lib/components → components}/chapter/Callout.svelte +3 -6
  40. package/components/chapter/Callout.svelte.d.ts +17 -0
  41. package/{src/lib/components → components}/chapter/CaptionedCode.svelte +13 -21
  42. package/components/chapter/CaptionedCode.svelte.d.ts +17 -0
  43. package/{src/lib/components → components}/chapter/ChapterBody.svelte +9 -13
  44. package/components/chapter/ChapterBody.svelte.d.ts +19 -0
  45. package/{src/lib/components → components}/chapter/Citations.svelte +33 -34
  46. package/components/chapter/Citations.svelte.d.ts +17 -0
  47. package/{src/lib/components → components}/chapter/Code.svelte +60 -64
  48. package/components/chapter/Code.svelte.d.ts +22 -0
  49. package/{src/lib/components → components}/chapter/Comment.svelte +18 -30
  50. package/components/chapter/Comment.svelte.d.ts +17 -0
  51. package/{src/lib/components → components}/chapter/Definition.svelte +17 -23
  52. package/components/chapter/Definition.svelte.d.ts +17 -0
  53. package/{src/lib/components → components}/chapter/Embed.svelte +77 -97
  54. package/components/chapter/Embed.svelte.d.ts +20 -0
  55. package/components/chapter/ErrorMessage.svelte +9 -0
  56. package/components/chapter/ErrorMessage.svelte.d.ts +17 -0
  57. package/components/chapter/ExtendedPrism.d.ts +2 -0
  58. package/{src/lib/components → components}/chapter/ExtendedPrism.js +0 -0
  59. package/{src/lib/components → components}/chapter/Figure.svelte +26 -34
  60. package/components/chapter/Figure.svelte.d.ts +24 -0
  61. package/{src/lib/components → components}/chapter/Footnote.svelte +20 -32
  62. package/components/chapter/Footnote.svelte.d.ts +19 -0
  63. package/{src/lib/components → components}/chapter/Format.svelte +34 -39
  64. package/components/chapter/Format.svelte.d.ts +19 -0
  65. package/{src/lib/components → components}/chapter/InlineCode.svelte +5 -9
  66. package/components/chapter/InlineCode.svelte.d.ts +17 -0
  67. package/{src/lib/components → components}/chapter/Label.svelte +14 -23
  68. package/components/chapter/Label.svelte.d.ts +17 -0
  69. package/{src/lib/components → components}/chapter/Link.svelte +21 -27
  70. package/components/chapter/Link.svelte.d.ts +17 -0
  71. package/{src/lib/components → components}/chapter/List.svelte +3 -5
  72. package/components/chapter/List.svelte.d.ts +17 -0
  73. package/{src/lib/components → components}/chapter/Marginal.svelte +41 -54
  74. package/components/chapter/Marginal.svelte.d.ts +22 -0
  75. package/{src/lib/components → components}/chapter/Paragraph.svelte +20 -25
  76. package/components/chapter/Paragraph.svelte.d.ts +18 -0
  77. package/{src/lib/components → components}/chapter/Positioned.svelte +1 -4
  78. package/components/chapter/Positioned.svelte.d.ts +19 -0
  79. package/{src/lib/components → components}/chapter/Problem.svelte +0 -0
  80. package/components/chapter/Problem.svelte.d.ts +27 -0
  81. package/components/chapter/Python.svelte +128 -0
  82. package/components/chapter/Python.svelte.d.ts +18 -0
  83. package/{src/lib/components → components}/chapter/Quote.svelte +19 -13
  84. package/components/chapter/Quote.svelte.d.ts +17 -0
  85. package/{src/lib/components → components}/chapter/Rule.svelte +1 -4
  86. package/components/chapter/Rule.svelte.d.ts +17 -0
  87. package/{src/lib/components → components}/chapter/Table.svelte +7 -11
  88. package/components/chapter/Table.svelte.d.ts +17 -0
  89. package/components/chapter/Text.svelte +87 -0
  90. package/components/chapter/Text.svelte.d.ts +18 -0
  91. package/components/editor/BookishEditor.svelte +884 -0
  92. package/components/editor/BookishEditor.svelte.d.ts +25 -0
  93. package/components/editor/CalloutEditor.svelte +10 -0
  94. package/components/editor/CalloutEditor.svelte.d.ts +17 -0
  95. package/{src/lib/components → components}/editor/CaptionedCodeEditor.svelte +6 -10
  96. package/components/editor/CaptionedCodeEditor.svelte.d.ts +17 -0
  97. package/components/editor/CaretContext.d.ts +50 -0
  98. package/components/editor/CaretContext.js +1 -0
  99. package/{src/lib/components/editor/CaretState.ts → components/editor/CaretState.d.ts} +7 -6
  100. package/components/editor/CaretState.js +1 -0
  101. package/{src/lib/components/editor/CaretUtilities.ts → components/editor/CaretUtilities.d.ts} +0 -1
  102. package/components/editor/CaretUtilities.js +1 -0
  103. package/{src/lib/components → components}/editor/CaretView.svelte +20 -25
  104. package/components/editor/CaretView.svelte.d.ts +25 -0
  105. package/components/editor/CitationsEditor.svelte +53 -0
  106. package/components/editor/CitationsEditor.svelte.d.ts +17 -0
  107. package/{src/lib/components/editor/Clipboard.ts → components/editor/Clipboard.d.ts} +1 -2
  108. package/components/editor/Clipboard.js +1 -0
  109. package/{src/lib/components/editor/Command.ts → components/editor/Command.d.ts} +2 -8
  110. package/components/editor/Command.js +1 -0
  111. package/components/editor/Commands.d.ts +3 -0
  112. package/{src/lib/components/editor/Commands.ts → components/editor/Commands.js} +315 -730
  113. package/components/editor/ConfirmButton.svelte +49 -0
  114. package/components/editor/ConfirmButton.svelte.d.ts +19 -0
  115. package/components/editor/DefinitionEditor.svelte +36 -0
  116. package/components/editor/DefinitionEditor.svelte.d.ts +17 -0
  117. package/components/editor/EmbedEditor.svelte +137 -0
  118. package/components/editor/EmbedEditor.svelte.d.ts +17 -0
  119. package/{src/lib/components → components}/editor/Icon.svelte +1 -2
  120. package/components/editor/Icon.svelte.d.ts +16 -0
  121. package/{src/lib/components → components}/editor/ImageChooser.svelte +19 -24
  122. package/components/editor/ImageChooser.svelte.d.ts +18 -0
  123. package/components/editor/InlineCodeEditor.svelte +12 -0
  124. package/components/editor/InlineCodeEditor.svelte.d.ts +17 -0
  125. package/{src/lib/components → components}/editor/LabelEditor.svelte +9 -14
  126. package/components/editor/LabelEditor.svelte.d.ts +17 -0
  127. package/{src/lib/components → components}/editor/LanguageEditor.svelte +5 -8
  128. package/components/editor/LanguageEditor.svelte.d.ts +17 -0
  129. package/components/editor/LinkEditor.svelte +100 -0
  130. package/components/editor/LinkEditor.svelte.d.ts +17 -0
  131. package/{src/lib/components → components}/editor/Note.svelte +0 -0
  132. package/components/editor/Note.svelte.d.ts +27 -0
  133. package/{src/lib/components → components}/editor/Permissions.svelte +36 -43
  134. package/components/editor/Permissions.svelte.d.ts +20 -0
  135. package/components/editor/PositionEditor.svelte +17 -0
  136. package/components/editor/PositionEditor.svelte.d.ts +18 -0
  137. package/components/editor/QuoteEditor.svelte +10 -0
  138. package/components/editor/QuoteEditor.svelte.d.ts +17 -0
  139. package/{src/lib/components → components}/editor/Switch.svelte +11 -14
  140. package/components/editor/Switch.svelte.d.ts +20 -0
  141. package/components/editor/TableEditor.svelte +10 -0
  142. package/components/editor/TableEditor.svelte.d.ts +17 -0
  143. package/{src/lib/components → components}/editor/TextEditor.svelte +89 -101
  144. package/components/editor/TextEditor.svelte.d.ts +24 -0
  145. package/components/editor/Toggle.svelte +41 -0
  146. package/components/editor/Toggle.svelte.d.ts +19 -0
  147. package/components/editor/Toolbar.svelte +249 -0
  148. package/components/editor/Toolbar.svelte.d.ts +17 -0
  149. package/{src/lib/components → components}/editor/ToolbarGroup.svelte +3 -5
  150. package/components/editor/ToolbarGroup.svelte.d.ts +18 -0
  151. package/{src/lib/components → components}/editor/ToolbarSpacer.svelte +0 -0
  152. package/components/editor/ToolbarSpacer.svelte.d.ts +23 -0
  153. package/components/editor/URLEditor.svelte +13 -0
  154. package/components/editor/URLEditor.svelte.d.ts +18 -0
  155. package/{src/lib/components/editor/UndoState.ts → components/editor/UndoState.d.ts} +2 -3
  156. package/components/editor/UndoState.js +1 -0
  157. package/{src/lib/components → components}/editor/icons/annotate.svg +0 -0
  158. package/{src/lib/components → components}/editor/icons/block.svg +0 -0
  159. package/{src/lib/components → components}/editor/icons/bold.svg +0 -0
  160. package/{src/lib/components → components}/editor/icons/bullets.svg +0 -0
  161. package/{src/lib/components → components}/editor/icons/callout.svg +0 -0
  162. package/{src/lib/components → components}/editor/icons/citation.svg +0 -0
  163. package/{src/lib/components → components}/editor/icons/clear.svg +0 -0
  164. package/{src/lib/components → components}/editor/icons/clipboard.svg +0 -0
  165. package/{src/lib/components → components}/editor/icons/code.svg +0 -0
  166. package/{src/lib/components → components}/editor/icons/columnafter.svg +0 -0
  167. package/{src/lib/components → components}/editor/icons/columnbefore.svg +0 -0
  168. package/{src/lib/components → components}/editor/icons/comment.svg +0 -0
  169. package/{src/lib/components → components}/editor/icons/copy.svg +0 -0
  170. package/{src/lib/components → components}/editor/icons/cut.svg +0 -0
  171. package/{src/lib/components → components}/editor/icons/define.svg +0 -0
  172. package/{src/lib/components → components}/editor/icons/deletecolumn.svg +0 -0
  173. package/{src/lib/components → components}/editor/icons/deleterow.svg +0 -0
  174. package/{src/lib/components → components}/editor/icons/footnote.svg +0 -0
  175. package/{src/lib/components → components}/editor/icons/header1.svg +0 -0
  176. package/{src/lib/components → components}/editor/icons/header2.svg +0 -0
  177. package/{src/lib/components → components}/editor/icons/header3.svg +0 -0
  178. package/{src/lib/components → components}/editor/icons/home.svg +0 -0
  179. package/{src/lib/components → components}/editor/icons/indent.svg +0 -0
  180. package/{src/lib/components → components}/editor/icons/italic.svg +0 -0
  181. package/{src/lib/components → components}/editor/icons/label.svg +0 -0
  182. package/{src/lib/components → components}/editor/icons/left.svg +0 -0
  183. package/{src/lib/components → components}/editor/icons/level.svg +0 -0
  184. package/{src/lib/components → components}/editor/icons/link.svg +0 -0
  185. package/{src/lib/components → components}/editor/icons/list.svg +0 -0
  186. package/{src/lib/components → components}/editor/icons/media.svg +0 -0
  187. package/{src/lib/components → components}/editor/icons/middle.svg +0 -0
  188. package/{src/lib/components → components}/editor/icons/numbers.svg +0 -0
  189. package/{src/lib/components → components}/editor/icons/paragraph.svg +0 -0
  190. package/{src/lib/components → components}/editor/icons/paste.svg +0 -0
  191. package/{src/lib/components → components}/editor/icons/quote.svg +0 -0
  192. package/{src/lib/components → components}/editor/icons/redo.svg +0 -0
  193. package/{src/lib/components → components}/editor/icons/right.svg +0 -0
  194. package/{src/lib/components → components}/editor/icons/rowabove.svg +0 -0
  195. package/{src/lib/components → components}/editor/icons/rowbelow.svg +0 -0
  196. package/{src/lib/components → components}/editor/icons/rule.svg +0 -0
  197. package/{src/lib/components → components}/editor/icons/sub.svg +0 -0
  198. package/{src/lib/components → components}/editor/icons/super.svg +0 -0
  199. package/{src/lib/components → components}/editor/icons/table.svg +0 -0
  200. package/{src/lib/components → components}/editor/icons/text.svg +0 -0
  201. package/{src/lib/components → components}/editor/icons/time.svg +0 -0
  202. package/{src/lib/components → components}/editor/icons/undo.svg +0 -0
  203. package/{src/lib/components → components}/editor/icons/unindent.svg +0 -0
  204. package/{src/lib/components → components}/editor/icons/unlink.svg +0 -0
  205. package/{src/lib/components → components}/page/Acknowledgements.svelte +10 -19
  206. package/components/page/Acknowledgements.svelte.d.ts +14 -0
  207. package/components/page/Authors.svelte +85 -0
  208. package/components/page/Authors.svelte.d.ts +21 -0
  209. package/components/page/BookLoader.svelte +59 -0
  210. package/components/page/BookLoader.svelte.d.ts +16 -0
  211. package/components/page/BulkReferenceEditor.svelte +63 -0
  212. package/components/page/BulkReferenceEditor.svelte.d.ts +14 -0
  213. package/components/page/Chapter.svelte +393 -0
  214. package/components/page/Chapter.svelte.d.ts +18 -0
  215. package/components/page/ChapterContext.d.ts +10 -0
  216. package/components/page/ChapterContext.js +1 -0
  217. package/{src/lib/components → components}/page/ChapterNumber.svelte +0 -0
  218. package/components/page/ChapterNumber.svelte.d.ts +27 -0
  219. package/{src/lib/components → components}/page/ChapterTitle.svelte +2 -4
  220. package/components/page/ChapterTitle.svelte.d.ts +18 -0
  221. package/components/page/Contexts.d.ts +47 -0
  222. package/components/page/Contexts.js +133 -0
  223. package/{src/lib/components → components}/page/DefinitionView.svelte +38 -53
  224. package/components/page/DefinitionView.svelte.d.ts +18 -0
  225. package/{src/lib/components → components}/page/Description.svelte +7 -15
  226. package/components/page/Description.svelte.d.ts +14 -0
  227. package/components/page/Edition.svelte +161 -0
  228. package/components/page/Edition.svelte.d.ts +20 -0
  229. package/components/page/EditionLoader.svelte +99 -0
  230. package/components/page/EditionLoader.svelte.d.ts +18 -0
  231. package/{src/lib/components → components}/page/Editions.svelte +18 -22
  232. package/components/page/Editions.svelte.d.ts +14 -0
  233. package/{src/lib/components → components}/page/Glossary.svelte +28 -33
  234. package/components/page/Glossary.svelte.d.ts +14 -0
  235. package/{src/lib/components → components}/page/Header.svelte +52 -59
  236. package/components/page/Header.svelte.d.ts +29 -0
  237. package/{src/lib/components → components}/page/Index.svelte +47 -50
  238. package/components/page/Index.svelte.d.ts +14 -0
  239. package/{src/lib/components → components}/page/Instructions.svelte +1 -2
  240. package/components/page/Instructions.svelte.d.ts +18 -0
  241. package/{src/lib/components → components}/page/License.svelte +9 -17
  242. package/components/page/License.svelte.d.ts +14 -0
  243. package/{src/lib/components → components}/page/Loading.svelte +0 -0
  244. package/components/page/Loading.svelte.d.ts +23 -0
  245. package/{src/lib/components → components}/page/Media.svelte +27 -44
  246. package/components/page/Media.svelte.d.ts +14 -0
  247. package/{src/lib/components → components}/page/MediaPreview.svelte +2 -3
  248. package/components/page/MediaPreview.svelte.d.ts +19 -0
  249. package/{src/lib/components → components}/page/Muted.svelte +0 -0
  250. package/components/page/Muted.svelte.d.ts +27 -0
  251. package/{src/lib/components → components}/page/Outline.svelte +110 -140
  252. package/components/page/Outline.svelte.d.ts +19 -0
  253. package/components/page/Page.svelte +84 -0
  254. package/components/page/Page.svelte.d.ts +19 -0
  255. package/{src/lib/components → components}/page/PageHeader.svelte +1 -2
  256. package/components/page/PageHeader.svelte.d.ts +18 -0
  257. package/{src/lib/components → components}/page/PageParagraph.svelte +0 -0
  258. package/components/page/PageParagraph.svelte.d.ts +27 -0
  259. package/components/page/PossibleChapter.svelte +14 -0
  260. package/components/page/PossibleChapter.svelte.d.ts +14 -0
  261. package/components/page/PossibleReference.svelte +11 -0
  262. package/components/page/PossibleReference.svelte.d.ts +18 -0
  263. package/{src/lib/components → components}/page/Print.svelte +3 -5
  264. package/components/page/Print.svelte.d.ts +14 -0
  265. package/{src/lib/components → components}/page/Publish.svelte +52 -59
  266. package/components/page/Publish.svelte.d.ts +14 -0
  267. package/{src/lib/components → components}/page/Reference.svelte +30 -39
  268. package/components/page/Reference.svelte.d.ts +17 -0
  269. package/{src/lib/components → components}/page/References.svelte +14 -18
  270. package/components/page/References.svelte.d.ts +14 -0
  271. package/{src/lib/components → components}/page/Rows.svelte +0 -0
  272. package/components/page/Rows.svelte.d.ts +27 -0
  273. package/components/page/Search.svelte +133 -0
  274. package/components/page/Search.svelte.d.ts +14 -0
  275. package/{src/lib/components → components}/page/Status.svelte +3 -5
  276. package/components/page/Status.svelte.d.ts +14 -0
  277. package/{src/lib/components → components}/page/SubdomainEditor.svelte +13 -16
  278. package/components/page/SubdomainEditor.svelte.d.ts +14 -0
  279. package/{src/lib/components → components}/page/TableOfContents.svelte +68 -79
  280. package/components/page/TableOfContents.svelte.d.ts +14 -0
  281. package/components/page/TableOfContentsImage.svelte +18 -0
  282. package/components/page/TableOfContentsImage.svelte.d.ts +16 -0
  283. package/{src/lib/components → components}/page/TableOfContentsRow.svelte +24 -34
  284. package/components/page/TableOfContentsRow.svelte.d.ts +24 -0
  285. package/{src/lib/components → components}/page/ThemeEditor.svelte +33 -44
  286. package/components/page/ThemeEditor.svelte.d.ts +14 -0
  287. package/{src/lib/components → components}/page/ThemeEditorPreview.svelte +12 -21
  288. package/components/page/ThemeEditorPreview.svelte.d.ts +17 -0
  289. package/components/page/ThemeSetEditor.svelte +19 -0
  290. package/components/page/ThemeSetEditor.svelte.d.ts +18 -0
  291. package/{src/lib/components → components}/page/ThemeVariableEditor.svelte +14 -18
  292. package/components/page/ThemeVariableEditor.svelte.d.ts +18 -0
  293. package/{src/lib/components → components}/page/Title.svelte +0 -0
  294. package/components/page/Title.svelte.d.ts +27 -0
  295. package/{src/lib/components → components}/page/Unknown.svelte +8 -10
  296. package/components/page/Unknown.svelte.d.ts +16 -0
  297. package/components/page/margins.d.ts +2 -0
  298. package/{src/lib/components/page/margins.ts → components/page/margins.js} +46 -79
  299. package/index.d.ts +15 -0
  300. package/{src/lib/index.js → index.js} +0 -0
  301. package/models/CRUD.d.ts +27 -0
  302. package/models/CRUD.js +262 -0
  303. package/models/Firebase.d.ts +5 -0
  304. package/{src/lib/models/Firebase.ts → models/Firebase.js} +16 -26
  305. package/models/book/Book.d.ts +61 -0
  306. package/models/book/Book.js +135 -0
  307. package/models/book/BookMedia.d.ts +23 -0
  308. package/models/book/BookMedia.js +108 -0
  309. package/models/book/BookSaveStatus.d.ts +7 -0
  310. package/models/book/BookSaveStatus.js +8 -0
  311. package/models/book/Chapter.d.ts +81 -0
  312. package/models/book/Chapter.js +212 -0
  313. package/models/book/ChapterID.d.ts +10 -0
  314. package/{src/lib/models/book/ChapterID.ts → models/book/ChapterID.js} +0 -1
  315. package/models/book/Definition.d.ts +6 -0
  316. package/models/book/Definition.js +1 -0
  317. package/models/book/Edition.d.ts +139 -0
  318. package/models/book/Edition.js +620 -0
  319. package/models/book/Reference.d.ts +24 -0
  320. package/models/book/Reference.js +78 -0
  321. package/models/book/Schema.d.ts +174 -0
  322. package/{src/lib/models/book/Schema.ts → models/book/Schema.js} +0 -1
  323. package/models/book/Theme.d.ts +113 -0
  324. package/{src/lib/models/book/Theme.ts → models/book/Theme.js} +6 -110
  325. package/{src/lib/models/book/ThemeColors.ts → models/book/ThemeColors.d.ts} +0 -6
  326. package/models/book/ThemeColors.js +1 -0
  327. package/models/book/Words.d.ts +2 -0
  328. package/{src/lib/models/book/Words.ts → models/book/Words.js} +0 -1
  329. package/models/chapter/AtomNode.d.ts +18 -0
  330. package/{src/lib/models/chapter/AtomNode.ts → models/chapter/AtomNode.js} +10 -30
  331. package/models/chapter/BlockNode.d.ts +20 -0
  332. package/{src/lib/models/chapter/BlockNode.ts → models/chapter/BlockNode.js} +47 -80
  333. package/models/chapter/BlocksNode.d.ts +50 -0
  334. package/{src/lib/models/chapter/BlocksNode.ts → models/chapter/BlocksNode.js} +359 -571
  335. package/models/chapter/BlocksNode.test.d.ts +1 -0
  336. package/models/chapter/BlocksNode.test.js +568 -0
  337. package/{src/lib/models/chapter/Bookkeeping.ts → models/chapter/Bookkeeping.d.ts} +0 -0
  338. package/models/chapter/Bookkeeping.js +1 -0
  339. package/models/chapter/CalloutNode.d.ts +17 -0
  340. package/models/chapter/CalloutNode.js +58 -0
  341. package/models/chapter/Caret.d.ts +23 -0
  342. package/{src/lib/models/chapter/Caret.ts → models/chapter/Caret.js} +26 -50
  343. package/models/chapter/ChapterNode.d.ts +34 -0
  344. package/models/chapter/ChapterNode.js +117 -0
  345. package/models/chapter/CitationsNode.d.ts +16 -0
  346. package/{src/lib/models/chapter/CitationsNode.ts → models/chapter/CitationsNode.js} +10 -17
  347. package/models/chapter/CodeNode.d.ts +35 -0
  348. package/{src/lib/models/chapter/CodeNode.ts → models/chapter/CodeNode.js} +62 -125
  349. package/models/chapter/CommentNode.d.ts +18 -0
  350. package/models/chapter/CommentNode.js +48 -0
  351. package/models/chapter/DefinitionNode.d.ts +12 -0
  352. package/{src/lib/models/chapter/DefinitionNode.ts → models/chapter/DefinitionNode.js} +8 -14
  353. package/models/chapter/Edit.d.ts +7 -0
  354. package/models/chapter/Edit.js +1 -0
  355. package/models/chapter/EmbedNode.d.ts +45 -0
  356. package/models/chapter/EmbedNode.js +168 -0
  357. package/models/chapter/ErrorNode.d.ts +17 -0
  358. package/{src/lib/models/chapter/ErrorNode.ts → models/chapter/ErrorNode.js} +8 -15
  359. package/models/chapter/FootnoteNode.d.ts +18 -0
  360. package/models/chapter/FootnoteNode.js +47 -0
  361. package/models/chapter/FormatNode.d.ts +60 -0
  362. package/{src/lib/models/chapter/FormatNode.ts → models/chapter/FormatNode.js} +262 -443
  363. package/models/chapter/FormatNode.test.d.ts +1 -0
  364. package/models/chapter/FormatNode.test.js +96 -0
  365. package/models/chapter/InlineCodeNode.d.ts +12 -0
  366. package/{src/lib/models/chapter/InlineCodeNode.ts → models/chapter/InlineCodeNode.js} +9 -17
  367. package/models/chapter/LabelNode.d.ts +17 -0
  368. package/{src/lib/models/chapter/LabelNode.ts → models/chapter/LabelNode.js} +10 -26
  369. package/models/chapter/LinkNode.d.ts +12 -0
  370. package/{src/lib/models/chapter/LinkNode.ts → models/chapter/LinkNode.js} +7 -12
  371. package/models/chapter/ListNode.d.ts +51 -0
  372. package/{src/lib/models/chapter/ListNode.ts → models/chapter/ListNode.js} +200 -277
  373. package/models/chapter/ListNode.test.d.ts +1 -0
  374. package/{src/lib/models/chapter/ListNode.test.ts → models/chapter/ListNode.test.js} +20 -57
  375. package/models/chapter/MetadataNode.d.ts +17 -0
  376. package/models/chapter/MetadataNode.js +32 -0
  377. package/models/chapter/Node.d.ts +38 -0
  378. package/{src/lib/models/chapter/Node.ts → models/chapter/Node.js} +71 -155
  379. package/models/chapter/Node.test.d.ts +1 -0
  380. package/{src/lib/models → models}/chapter/Node.test.js +0 -0
  381. package/models/chapter/ParagraphNode.d.ts +33 -0
  382. package/{src/lib/models/chapter/ParagraphNode.ts → models/chapter/ParagraphNode.js} +58 -95
  383. package/models/chapter/ParagraphNode.test.d.ts +1 -0
  384. package/models/chapter/ParagraphNode.test.js +30 -0
  385. package/models/chapter/Parser.d.ts +75 -0
  386. package/{src/lib/models/chapter/Parser.ts → models/chapter/Parser.js} +184 -369
  387. package/models/chapter/Parser.test.d.ts +1 -0
  388. package/{src/lib/models/chapter/Parser.test.ts → models/chapter/Parser.test.js} +0 -7
  389. package/{src/lib/models/chapter/Position.ts → models/chapter/Position.d.ts} +0 -0
  390. package/models/chapter/Position.js +1 -0
  391. package/models/chapter/QuoteNode.d.ts +25 -0
  392. package/models/chapter/QuoteNode.js +99 -0
  393. package/{src/lib/models/chapter/RootNode.ts → models/chapter/RootNode.d.ts} +0 -2
  394. package/models/chapter/RootNode.js +1 -0
  395. package/models/chapter/RuleNode.d.ts +15 -0
  396. package/{src/lib/models/chapter/RuleNode.ts → models/chapter/RuleNode.js} +6 -9
  397. package/models/chapter/TableNode.d.ts +37 -0
  398. package/{src/lib/models/chapter/TableNode.ts → models/chapter/TableNode.js} +82 -141
  399. package/models/chapter/TableNode.test.d.ts +1 -0
  400. package/{src/lib/models/chapter/TableNode.test.ts → models/chapter/TableNode.test.js} +10 -27
  401. package/models/chapter/TextNode.d.ts +36 -0
  402. package/{src/lib/models/chapter/TextNode.ts → models/chapter/TextNode.js} +65 -117
  403. package/models/chapter/TextNode.test.d.ts +1 -0
  404. package/{src/lib/models/chapter/TextNode.test.ts → models/chapter/TextNode.test.js} +0 -2
  405. package/package.json +270 -53
  406. package/util/getSubdomain.d.ts +3 -0
  407. package/{src/lib/util/getSubdomain.ts → util/getSubdomain.js} +8 -14
  408. package/util/isMobile.d.ts +2 -0
  409. package/{src/lib/util/isMobile.ts → util/isMobile.js} +0 -1
  410. package/util/mineReference.d.ts +4 -0
  411. package/{src/lib/util/mineReference.ts → util/mineReference.js} +25 -45
  412. package/util/scrollToEyeLevel.d.ts +2 -0
  413. package/{src/lib/util/scrollToEyeLevel.ts → util/scrollToEyeLevel.js} +2 -4
  414. package/.env.example +0 -8
  415. package/.firebaserc +0 -8
  416. package/.prettierignore +0 -8
  417. package/.prettierrc.json +0 -5
  418. package/_update-notifier-last-checked +0 -0
  419. package/firebase.json +0 -46
  420. package/firestore.indexes.json +0 -4
  421. package/firestore.rules +0 -59
  422. package/functions/.eslintrc.js +0 -28
  423. package/functions/package-lock.json +0 -12595
  424. package/functions/package.json +0 -43
  425. package/functions/src/index.ts +0 -345
  426. package/functions/tsconfig.dev.json +0 -3
  427. package/functions/tsconfig.json +0 -15
  428. package/scripts/claims.cjs +0 -99
  429. package/src/app.d.ts +0 -9
  430. package/src/app.html +0 -24
  431. package/src/lib/components/Auth.svelte +0 -65
  432. package/src/lib/components/Link.svelte +0 -58
  433. package/src/lib/components/chapter/Block.svelte +0 -42
  434. package/src/lib/components/chapter/ErrorMessage.svelte +0 -12
  435. package/src/lib/components/chapter/Python.svelte +0 -144
  436. package/src/lib/components/chapter/Text.svelte +0 -109
  437. package/src/lib/components/editor/BookishEditor.svelte +0 -1101
  438. package/src/lib/components/editor/CalloutEditor.svelte +0 -14
  439. package/src/lib/components/editor/CaretContext.ts +0 -55
  440. package/src/lib/components/editor/CitationsEditor.svelte +0 -64
  441. package/src/lib/components/editor/ConfirmButton.svelte +0 -51
  442. package/src/lib/components/editor/DefinitionEditor.svelte +0 -44
  443. package/src/lib/components/editor/EmbedEditor.svelte +0 -152
  444. package/src/lib/components/editor/InlineCodeEditor.svelte +0 -16
  445. package/src/lib/components/editor/LinkEditor.svelte +0 -110
  446. package/src/lib/components/editor/PositionEditor.svelte +0 -21
  447. package/src/lib/components/editor/QuoteEditor.svelte +0 -14
  448. package/src/lib/components/editor/TableEditor.svelte +0 -14
  449. package/src/lib/components/editor/Toggle.svelte +0 -47
  450. package/src/lib/components/editor/Toolbar.svelte +0 -297
  451. package/src/lib/components/editor/URLEditor.svelte +0 -15
  452. package/src/lib/components/page/Authors.svelte +0 -92
  453. package/src/lib/components/page/BookLoader.svelte +0 -77
  454. package/src/lib/components/page/BulkReferenceEditor.svelte +0 -86
  455. package/src/lib/components/page/Chapter.svelte +0 -449
  456. package/src/lib/components/page/ChapterContext.ts +0 -13
  457. package/src/lib/components/page/Contexts.ts +0 -176
  458. package/src/lib/components/page/Edition.svelte +0 -189
  459. package/src/lib/components/page/EditionLoader.svelte +0 -123
  460. package/src/lib/components/page/Page.svelte +0 -94
  461. package/src/lib/components/page/PossibleChapter.svelte +0 -16
  462. package/src/lib/components/page/PossibleReference.svelte +0 -14
  463. package/src/lib/components/page/Search.svelte +0 -153
  464. package/src/lib/components/page/TableOfContentsImage.svelte +0 -22
  465. package/src/lib/components/page/ThemeSetEditor.svelte +0 -21
  466. package/src/lib/models/CRUD.ts +0 -469
  467. package/src/lib/models/book/Book.ts +0 -283
  468. package/src/lib/models/book/BookMedia.ts +0 -182
  469. package/src/lib/models/book/BookSaveStatus.ts +0 -8
  470. package/src/lib/models/book/Chapter.ts +0 -462
  471. package/src/lib/models/book/Definition.ts +0 -2
  472. package/src/lib/models/book/Edition.ts +0 -1216
  473. package/src/lib/models/book/Reference.ts +0 -171
  474. package/src/lib/models/chapter/BlocksNode.test.ts +0 -867
  475. package/src/lib/models/chapter/CalloutNode.ts +0 -79
  476. package/src/lib/models/chapter/ChapterNode.ts +0 -169
  477. package/src/lib/models/chapter/CommentNode.ts +0 -61
  478. package/src/lib/models/chapter/Edit.ts +0 -6
  479. package/src/lib/models/chapter/EmbedNode.ts +0 -257
  480. package/src/lib/models/chapter/FootnoteNode.ts +0 -59
  481. package/src/lib/models/chapter/FormatNode.test.ts +0 -137
  482. package/src/lib/models/chapter/MetadataNode.ts +0 -44
  483. package/src/lib/models/chapter/ParagraphNode.test.ts +0 -54
  484. package/src/lib/models/chapter/QuoteNode.ts +0 -135
  485. package/src/params/edition.ts +0 -3
  486. package/src/routes/+error.svelte +0 -12
  487. package/src/routes/+layout.svelte +0 -241
  488. package/src/routes/+page.svelte +0 -43
  489. package/src/routes/Footer.svelte +0 -0
  490. package/src/routes/Header.svelte +0 -112
  491. package/src/routes/[bookid]/+layout.svelte +0 -5
  492. package/src/routes/[bookid]/[[editionid=edition]]/+error.svelte +0 -14
  493. package/src/routes/[bookid]/[[editionid=edition]]/+layout.svelte +0 -7
  494. package/src/routes/[bookid]/[[editionid=edition]]/+page.svelte +0 -5
  495. package/src/routes/[bookid]/[[editionid=edition]]/[chapterid]/+page.svelte +0 -5
  496. package/src/routes/[bookid]/[[editionid=edition]]/glossary/+page.svelte +0 -5
  497. package/src/routes/[bookid]/[[editionid=edition]]/index/[[letter]]/+page.svelte +0 -5
  498. package/src/routes/[bookid]/[[editionid=edition]]/media/+page.svelte +0 -5
  499. package/src/routes/[bookid]/[[editionid=edition]]/print/+page.svelte +0 -5
  500. package/src/routes/[bookid]/[[editionid=edition]]/references/+page.svelte +0 -5
  501. package/src/routes/[bookid]/[[editionid=edition]]/search/+page.svelte +0 -5
  502. package/src/routes/[bookid]/editions/+page.svelte +0 -20
  503. package/src/routes/about/+page.svelte +0 -102
  504. package/src/routes/confirm/+page.svelte +0 -62
  505. package/src/routes/email/+page.svelte +0 -99
  506. package/src/routes/login/+page.svelte +0 -66
  507. package/src/routes/read/+page.svelte +0 -38
  508. package/src/routes/write/+error.svelte +0 -10
  509. package/src/routes/write/+layout.svelte +0 -11
  510. package/src/routes/write/+page.svelte +0 -114
  511. package/src/routes/write/[bookid]/+layout.svelte +0 -5
  512. package/src/routes/write/[bookid]/[[editionid=edition]]/+layout.svelte +0 -7
  513. package/src/routes/write/[bookid]/[[editionid=edition]]/+page.svelte +0 -5
  514. package/src/routes/write/[bookid]/[[editionid=edition]]/[chapterid]/+page.svelte +0 -5
  515. package/src/routes/write/[bookid]/[[editionid=edition]]/glossary/+page.svelte +0 -5
  516. package/src/routes/write/[bookid]/[[editionid=edition]]/index/[[letter]]/+page.svelte +0 -5
  517. package/src/routes/write/[bookid]/[[editionid=edition]]/media/+page.svelte +0 -5
  518. package/src/routes/write/[bookid]/[[editionid=edition]]/print/+page.svelte +0 -5
  519. package/src/routes/write/[bookid]/[[editionid=edition]]/references/+page.svelte +0 -5
  520. package/src/routes/write/[bookid]/[[editionid=edition]]/search/+page.svelte +0 -5
  521. package/src/routes/write/[bookid]/[[editionid=edition]]/theme/+page.svelte +0 -5
  522. package/src/routes/write/[bookid]/[[editionid=edition]]/unknown/+page.svelte +0 -5
  523. package/src/routes/write/[bookid]/editions/+page.svelte +0 -20
  524. package/src/vite-env.d.ts +0 -1
  525. package/static/icons/favicon.png +0 -0
  526. package/static/icons/icon.png +0 -0
  527. package/static/icons/ios-icon.png +0 -0
  528. package/storage.rules +0 -9
  529. package/svelte.config.js +0 -19
  530. package/tsconfig.json +0 -18
  531. package/tsconfig.node.json +0 -9
  532. package/vite.config.ts +0 -8
  533. package/vite.reader.config.ts +0 -32
@@ -0,0 +1,135 @@
1
+ import BookMedia from './BookMedia';
2
+ export default class Book {
3
+ ref;
4
+ title;
5
+ authors;
6
+ description;
7
+ cover;
8
+ published;
9
+ editions;
10
+ domain;
11
+ uids;
12
+ media;
13
+ constructor(ref, title, authors, description, cover, editions, domain, uids) {
14
+ this.ref = ref;
15
+ this.title = title;
16
+ this.authors = authors;
17
+ this.description = description;
18
+ this.cover = cover;
19
+ // The published state is always true if some edition's published flag isn't null.
20
+ this.published = editions.some((edition) => edition.published !== null);
21
+ // We always keep editions in reversed edition number for easy reference.
22
+ this.editions = editions.sort((a, b) => a.number - b.number);
23
+ this.domain = domain;
24
+ this.uids = uids;
25
+ this.media = new BookMedia(this);
26
+ }
27
+ getMedia() {
28
+ return this.media;
29
+ }
30
+ static fromJSON(ref, book) {
31
+ return new Book(ref, book.title, book.authors, book.description, book.cover, book.editions, book.domain, book.uids);
32
+ }
33
+ toJSON() {
34
+ const json = {
35
+ title: this.title,
36
+ authors: this.authors,
37
+ description: this.description,
38
+ cover: this.cover,
39
+ published: this.published,
40
+ domain: this.domain,
41
+ editions: this.editions,
42
+ uids: this.uids,
43
+ readuids: Array.from(new Set(this.editions
44
+ .map((edition) => [
45
+ ...edition.editionuids,
46
+ ...edition.chapteruids,
47
+ ])
48
+ .flat())),
49
+ };
50
+ return json;
51
+ }
52
+ getSubdomain() {
53
+ return this.domain;
54
+ }
55
+ withSubdomain(domain) {
56
+ return new Book(this.ref, this.title, this.authors, this.description, this.cover, this.editions, domain.length === 0 ? null : domain, this.uids);
57
+ }
58
+ getTitle() {
59
+ return this.title;
60
+ }
61
+ withTitle(title) {
62
+ return new Book(this.ref, title, this.authors, this.description, this.cover, this.editions, this.domain, this.uids);
63
+ }
64
+ getDescription() {
65
+ return this.description;
66
+ }
67
+ withDescription(description) {
68
+ return new Book(this.ref, this.title, this.authors, description, this.cover, this.editions, this.domain, this.uids);
69
+ }
70
+ getCover() {
71
+ return this.cover;
72
+ }
73
+ withCover(cover) {
74
+ return new Book(this.ref, this.title, this.authors, this.description, cover, this.editions, this.domain, this.uids);
75
+ }
76
+ getAuthors() {
77
+ return this.authors;
78
+ }
79
+ withAuthors(authors) {
80
+ return new Book(this.ref, this.title, authors, this.description, this.cover, this.editions, this.domain, this.uids);
81
+ }
82
+ getRef() {
83
+ return this.ref;
84
+ }
85
+ getRefID() {
86
+ return this.ref.id;
87
+ }
88
+ getEditionNumberID(number) {
89
+ // Get the ID corresponding to this number.
90
+ const edition = this.editions.find((ed) => ed.number === number);
91
+ return edition ? edition.ref.id : undefined;
92
+ }
93
+ getLatestPublishedEditionID() {
94
+ return this.editions.filter((ed) => ed.published !== null)[0]?.ref.id;
95
+ }
96
+ getLatestEditionID() {
97
+ return this.editions[0]?.ref.id;
98
+ }
99
+ getEditions() {
100
+ return this.editions.slice();
101
+ }
102
+ getPublishedEditionCount() {
103
+ return this.editions.filter((edition) => edition.published).length;
104
+ }
105
+ isEditor(uid) {
106
+ return this.uids.includes(uid);
107
+ }
108
+ withEditors(uids) {
109
+ return new Book(this.ref, this.title, this.authors, this.description, this.cover, this.editions, this.domain, uids);
110
+ }
111
+ withEditions(revisions) {
112
+ return new Book(this.ref, this.title, this.authors, this.description, this.cover, revisions, this.domain, this.uids);
113
+ }
114
+ withRevisedEdition(previous, revised) {
115
+ // Get the new info.
116
+ const info = revised.getInfo();
117
+ if (info === undefined)
118
+ return this;
119
+ // If no previous addition, just add it.
120
+ if (previous === undefined)
121
+ return this.withEditions([...this.editions, info]);
122
+ // Find the corresponding edition.
123
+ const index = this.editions.findIndex((edition) => edition.number === previous.number);
124
+ return index < 0
125
+ ? this
126
+ : this.withEditions([
127
+ ...this.editions.slice(0, index),
128
+ info,
129
+ ...this.editions.slice(index + 1),
130
+ ]);
131
+ }
132
+ hasPublishedEdition() {
133
+ return this.editions.some((revision) => revision.published !== null);
134
+ }
135
+ }
@@ -0,0 +1,23 @@
1
+ import type { StorageReference } from 'firebase/storage';
2
+ import type Book from './Book';
3
+ export type Image = {
4
+ url: string;
5
+ ref: StorageReference;
6
+ };
7
+ export default class BookMedia {
8
+ readonly book: Book;
9
+ _images: Image[] | undefined;
10
+ readonly observers: Set<(images: Image[]) => void>;
11
+ constructor(book: Book);
12
+ notify(observer: (images: Image[]) => void): void;
13
+ stopNotifying(observer: (images: Image[]) => void): void;
14
+ /** Get all non-thumbnail images. */
15
+ getImages(): Promise<Image[]>;
16
+ getImagePath(): string;
17
+ /** Get a listing of all of the images for the book. */
18
+ cacheImages(): Promise<Image[]>;
19
+ retrieveImages(): Promise<(Image | undefined)[]>;
20
+ getThumbnailURL(url: string, thumbnailRef: StorageReference, error: (message: string) => void, finished: (url: string, thumbnailURL: string) => void, attempt?: number): void;
21
+ upload(file: File, progressHandler: (progress: number) => void, errorHandler: (message: string) => void, finishedHandler: (url: string, thumbnailURL: string) => void): void;
22
+ remove(image: Image): Promise<Image[] | undefined>;
23
+ }
@@ -0,0 +1,108 @@
1
+ import { deleteObject, getDownloadURL, listAll, ref, uploadBytes, } from 'firebase/storage';
2
+ import { v4 as uuidv4 } from 'uuid';
3
+ import { storage } from '../Firebase';
4
+ export default class BookMedia {
5
+ book;
6
+ _images;
7
+ // A list of functions to call when the book media changes.
8
+ observers = new Set();
9
+ constructor(book) {
10
+ this.book = book;
11
+ }
12
+ notify(observer) {
13
+ this.observers.add(observer);
14
+ // Notify it right away!
15
+ this.getImages().then((images) => observer(images));
16
+ }
17
+ stopNotifying(observer) {
18
+ this.observers.delete(observer);
19
+ }
20
+ /** Get all non-thumbnail images. */
21
+ async getImages() {
22
+ return this._images === undefined ? this.cacheImages() : this._images;
23
+ }
24
+ getImagePath() {
25
+ return `images/${this.book.getRefID()}/`;
26
+ }
27
+ /** Get a listing of all of the images for the book. */
28
+ async cacheImages() {
29
+ if (storage === undefined)
30
+ return [];
31
+ // Find all the prefixes and items.
32
+ this._images = (await this.retrieveImages()).filter((image) => image !== undefined);
33
+ // Notify observers
34
+ for (const observer of this.observers)
35
+ observer(this._images.slice());
36
+ return this._images;
37
+ }
38
+ async retrieveImages() {
39
+ if (storage === undefined)
40
+ return [];
41
+ // Create a reference under which you want to list
42
+ const listRef = ref(storage, this.getImagePath());
43
+ // Find all the prefixes and items.
44
+ return listAll(listRef).then((res) => Promise.all(res.items.map((itemRef) => getDownloadURL(itemRef).then((url) => {
45
+ const image = {
46
+ url: url,
47
+ description: '',
48
+ ref: itemRef,
49
+ };
50
+ if (this._images !== undefined) {
51
+ this._images.push(image);
52
+ }
53
+ return image;
54
+ }))));
55
+ }
56
+ getThumbnailURL(url, thumbnailRef, error, finished, attempt = 0) {
57
+ getDownloadURL(thumbnailRef)
58
+ .then((thumbnail) => finished(url, thumbnail))
59
+ // Try again in a bit.
60
+ .catch(() => attempt > 25
61
+ ? error("Couldn't get the image URL. Connection issues?")
62
+ : setTimeout(() => this.getThumbnailURL(url, thumbnailRef, error, finished, attempt + 1), 250));
63
+ }
64
+ upload(file, progressHandler, errorHandler, finishedHandler) {
65
+ progressHandler;
66
+ if (storage === undefined)
67
+ return;
68
+ // The canonical path format for Bookish images in the store is image/{bookid}/{imageid}
69
+ // where {bookid} is the Firestore ID of the book being edited and {imageid} is just a random id.
70
+ const imageName = `image-${uuidv4()}`;
71
+ const imageRef = ref(storage, `${this.getImagePath()}/${imageName}`);
72
+ const thumbnailRef = ref(storage, `${this.getImagePath()}/thumbnails/${imageName}`);
73
+ uploadBytes(imageRef, file)
74
+ .then((snapshot) => {
75
+ getDownloadURL(snapshot.ref)
76
+ .then((url) => {
77
+ // Give some time for the cloud function to create a thumbnail, then try to get it's URL.
78
+ setTimeout(() => this.getThumbnailURL(url, thumbnailRef, errorHandler, finishedHandler), 250);
79
+ })
80
+ .catch(() => errorHandler('Unable to get image URL.'));
81
+ })
82
+ .then(() => this.cacheImages());
83
+ // This seems to be broken in Firebase right now. Switched above to a no-feedback approach.
84
+ // const uploadTask = uploadBytesResumable(imageRef, file);
85
+ // uploadTask.on("state_changed",
86
+ // // During upload, notify of progress by sending an integer percent complete.
87
+ // (snapshot) => progressHandler(Math.round((snapshot.bytesTransferred / snapshot.totalBytes) * 100)),
88
+ // // If there's an error, map it to a message.
89
+ // // https://firebase.google.com/docs/storage/web/handle-errors
90
+ // (error) => {
91
+ // console.error(error);
92
+ // errorHandler(
93
+ // error.code === "storage/unauthorized" ? "Wrong permissions to upload" :
94
+ // error.code === "storage/canceled" ? "Upload canceled" :
95
+ // error.code === "storage/quota-exceeded" ? "Storage limit reached" :
96
+ // error.code === "storage/unauthenticated" ? "Log in again to upload" :
97
+ // "Unknown upload error"
98
+ // )
99
+ // },
100
+ }
101
+ async remove(image) {
102
+ if (storage === undefined)
103
+ return;
104
+ const imageRef = ref(storage, image.ref.fullPath);
105
+ await deleteObject(imageRef);
106
+ return await this.cacheImages();
107
+ }
108
+ }
@@ -0,0 +1,7 @@
1
+ declare enum BookSaveStatus {
2
+ Changed = 0,
3
+ Saving = 1,
4
+ Saved = 2,
5
+ Error = 3
6
+ }
7
+ export default BookSaveStatus;
@@ -0,0 +1,8 @@
1
+ var BookSaveStatus;
2
+ (function (BookSaveStatus) {
3
+ BookSaveStatus[BookSaveStatus["Changed"] = 0] = "Changed";
4
+ BookSaveStatus[BookSaveStatus["Saving"] = 1] = "Saving";
5
+ BookSaveStatus[BookSaveStatus["Saved"] = 2] = "Saved";
6
+ BookSaveStatus[BookSaveStatus["Error"] = 3] = "Error";
7
+ })(BookSaveStatus || (BookSaveStatus = {}));
8
+ export default BookSaveStatus;
@@ -0,0 +1,81 @@
1
+ import type ChapterNode from '../chapter/ChapterNode';
2
+ import type Edition from './Edition';
3
+ import type { DocumentReference } from 'firebase/firestore';
4
+ export type ChapterSpecification = {
5
+ ref?: DocumentReference;
6
+ id: string;
7
+ title: string;
8
+ authors: string[];
9
+ image: string | null;
10
+ numbered: boolean;
11
+ forthcoming: boolean;
12
+ section?: string;
13
+ text?: string;
14
+ uids: string[];
15
+ };
16
+ export type ChapterContent = {
17
+ text: string;
18
+ };
19
+ export type Match = {
20
+ left: string;
21
+ match: string;
22
+ right: string;
23
+ };
24
+ export default class Chapter {
25
+ readonly ref: DocumentReference | undefined;
26
+ readonly id: string;
27
+ readonly title: string;
28
+ readonly authors: string[];
29
+ readonly image: string | null;
30
+ readonly numbered: boolean;
31
+ readonly forthcoming: boolean;
32
+ readonly section: string | undefined;
33
+ readonly text: string;
34
+ readonly uids: string[];
35
+ _ast: ChapterNode | undefined;
36
+ _index: Record<string, Array<Match>> | undefined;
37
+ _wordCount: number | undefined;
38
+ edits: {
39
+ resolve: Function;
40
+ reject: Function;
41
+ }[];
42
+ lastEdit: number;
43
+ listeners: Set<(text: string) => void>;
44
+ constructor(ref: DocumentReference | undefined, id: string, title: string, authors: string[], image: string | null, numbered: boolean, forthcoming: boolean, section: string | undefined, text: string, uids: string[]);
45
+ /**
46
+ * Convert a chapter spec and it's text into a chapter object.
47
+ * The spec may contain the text itself, but it may not, so we require it to be
48
+ * repeated here to guarantee its provided.
49
+ */
50
+ static fromJSON(spec: ChapterSpecification, text: string): Chapter;
51
+ toJSON(): ChapterSpecification;
52
+ getRef(): DocumentReference<import("@firebase/firestore").DocumentData> | undefined;
53
+ withEditors(uids: string[]): Chapter;
54
+ withRef(ref: DocumentReference): Chapter;
55
+ withoutRef(): Chapter;
56
+ getID(): string;
57
+ withChapterID(id: string): Chapter;
58
+ getSection(): string | undefined;
59
+ withSection(section: string): Chapter;
60
+ isForthcoming(): boolean;
61
+ asForthcoming(forthcoming: boolean): Chapter;
62
+ isNumbered(): boolean;
63
+ asNumbered(numbered: boolean): Chapter;
64
+ isEditor(uid: string): boolean;
65
+ getText(): string;
66
+ withText(text: string): Chapter;
67
+ withAST(ast: ChapterNode): Chapter;
68
+ getAuthors(): string[];
69
+ withAuthor(name: string): Chapter;
70
+ withRenamedAuthor(index: number, name: string): Chapter;
71
+ withoutAuthor(index: number): Chapter;
72
+ getTitle(): string;
73
+ withTitle(title: string): Chapter;
74
+ getImage(): string | null;
75
+ withImage(image: string | null): Chapter;
76
+ getAST(edition: Edition): ChapterNode;
77
+ getWordCount(edition: Edition): number;
78
+ getReadingTime(edition: Edition): number | undefined;
79
+ getIndex(edition: Edition): Record<string, Match[]>;
80
+ toString(): string;
81
+ }
@@ -0,0 +1,212 @@
1
+ import Parser from '../chapter/Parser';
2
+ import CommonWords from './Words';
3
+ export default class Chapter {
4
+ // Inputs
5
+ ref;
6
+ id;
7
+ title;
8
+ authors;
9
+ image;
10
+ numbered;
11
+ forthcoming;
12
+ section;
13
+ text;
14
+ uids;
15
+ // Derived values
16
+ _ast = undefined;
17
+ _index = undefined;
18
+ _wordCount = undefined;
19
+ // A list of requested edits, stored as promises, resolved
20
+ // when the book is ready to save.
21
+ edits = [];
22
+ lastEdit = 0;
23
+ // A set of listeners that are notified when the chapter text changes.
24
+ listeners = new Set();
25
+ constructor(ref, id, title, authors, image, numbered, forthcoming, section, text, uids) {
26
+ this.ref = ref;
27
+ this.id = id;
28
+ this.title = title;
29
+ this.authors = authors.slice();
30
+ this.image = image;
31
+ this.numbered = numbered;
32
+ this.forthcoming = forthcoming;
33
+ this.section = section;
34
+ this.text = text;
35
+ this.uids = uids;
36
+ }
37
+ /**
38
+ * Convert a chapter spec and it's text into a chapter object.
39
+ * The spec may contain the text itself, but it may not, so we require it to be
40
+ * repeated here to guarantee its provided.
41
+ */
42
+ static fromJSON(spec, text) {
43
+ // Copy the spec, filling in defaults as necessary.
44
+ return new Chapter(spec.ref, spec.id, spec.title, spec.authors ?? [], spec.image ?? null, spec.numbered === true || spec.numbered === undefined, spec.forthcoming === true, spec.section, spec.text ?? text, spec.uids);
45
+ }
46
+ toJSON() {
47
+ // Note that we don't include the chapter text in the payload; that's stored in the chapters subcollection.
48
+ // We just return the chapter metadata here, which is stored in the book collection.
49
+ const json = {
50
+ id: this.id,
51
+ title: this.title,
52
+ authors: this.authors.slice(),
53
+ image: this.image,
54
+ numbered: this.numbered,
55
+ forthcoming: this.forthcoming,
56
+ uids: this.uids,
57
+ };
58
+ if (this.ref)
59
+ json.ref = this.ref;
60
+ if (this.section)
61
+ json.section = this.section;
62
+ return json;
63
+ }
64
+ getRef() {
65
+ return this.ref;
66
+ }
67
+ withEditors(uids) {
68
+ return new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text, uids);
69
+ }
70
+ withRef(ref) {
71
+ return new Chapter(ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
72
+ }
73
+ withoutRef() {
74
+ return new Chapter(undefined, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
75
+ }
76
+ getID() {
77
+ return this.id;
78
+ }
79
+ withChapterID(id) {
80
+ return new Chapter(this.ref, id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
81
+ }
82
+ getSection() {
83
+ return this.section;
84
+ }
85
+ withSection(section) {
86
+ return new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, section, this.text, this.uids);
87
+ }
88
+ isForthcoming() {
89
+ return this.forthcoming;
90
+ }
91
+ asForthcoming(forthcoming) {
92
+ return new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, forthcoming, this.section, this.text, this.uids);
93
+ }
94
+ isNumbered() {
95
+ return this.numbered;
96
+ }
97
+ asNumbered(numbered) {
98
+ return new Chapter(this.ref, this.id, this.title, this.authors, this.image, numbered, this.forthcoming, this.section, this.text, this.uids);
99
+ }
100
+ isEditor(uid) {
101
+ return this.uids.includes(uid);
102
+ }
103
+ getText() {
104
+ return this.text;
105
+ }
106
+ withText(text) {
107
+ return new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, text, this.uids);
108
+ }
109
+ withAST(ast) {
110
+ const newChapter = new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, ast.toBookdown(), this.uids);
111
+ newChapter._ast = ast;
112
+ return newChapter;
113
+ }
114
+ getAuthors() {
115
+ return this.authors;
116
+ }
117
+ withAuthor(name) {
118
+ return new Chapter(this.ref, this.id, this.title, [...this.authors, name], this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
119
+ }
120
+ withRenamedAuthor(index, name) {
121
+ if (index < 0 || index >= this.authors.length)
122
+ return this;
123
+ return new Chapter(this.ref, this.id, this.title, [
124
+ ...this.authors.slice(0, index),
125
+ name,
126
+ ...this.authors.slice(index + 1),
127
+ ], this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
128
+ }
129
+ withoutAuthor(index) {
130
+ if (index < 0 || index >= this.authors.length)
131
+ return this;
132
+ return new Chapter(this.ref, this.id, this.title, [...this.authors.slice(0, index), ...this.authors.slice(index + 1)], this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
133
+ }
134
+ getTitle() {
135
+ return this.title;
136
+ }
137
+ withTitle(title) {
138
+ return new Chapter(this.ref, this.id, title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
139
+ }
140
+ getImage() {
141
+ return this.image;
142
+ }
143
+ withImage(image) {
144
+ return new Chapter(this.ref, this.id, this.title, this.authors, image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
145
+ }
146
+ getAST(edition) {
147
+ // Compute the cache if necessary
148
+ if (this._ast === undefined)
149
+ this._ast = Parser.parseChapter(edition, this.text);
150
+ return this._ast;
151
+ }
152
+ getWordCount(edition) {
153
+ if (this._wordCount === undefined)
154
+ this._wordCount = this.getAST(edition).toText().split(/\s+/).length;
155
+ return this._wordCount;
156
+ }
157
+ // Utility function
158
+ getReadingTime(edition) {
159
+ return this.isForthcoming()
160
+ ? undefined
161
+ : Math.max(1, Math.round(this.getWordCount(edition) / 150));
162
+ }
163
+ getIndex(edition) {
164
+ if (this._index === undefined) {
165
+ const ast = this.getAST(edition);
166
+ // Build a list of common words
167
+ let commonWords = new Set();
168
+ CommonWords.forEach((word) => commonWords.add(word));
169
+ // Get all the text in the chapter.
170
+ let text = ast.toText();
171
+ // Split by word boundaries.
172
+ const words = text.split(/\b/);
173
+ // Index the words
174
+ const index = {};
175
+ words.forEach((word, wordNumber) => {
176
+ // Skip non words. We keep them for search results.
177
+ if (!/[a-zA-Z\u2019]+/.test(word))
178
+ return;
179
+ word = word.toLowerCase();
180
+ // Should we include?
181
+ // • It shouldn't be a common word
182
+ // • It shouldn't have an apostrophe
183
+ // • It should be longer than two letters
184
+ // • It shouldn't end in 'ly'
185
+ if (!commonWords.has(word) &&
186
+ word.indexOf('\u2019') < 0 &&
187
+ word.length > 2 &&
188
+ word.substring(word.length - 2, word.length) !== 'ly') {
189
+ // If we haven't started a list of occurrences, start one.
190
+ if (!(word in index))
191
+ index[word] = [];
192
+ let match = {
193
+ left: words
194
+ .slice(Math.max(0, wordNumber - 10), Math.max(0, wordNumber - 1) + 1)
195
+ .join(''),
196
+ match: words[wordNumber],
197
+ right: words
198
+ .slice(Math.min(words.length - 1, wordNumber + 1), Math.min(words.length - 1, wordNumber + 10) + 1)
199
+ .join(''),
200
+ };
201
+ // Add the occurrence, but a lower case canonical version.
202
+ index[word.toLowerCase()].push(match);
203
+ }
204
+ });
205
+ this._index = index;
206
+ }
207
+ return this._index;
208
+ }
209
+ toString() {
210
+ return `${this.title} by ${this.authors.join(', ')}: ${this.text.substring(0, 32)}}`;
211
+ }
212
+ }
@@ -0,0 +1,10 @@
1
+ declare const ChapterIDs: {
2
+ TableOfContentsID: string;
3
+ ReferencesID: string;
4
+ SearchID: string;
5
+ MediaID: string;
6
+ IndexID: string;
7
+ GlossaryID: string;
8
+ UnknownID: string;
9
+ };
10
+ export default ChapterIDs;
@@ -7,5 +7,4 @@ const ChapterIDs = {
7
7
  GlossaryID: 'glossary',
8
8
  UnknownID: 'unknown',
9
9
  };
10
-
11
10
  export default ChapterIDs;
@@ -0,0 +1,6 @@
1
+ type Definition = {
2
+ phrase: string;
3
+ definition: string;
4
+ synonyms?: string[];
5
+ };
6
+ export default Definition;
@@ -0,0 +1 @@
1
+ export {};