bookish-press 0.4.24 → 0.4.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Auth.svelte +2 -2
- package/components/page/Acknowledgements.svelte +2 -2
- package/components/page/BookLoader.svelte +2 -2
- package/components/page/Chapter.svelte +2 -2
- package/components/page/Contexts.d.ts +5 -5
- package/components/page/Contexts.js +7 -7
- package/components/page/DefinitionView.svelte +2 -2
- package/components/page/Description.svelte +2 -2
- package/components/page/EditionLoader.svelte +2 -2
- package/components/page/Editions.svelte +2 -2
- package/components/page/Glossary.svelte +2 -2
- package/components/page/Header.svelte +2 -2
- package/components/page/License.svelte +2 -2
- package/components/page/Publish.svelte +2 -2
- package/components/page/References.svelte +2 -2
- package/components/page/TableOfContents.svelte +2 -2
- package/models/Firebase.js +2 -2
- package/package.json +1 -1
package/components/Auth.svelte
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { onDestroy, setContext } from 'svelte';
|
|
3
3
|
import { writable } from 'svelte/store';
|
|
4
4
|
import { auth } from '../models/Firebase';
|
|
5
|
-
import {
|
|
5
|
+
import { USER } from './page/Contexts';
|
|
6
6
|
// Track the user and user loading status in state
|
|
7
7
|
let loading = true;
|
|
8
8
|
// The store that tracks the auth context.
|
|
@@ -46,7 +46,7 @@ if (auth) {
|
|
|
46
46
|
onDestroy(unsubscribe);
|
|
47
47
|
}
|
|
48
48
|
// Expose the state and the login/logout functionality.
|
|
49
|
-
setContext(
|
|
49
|
+
setContext(USER, authentication);
|
|
50
50
|
</script>
|
|
51
51
|
|
|
52
52
|
<!-- Wrap whatever children are given in this context. -->
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import ChapterBody from '../chapter/ChapterBody.svelte';
|
|
3
3
|
import BookishEditor from '../editor/BookishEditor.svelte';
|
|
4
4
|
import Instructions from './Instructions.svelte';
|
|
5
|
-
import {
|
|
5
|
+
import { getUser, getEdition, getLeasee, isEditionEditable, lease, } from './Contexts';
|
|
6
6
|
import PageHeader from './PageHeader.svelte';
|
|
7
|
-
let auth =
|
|
7
|
+
let auth = getUser();
|
|
8
8
|
let edition = getEdition();
|
|
9
9
|
let editable = isEditionEditable();
|
|
10
10
|
$: acknowledgements = $edition?.getAcknowledgements();
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import Feedback from '../app/Feedback.svelte';
|
|
3
3
|
import { onDestroy } from 'svelte';
|
|
4
4
|
import { page } from '$app/stores';
|
|
5
|
-
import { getBook,
|
|
5
|
+
import { getBook, getUser } from './Contexts';
|
|
6
6
|
import { listenToBookWithID as listenToBooksWithID, listenToBooksByName as listenToBooksWithName, } from '../../models/CRUD';
|
|
7
|
-
let auth =
|
|
7
|
+
let auth = getUser();
|
|
8
8
|
let book = getBook();
|
|
9
9
|
// Keep track of the query updates
|
|
10
10
|
let booksByName = undefined;
|
|
@@ -11,7 +11,7 @@ import ChapterBody from '../chapter/ChapterBody.svelte';
|
|
|
11
11
|
import PossibleReference from './PossibleReference.svelte';
|
|
12
12
|
import ChapterNumber from './ChapterNumber.svelte';
|
|
13
13
|
import Problem from '../chapter/Problem.svelte';
|
|
14
|
-
import { CHAPTER,
|
|
14
|
+
import { CHAPTER, getUser, getBook, getEdition, isBookEditable, isChapterEditable, isEditionPartiallyEditable, getLeasee, lease, setChapter, isEditionEditable, } from './Contexts';
|
|
15
15
|
import { writable } from 'svelte/store';
|
|
16
16
|
import { onMount, setContext } from 'svelte';
|
|
17
17
|
import { hideOutlineIfObscured, layoutMarginals } from './margins';
|
|
@@ -26,7 +26,7 @@ export let chapter;
|
|
|
26
26
|
export let print = false;
|
|
27
27
|
let book = getBook();
|
|
28
28
|
let edition = getEdition();
|
|
29
|
-
let auth =
|
|
29
|
+
let auth = getUser();
|
|
30
30
|
// Keep track of the scroll position to facilitate reading during reloads.
|
|
31
31
|
function rememberPosition() {
|
|
32
32
|
localStorage.setItem('scrollposition', '' + window.scrollY);
|
|
@@ -10,9 +10,9 @@ import type { DocumentReference } from 'firebase/firestore';
|
|
|
10
10
|
export type DarkModeStore = Writable<boolean>;
|
|
11
11
|
export declare const DARK_MODE: unique symbol;
|
|
12
12
|
export declare function getDarkMode(): DarkModeStore;
|
|
13
|
-
export type
|
|
14
|
-
export declare const
|
|
15
|
-
export declare function
|
|
13
|
+
export type UserStore = Writable<Authentication | undefined>;
|
|
14
|
+
export declare const USER: unique symbol;
|
|
15
|
+
export declare function getUser(): UserStore;
|
|
16
16
|
export type BookStore = Writable<Book | undefined>;
|
|
17
17
|
export declare const BOOK: unique symbol;
|
|
18
18
|
export declare function getBook(): BookStore;
|
|
@@ -43,5 +43,5 @@ export declare function getCaret(): Writable<CaretState | undefined>;
|
|
|
43
43
|
export declare const STATUS: unique symbol;
|
|
44
44
|
export type StatusStore = Writable<BookSaveStatus>;
|
|
45
45
|
export declare function getStatus(): StatusStore;
|
|
46
|
-
export declare function lease(authStore:
|
|
47
|
-
export declare function getLeasee(authStore:
|
|
46
|
+
export declare function lease(authStore: UserStore, editionStore: EditionStore, contentID: string, lock: boolean): Promise<boolean>;
|
|
47
|
+
export declare function getLeasee(authStore: UserStore, editionStore: EditionStore, contentID: string): string | boolean;
|
|
@@ -10,9 +10,9 @@ export const DARK_MODE = Symbol('dark');
|
|
|
10
10
|
export function getDarkMode() {
|
|
11
11
|
return getContext(DARK_MODE);
|
|
12
12
|
}
|
|
13
|
-
export const
|
|
14
|
-
export function
|
|
15
|
-
return getContext(
|
|
13
|
+
export const USER = Symbol('user');
|
|
14
|
+
export function getUser() {
|
|
15
|
+
return getContext(USER);
|
|
16
16
|
}
|
|
17
17
|
export const BOOK = Symbol('book');
|
|
18
18
|
export function getBook() {
|
|
@@ -42,7 +42,7 @@ export function setChapter(store, previous, chapter) {
|
|
|
42
42
|
export function isChapterEditable() {
|
|
43
43
|
if (!get(page).route.id?.startsWith('/write'))
|
|
44
44
|
return false;
|
|
45
|
-
const auth = get(
|
|
45
|
+
const auth = get(getUser());
|
|
46
46
|
const chapter = get(getChapter());
|
|
47
47
|
const edition = get(getEdition());
|
|
48
48
|
const book = get(getBook());
|
|
@@ -58,7 +58,7 @@ export function isChapterEditable() {
|
|
|
58
58
|
export function isEditionEditable() {
|
|
59
59
|
if (!get(page).route.id?.startsWith('/write'))
|
|
60
60
|
return false;
|
|
61
|
-
const auth = get(
|
|
61
|
+
const auth = get(getUser());
|
|
62
62
|
const edition = get(getEdition());
|
|
63
63
|
const book = get(getBook());
|
|
64
64
|
return (edition !== undefined &&
|
|
@@ -70,7 +70,7 @@ export function isEditionEditable() {
|
|
|
70
70
|
export function isEditionPartiallyEditable() {
|
|
71
71
|
if (!get(page).route.id?.startsWith('/write'))
|
|
72
72
|
return false;
|
|
73
|
-
const auth = get(
|
|
73
|
+
const auth = get(getUser());
|
|
74
74
|
const edition = get(getEdition());
|
|
75
75
|
return (edition !== undefined &&
|
|
76
76
|
auth !== undefined &&
|
|
@@ -80,7 +80,7 @@ export function isEditionPartiallyEditable() {
|
|
|
80
80
|
export function isBookEditable() {
|
|
81
81
|
if (!get(page).route.id?.startsWith('/write'))
|
|
82
82
|
return false;
|
|
83
|
-
const auth = get(
|
|
83
|
+
const auth = get(getUser());
|
|
84
84
|
const book = get(getBook());
|
|
85
85
|
return (book !== undefined &&
|
|
86
86
|
auth !== undefined &&
|
|
@@ -5,11 +5,11 @@ import BookishEditor from '../editor/BookishEditor.svelte';
|
|
|
5
5
|
import Format from '../chapter/Format.svelte';
|
|
6
6
|
import Note from '../editor/Note.svelte';
|
|
7
7
|
import { afterUpdate } from 'svelte';
|
|
8
|
-
import {
|
|
8
|
+
import { getUser, getEdition, getLeasee, isChapterEditable, lease, } from './Contexts';
|
|
9
9
|
import Button from '../app/Button.svelte';
|
|
10
10
|
export let id;
|
|
11
11
|
export let definition;
|
|
12
|
-
let auth =
|
|
12
|
+
let auth = getUser();
|
|
13
13
|
let edition = getEdition();
|
|
14
14
|
let editable = isChapterEditable();
|
|
15
15
|
// Focus after adding a new synonym.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script>import Parser from '../../models/chapter/Parser';
|
|
2
2
|
import ChapterBody from '../chapter/ChapterBody.svelte';
|
|
3
3
|
import BookishEditor from '../editor/BookishEditor.svelte';
|
|
4
|
-
import {
|
|
5
|
-
let auth =
|
|
4
|
+
import { getUser, getEdition, getLeasee, isEditionEditable, lease, } from './Contexts';
|
|
5
|
+
let auth = getUser();
|
|
6
6
|
let editable = isEditionEditable();
|
|
7
7
|
let edition = getEdition();
|
|
8
8
|
</script>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<script>import Loading from './Loading.svelte';
|
|
2
2
|
import Edition from './Edition.svelte';
|
|
3
3
|
import Feedback from '../app/Feedback.svelte';
|
|
4
|
-
import { getBook, getEdition,
|
|
4
|
+
import { getBook, getEdition, getUser, CHAPTERTEXT, getChapterText, } from './Contexts';
|
|
5
5
|
import { onDestroy } from 'svelte';
|
|
6
6
|
import { page } from '$app/stores';
|
|
7
7
|
import { listenToChapters, listenToEdition } from '../../models/CRUD';
|
|
8
8
|
export let write;
|
|
9
|
-
let auth =
|
|
9
|
+
let auth = getUser();
|
|
10
10
|
let book = getBook();
|
|
11
11
|
let edition = getEdition();
|
|
12
12
|
let chapterText = getChapterText();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script>import { createNewEdition } from '../../models/CRUD';
|
|
2
2
|
import Instructions from './Instructions.svelte';
|
|
3
3
|
import Note from '../editor/Note.svelte';
|
|
4
|
-
import {
|
|
4
|
+
import { getUser, getBook, isBookEditable } from './Contexts';
|
|
5
5
|
import Button from '../app/Button.svelte';
|
|
6
6
|
import Link from '../app/Link.svelte';
|
|
7
7
|
import Format from '../chapter/Format.svelte';
|
|
@@ -9,7 +9,7 @@ import Parser from '../../models/chapter/Parser';
|
|
|
9
9
|
import Permissions from '../editor/Permissions.svelte';
|
|
10
10
|
let book = getBook();
|
|
11
11
|
let editable = isBookEditable();
|
|
12
|
-
let auth =
|
|
12
|
+
let auth = getUser();
|
|
13
13
|
$: editions = $book?.getEditions();
|
|
14
14
|
$: latestPublishedID = $book?.getLatestPublishedEditionID();
|
|
15
15
|
async function handleDraftEdition() {
|
|
@@ -3,10 +3,10 @@ import Outline from './Outline.svelte';
|
|
|
3
3
|
import Page from './Page.svelte';
|
|
4
4
|
import ChapterIDs from '../../models/book/ChapterID';
|
|
5
5
|
import DefinitionView from './DefinitionView.svelte';
|
|
6
|
-
import {
|
|
6
|
+
import { getUser, getEdition, isEditionEditable } from './Contexts';
|
|
7
7
|
import Instructions from './Instructions.svelte';
|
|
8
8
|
import Button from '../app/Button.svelte';
|
|
9
|
-
let auth =
|
|
9
|
+
let auth = getUser();
|
|
10
10
|
let edition = getEdition();
|
|
11
11
|
let editable = isEditionEditable();
|
|
12
12
|
$: glossary = $edition?.getGlossary() ?? {};
|
|
@@ -4,7 +4,7 @@ import BookishEditor from '../editor/BookishEditor.svelte';
|
|
|
4
4
|
import Title from './Title.svelte';
|
|
5
5
|
import { onMount } from 'svelte';
|
|
6
6
|
import TextEditor from '../editor/TextEditor.svelte';
|
|
7
|
-
import {
|
|
7
|
+
import { getUser, getEdition, getLeasee, lease } from './Contexts';
|
|
8
8
|
import Button from '../app/Button.svelte';
|
|
9
9
|
/** True if an author should be able to edit this header. */
|
|
10
10
|
export let editable;
|
|
@@ -19,7 +19,7 @@ export let setImage;
|
|
|
19
19
|
export let save = null;
|
|
20
20
|
let title = null;
|
|
21
21
|
let showReminder = true;
|
|
22
|
-
let auth =
|
|
22
|
+
let auth = getUser();
|
|
23
23
|
let edition = getEdition();
|
|
24
24
|
function updateScrollReminder() {
|
|
25
25
|
// If the bottom of the window is below the top of the title, hide the reminder.
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import BookishEditor from '../editor/BookishEditor.svelte';
|
|
3
3
|
import Instructions from './Instructions.svelte';
|
|
4
4
|
import Format from '../chapter/Format.svelte';
|
|
5
|
-
import {
|
|
5
|
+
import { getUser, getEdition, getLeasee, isEditionEditable, lease, } from './Contexts';
|
|
6
6
|
import PageHeader from './PageHeader.svelte';
|
|
7
|
-
let auth =
|
|
7
|
+
let auth = getUser();
|
|
8
8
|
let edition = getEdition();
|
|
9
9
|
let editable = isEditionEditable();
|
|
10
10
|
</script>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script>import Parser from '../../models/chapter/Parser';
|
|
2
2
|
import BookishEditor from '../editor/BookishEditor.svelte';
|
|
3
3
|
import Switch from '../editor/Switch.svelte';
|
|
4
|
-
import {
|
|
4
|
+
import { getUser, getEdition, getLeasee, isEditionEditable, lease, } from './Contexts';
|
|
5
5
|
import Format from '../chapter/Format.svelte';
|
|
6
6
|
import Note from '../editor/Note.svelte';
|
|
7
7
|
import Instructions from './Instructions.svelte';
|
|
@@ -10,7 +10,7 @@ import { PUBLIC_CONTEXT } from '$env/static/public';
|
|
|
10
10
|
import Button from '../app/Button.svelte';
|
|
11
11
|
import { publish } from '../../models/CRUD';
|
|
12
12
|
import Feedback from '../app/Feedback.svelte';
|
|
13
|
-
let auth =
|
|
13
|
+
let auth = getUser();
|
|
14
14
|
let edition = getEdition();
|
|
15
15
|
let editable = isEditionEditable();
|
|
16
16
|
let publishing = false;
|
|
@@ -4,8 +4,8 @@ import Page from './Page.svelte';
|
|
|
4
4
|
import ChapterIDs from '../../models/book/ChapterID';
|
|
5
5
|
import BulkReferenceEditor from './BulkReferenceEditor.svelte';
|
|
6
6
|
import PossibleReference from './PossibleReference.svelte';
|
|
7
|
-
import {
|
|
8
|
-
let auth =
|
|
7
|
+
import { getUser, getEdition, isEditionEditable } from './Contexts';
|
|
8
|
+
let auth = getUser();
|
|
9
9
|
let edition = getEdition();
|
|
10
10
|
let editable = isEditionEditable();
|
|
11
11
|
$: references = $edition?.hasReferences() ? $edition.getReferences() : null;
|
|
@@ -13,7 +13,7 @@ import License from './License.svelte';
|
|
|
13
13
|
import Authors from './Authors.svelte';
|
|
14
14
|
import TextEditor from '../editor/TextEditor.svelte';
|
|
15
15
|
import Toggle from '../editor/Toggle.svelte';
|
|
16
|
-
import {
|
|
16
|
+
import { getUser, getBase, getBook, getEdition, isBookEditable, isEditionEditable, isEditionPartiallyEditable, setChapter, } from './Contexts';
|
|
17
17
|
import Muted from './Muted.svelte';
|
|
18
18
|
import Button from '../app/Button.svelte';
|
|
19
19
|
import PageHeader from './PageHeader.svelte';
|
|
@@ -22,7 +22,7 @@ import PageParagraph from './PageParagraph.svelte';
|
|
|
22
22
|
import Note from '../editor/Note.svelte';
|
|
23
23
|
import Permissions from '../editor/Permissions.svelte';
|
|
24
24
|
import Publish from './Publish.svelte';
|
|
25
|
-
let auth =
|
|
25
|
+
let auth = getUser();
|
|
26
26
|
let book = getBook();
|
|
27
27
|
let edition = getEdition();
|
|
28
28
|
let base = getBase();
|
package/models/Firebase.js
CHANGED
|
@@ -3,8 +3,8 @@ import { connectAuthEmulator, getAuth } from 'firebase/auth';
|
|
|
3
3
|
import { connectFirestoreEmulator, getFirestore } from 'firebase/firestore';
|
|
4
4
|
import { connectFunctionsEmulator, getFunctions } from 'firebase/functions';
|
|
5
5
|
import { connectStorageEmulator, getStorage } from 'firebase/storage';
|
|
6
|
-
import { PUBLIC_CONTEXT, PUBLIC_FIREBASE_API_KEY, PUBLIC_FIREBASE_AUTH_DOMAIN, PUBLIC_FIREBASE_PROJECT_ID, PUBLIC_FIREBASE_STORAGE_BUCKET, PUBLIC_FIREBASE_MESSAGING_SENDER_ID, PUBLIC_FIREBASE_APP_ID, } from '$env/static/public';
|
|
7
|
-
const isReader =
|
|
6
|
+
import { PUBLIC_READER, PUBLIC_CONTEXT, PUBLIC_FIREBASE_API_KEY, PUBLIC_FIREBASE_AUTH_DOMAIN, PUBLIC_FIREBASE_PROJECT_ID, PUBLIC_FIREBASE_STORAGE_BUCKET, PUBLIC_FIREBASE_MESSAGING_SENDER_ID, PUBLIC_FIREBASE_APP_ID, } from '$env/static/public';
|
|
7
|
+
const isReader = PUBLIC_READER === 'true';
|
|
8
8
|
// Some feedback about context
|
|
9
9
|
if (PUBLIC_CONTEXT !== 'prod')
|
|
10
10
|
console.log(`*** ${PUBLIC_CONTEXT.toLocaleUpperCase()} ***`);
|