@inkbar/svelte 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +181 -2
- package/dist/components/InkAnnotation.svelte +73 -0
- package/dist/components/InkAnnotation.svelte.d.ts +13 -0
- package/dist/components/InkAnnotation.svelte.d.ts.map +1 -0
- package/dist/components/InkIcon.svelte +24 -0
- package/dist/components/InkIcon.svelte.d.ts +9 -0
- package/dist/components/InkIcon.svelte.d.ts.map +1 -0
- package/dist/components/InkNextPage.svelte +38 -0
- package/dist/components/InkNextPage.svelte.d.ts +5 -0
- package/dist/components/InkNextPage.svelte.d.ts.map +1 -0
- package/dist/components/InkNotePopover.svelte +193 -0
- package/dist/components/InkNotePopover.svelte.d.ts +9 -0
- package/dist/components/InkNotePopover.svelte.d.ts.map +1 -0
- package/dist/components/InkPage.svelte +125 -0
- package/dist/components/InkPage.svelte.d.ts +22 -0
- package/dist/components/InkPage.svelte.d.ts.map +1 -0
- package/dist/components/InkPageCount.svelte +20 -0
- package/dist/components/InkPageCount.svelte.d.ts +6 -0
- package/dist/components/InkPageCount.svelte.d.ts.map +1 -0
- package/dist/components/InkPageInput.svelte +49 -0
- package/dist/components/InkPageInput.svelte.d.ts +6 -0
- package/dist/components/InkPageInput.svelte.d.ts.map +1 -0
- package/dist/components/InkPrevPage.svelte +38 -0
- package/dist/components/InkPrevPage.svelte.d.ts +5 -0
- package/dist/components/InkPrevPage.svelte.d.ts.map +1 -0
- package/dist/components/InkRedo.svelte +38 -0
- package/dist/components/InkRedo.svelte.d.ts +5 -0
- package/dist/components/InkRedo.svelte.d.ts.map +1 -0
- package/dist/components/InkRoot.svelte +358 -0
- package/dist/components/InkRoot.svelte.d.ts +51 -0
- package/dist/components/InkRoot.svelte.d.ts.map +1 -0
- package/dist/components/InkSuggestionCard.svelte +121 -0
- package/dist/components/InkSuggestionCard.svelte.d.ts +9 -0
- package/dist/components/InkSuggestionCard.svelte.d.ts.map +1 -0
- package/dist/components/InkToolButton.svelte +68 -0
- package/dist/components/InkToolButton.svelte.d.ts +17 -0
- package/dist/components/InkToolButton.svelte.d.ts.map +1 -0
- package/dist/components/InkToolbar.svelte +40 -0
- package/dist/components/InkToolbar.svelte.d.ts +13 -0
- package/dist/components/InkToolbar.svelte.d.ts.map +1 -0
- package/dist/components/InkToolbarSeparator.svelte +18 -0
- package/dist/components/InkToolbarSeparator.svelte.d.ts +6 -0
- package/dist/components/InkToolbarSeparator.svelte.d.ts.map +1 -0
- package/dist/components/InkUndo.svelte +38 -0
- package/dist/components/InkUndo.svelte.d.ts +5 -0
- package/dist/components/InkUndo.svelte.d.ts.map +1 -0
- package/dist/components/InkViewport.svelte +306 -0
- package/dist/components/InkViewport.svelte.d.ts +27 -0
- package/dist/components/InkViewport.svelte.d.ts.map +1 -0
- package/dist/components/InkZoomIn.svelte +36 -0
- package/dist/components/InkZoomIn.svelte.d.ts +5 -0
- package/dist/components/InkZoomIn.svelte.d.ts.map +1 -0
- package/dist/components/InkZoomOut.svelte +36 -0
- package/dist/components/InkZoomOut.svelte.d.ts +5 -0
- package/dist/components/InkZoomOut.svelte.d.ts.map +1 -0
- package/dist/components/InkZoomSelect.svelte +105 -0
- package/dist/components/InkZoomSelect.svelte.d.ts +7 -0
- package/dist/components/InkZoomSelect.svelte.d.ts.map +1 -0
- package/dist/components/ThreadForm.svelte +42 -0
- package/dist/components/ThreadForm.svelte.d.ts +11 -0
- package/dist/components/ThreadForm.svelte.d.ts.map +1 -0
- package/dist/components/annotation-element.svelte.d.ts +9 -0
- package/dist/components/annotation-element.svelte.d.ts.map +1 -0
- package/dist/components/annotation-element.svelte.js +25 -0
- package/dist/components/child-snippet.d.ts +22 -0
- package/dist/components/child-snippet.d.ts.map +1 -0
- package/dist/components/child-snippet.js +14 -0
- package/dist/components/history-button.d.ts +10 -0
- package/dist/components/history-button.d.ts.map +1 -0
- package/dist/components/history-button.js +1 -0
- package/dist/components/page-button.d.ts +10 -0
- package/dist/components/page-button.d.ts.map +1 -0
- package/dist/components/page-button.js +1 -0
- package/dist/components/popover-focus.d.ts +33 -0
- package/dist/components/popover-focus.d.ts.map +1 -0
- package/dist/components/popover-focus.js +63 -0
- package/dist/components/portal.d.ts +26 -0
- package/dist/components/portal.d.ts.map +1 -0
- package/dist/components/portal.js +55 -0
- package/dist/components/zoom-button.d.ts +10 -0
- package/dist/components/zoom-button.d.ts.map +1 -0
- package/dist/components/zoom-button.js +1 -0
- package/dist/context.d.ts +57 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +34 -0
- package/dist/hooks/useAnnotations.svelte.d.ts +1683 -0
- package/dist/hooks/useAnnotations.svelte.d.ts.map +1 -0
- package/dist/hooks/useAnnotations.svelte.js +33 -0
- package/dist/hooks/useDocument.svelte.d.ts +12 -0
- package/dist/hooks/useDocument.svelte.d.ts.map +1 -0
- package/dist/hooks/useDocument.svelte.js +28 -0
- package/dist/hooks/useEmbedded.svelte.d.ts +7 -0
- package/dist/hooks/useEmbedded.svelte.d.ts.map +1 -0
- package/dist/hooks/useEmbedded.svelte.js +17 -0
- package/dist/hooks/useHistory.svelte.d.ts +7 -0
- package/dist/hooks/useHistory.svelte.d.ts.map +1 -0
- package/dist/hooks/useHistory.svelte.js +8 -0
- package/dist/hooks/usePage.svelte.d.ts +10 -0
- package/dist/hooks/usePage.svelte.d.ts.map +1 -0
- package/dist/hooks/usePage.svelte.js +29 -0
- package/dist/hooks/useSelection.svelte.d.ts +6 -0
- package/dist/hooks/useSelection.svelte.d.ts.map +1 -0
- package/dist/hooks/useSelection.svelte.js +12 -0
- package/dist/hooks/useTool.svelte.d.ts +6 -0
- package/dist/hooks/useTool.svelte.d.ts.map +1 -0
- package/dist/hooks/useTool.svelte.js +10 -0
- package/dist/hooks/useZoom.svelte.d.ts +9 -0
- package/dist/hooks/useZoom.svelte.d.ts.map +1 -0
- package/dist/hooks/useZoom.svelte.js +18 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/use-readable.svelte.d.ts +13 -0
- package/dist/use-readable.svelte.d.ts.map +1 -0
- package/dist/use-readable.svelte.js +28 -0
- package/package.json +56 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAnnotations.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/hooks/useAnnotations.svelte.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE/D,wBAAgB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAkBX,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAIL,MAAM;EAEvB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { acceptSuggestion, repliesTo } from '@inkbar/core';
|
|
2
|
+
import { useInkContext } from '../context.js';
|
|
3
|
+
export function useAnnotations() {
|
|
4
|
+
const ctx = useInkContext('useAnnotations()');
|
|
5
|
+
const selected = $derived(ctx.selection
|
|
6
|
+
.map((id) => ctx.annotations.find((a) => a.id === id))
|
|
7
|
+
.filter((a) => !!a));
|
|
8
|
+
const store = () => ctx.document?.annotations;
|
|
9
|
+
return {
|
|
10
|
+
get annotations() {
|
|
11
|
+
return ctx.annotations;
|
|
12
|
+
},
|
|
13
|
+
get selection() {
|
|
14
|
+
return ctx.selection;
|
|
15
|
+
},
|
|
16
|
+
get selected() {
|
|
17
|
+
return selected;
|
|
18
|
+
},
|
|
19
|
+
byPage: (page) => ctx.annotations.filter((a) => a.page === page),
|
|
20
|
+
/** Replies in creation order for a note id. */
|
|
21
|
+
replies: (id) => repliesTo(ctx.annotations, id),
|
|
22
|
+
add: (input) => store()?.add(input),
|
|
23
|
+
update: (id, patch) => store()?.update(id, patch),
|
|
24
|
+
remove: (id) => store()?.remove(id) ?? false,
|
|
25
|
+
select: (ids) => store()?.select(ids),
|
|
26
|
+
/** Keeps a suggested redaction as the user's own, in the default redaction colour. */
|
|
27
|
+
accept: (id) => {
|
|
28
|
+
const s = store();
|
|
29
|
+
return s ? acceptSuggestion(s, id) : undefined;
|
|
30
|
+
},
|
|
31
|
+
dismiss: (id) => store()?.remove(id) ?? false,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AnnotationDocument, ImportOptions, PageInfo } from '@inkbar/core';
|
|
2
|
+
export declare function useDocument(): {
|
|
3
|
+
readonly document: import("@inkbar/core").InkDocument | null;
|
|
4
|
+
readonly status: import("@inkbar/core").InkStatus;
|
|
5
|
+
readonly isReady: boolean;
|
|
6
|
+
readonly error: import("@inkbar/core").InkError | null;
|
|
7
|
+
readonly pages: readonly PageInfo[];
|
|
8
|
+
readonly info: import("@inkbar/core").DocumentInfo | null;
|
|
9
|
+
exportAnnotations: () => AnnotationDocument | undefined;
|
|
10
|
+
importAnnotations: (data: AnnotationDocument | string, opts?: ImportOptions) => import("@inkbar/core").ImportResult | undefined;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=useDocument.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDocument.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/hooks/useDocument.svelte.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAI/E,wBAAgB,WAAW;;;;;;;;8BAuBG,kBAAkB,GAAG,MAAM,SAAS,aAAa;EAG9E"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useInkContext } from '../context.js';
|
|
2
|
+
const NO_PAGES = [];
|
|
3
|
+
export function useDocument() {
|
|
4
|
+
const ctx = useInkContext('useDocument()');
|
|
5
|
+
return {
|
|
6
|
+
get document() {
|
|
7
|
+
return ctx.document;
|
|
8
|
+
},
|
|
9
|
+
get status() {
|
|
10
|
+
return ctx.status;
|
|
11
|
+
},
|
|
12
|
+
get isReady() {
|
|
13
|
+
return ctx.status.state === 'ready';
|
|
14
|
+
},
|
|
15
|
+
get error() {
|
|
16
|
+
const s = ctx.status;
|
|
17
|
+
return s.state === 'error' ? s.error : null;
|
|
18
|
+
},
|
|
19
|
+
get pages() {
|
|
20
|
+
return ctx.document?.pages ?? NO_PAGES;
|
|
21
|
+
},
|
|
22
|
+
get info() {
|
|
23
|
+
return ctx.document?.info ?? null;
|
|
24
|
+
},
|
|
25
|
+
exportAnnotations: () => ctx.document?.exportAnnotations('json'),
|
|
26
|
+
importAnnotations: (data, opts) => ctx.document?.importAnnotations(data, opts),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEmbedded.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/hooks/useEmbedded.svelte.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAInD,wBAAgB,WAAW;;;;EAc1B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useInkContext } from '../context.js';
|
|
2
|
+
const NONE = [];
|
|
3
|
+
export function useEmbedded() {
|
|
4
|
+
const ctx = useInkContext('useEmbedded()');
|
|
5
|
+
const summary = $derived(ctx.document?.embedded ?? NONE);
|
|
6
|
+
return {
|
|
7
|
+
get summary() {
|
|
8
|
+
return summary;
|
|
9
|
+
},
|
|
10
|
+
get total() {
|
|
11
|
+
return summary.reduce((n, s) => n + s.count, 0);
|
|
12
|
+
},
|
|
13
|
+
get hasAny() {
|
|
14
|
+
return summary.length > 0;
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type InkHistory } from '../context.js';
|
|
2
|
+
/**
|
|
3
|
+
* Undo and redo. Uncontrolled documents use the core history; controlled hosts that pass
|
|
4
|
+
* `history` to InkRoot get a snapshot stack over their own list, applied through the binding.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useHistory(): InkHistory;
|
|
7
|
+
//# sourceMappingURL=useHistory.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHistory.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/hooks/useHistory.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,eAAe,CAAA;AAE9D;;;GAGG;AACH,wBAAgB,UAAU,IAAI,UAAU,CAEvC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { useInkContext } from '../context.js';
|
|
2
|
+
/**
|
|
3
|
+
* Undo and redo. Uncontrolled documents use the core history; controlled hosts that pass
|
|
4
|
+
* `history` to InkRoot get a snapshot stack over their own list, applied through the binding.
|
|
5
|
+
*/
|
|
6
|
+
export function useHistory() {
|
|
7
|
+
return useInkContext('useHistory()').history;
|
|
8
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function usePage(): {
|
|
2
|
+
/** 0-based. */
|
|
3
|
+
readonly current: number;
|
|
4
|
+
readonly count: number;
|
|
5
|
+
goTo: (index: number) => void | undefined;
|
|
6
|
+
next: () => void;
|
|
7
|
+
previous: () => void;
|
|
8
|
+
scrollToAnnotation(id: string): void;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=usePage.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePage.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/hooks/usePage.svelte.ts"],"names":[],"mappings":"AAGA,wBAAgB,OAAO;IAInB,eAAe;;;kBAOD,MAAM;;;2BASG,MAAM;EAKhC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useInkContext } from '../context.js';
|
|
2
|
+
import { useReadable } from '../use-readable.svelte.js';
|
|
3
|
+
export function usePage() {
|
|
4
|
+
const ctx = useInkContext('usePage()');
|
|
5
|
+
const current = useReadable(() => ctx.viewport?.currentPage, 0);
|
|
6
|
+
return {
|
|
7
|
+
/** 0-based. */
|
|
8
|
+
get current() {
|
|
9
|
+
return current.current;
|
|
10
|
+
},
|
|
11
|
+
get count() {
|
|
12
|
+
return ctx.document?.pages.length ?? 0;
|
|
13
|
+
},
|
|
14
|
+
goTo: (index) => ctx.viewport?.scrollToPage(index),
|
|
15
|
+
next: () => {
|
|
16
|
+
const vp = ctx.viewport;
|
|
17
|
+
vp?.scrollToPage(vp.currentPage.get() + 1);
|
|
18
|
+
},
|
|
19
|
+
previous: () => {
|
|
20
|
+
const vp = ctx.viewport;
|
|
21
|
+
vp?.scrollToPage(vp.currentPage.get() - 1);
|
|
22
|
+
},
|
|
23
|
+
scrollToAnnotation(id) {
|
|
24
|
+
const a = ctx.document?.annotations.get(id);
|
|
25
|
+
if (a)
|
|
26
|
+
ctx.viewport?.scrollToRect(a.page, a.rect);
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSelection.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/hooks/useSelection.svelte.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY;;kBAOV,MAAM,EAAE;;EAGzB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useInkContext } from '../context.js';
|
|
2
|
+
export function useSelection() {
|
|
3
|
+
const ctx = useInkContext('useSelection()');
|
|
4
|
+
const store = () => ctx.document?.annotations;
|
|
5
|
+
return {
|
|
6
|
+
get selection() {
|
|
7
|
+
return ctx.selection;
|
|
8
|
+
},
|
|
9
|
+
select: (ids) => store()?.select(ids),
|
|
10
|
+
clear: () => store()?.select([]),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTool.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/hooks/useTool.svelte.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAE9C,wBAAgB,OAAO;;kBAML,MAAM;EAEvB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ZoomValue } from '@inkbar/core/dom';
|
|
2
|
+
export declare function useZoom(): {
|
|
3
|
+
readonly zoom: ZoomValue;
|
|
4
|
+
readonly scale: number;
|
|
5
|
+
setZoom: (z: ZoomValue) => void | undefined;
|
|
6
|
+
zoomIn: () => void | undefined;
|
|
7
|
+
zoomOut: () => void | undefined;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=useZoom.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useZoom.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/hooks/useZoom.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAEjD,wBAAgB,OAAO;;;iBAWN,SAAS;;;EAIzB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useInkContext } from '../context.js';
|
|
2
|
+
import { useReadable } from '../use-readable.svelte.js';
|
|
3
|
+
export function useZoom() {
|
|
4
|
+
const ctx = useInkContext('useZoom()');
|
|
5
|
+
const zoom = useReadable(() => ctx.viewport?.zoom, 'fit-width');
|
|
6
|
+
const scale = useReadable(() => ctx.viewport?.scale, 1);
|
|
7
|
+
return {
|
|
8
|
+
get zoom() {
|
|
9
|
+
return zoom.current;
|
|
10
|
+
},
|
|
11
|
+
get scale() {
|
|
12
|
+
return scale.current;
|
|
13
|
+
},
|
|
14
|
+
setZoom: (z) => ctx.viewport?.setZoom(z),
|
|
15
|
+
zoomIn: () => ctx.viewport?.zoomBy(1.25),
|
|
16
|
+
zoomOut: () => ctx.viewport?.zoomBy(0.8),
|
|
17
|
+
};
|
|
18
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type InkRootComponent from './components/InkRoot.svelte';
|
|
2
|
+
export { useInkContext } from './context.js';
|
|
3
|
+
export type { InkContext, InkHistory, InkStatus } from './context.js';
|
|
4
|
+
export { useReadable } from './use-readable.svelte.js';
|
|
5
|
+
export type { ReadableRef } from './use-readable.svelte.js';
|
|
6
|
+
export type { AnnotationSlotProps, AnnotationState, NotePopoverSlotProps, SuggestionCardSlotProps, } from '@inkbar/core/dom';
|
|
7
|
+
export type { ConfidenceBucket } from '@inkbar/core';
|
|
8
|
+
export { useDocument } from './hooks/useDocument.svelte.js';
|
|
9
|
+
export { useAnnotations } from './hooks/useAnnotations.svelte.js';
|
|
10
|
+
export { useTool } from './hooks/useTool.svelte.js';
|
|
11
|
+
export { useSelection } from './hooks/useSelection.svelte.js';
|
|
12
|
+
export { useZoom } from './hooks/useZoom.svelte.js';
|
|
13
|
+
export { usePage } from './hooks/usePage.svelte.js';
|
|
14
|
+
export { useHistory } from './hooks/useHistory.svelte.js';
|
|
15
|
+
export { useEmbedded } from './hooks/useEmbedded.svelte.js';
|
|
16
|
+
export { default as InkRoot } from './components/InkRoot.svelte';
|
|
17
|
+
export type { InkRootProps } from './components/InkRoot.svelte';
|
|
18
|
+
export type InkRootHandle = ReturnType<typeof InkRootComponent>;
|
|
19
|
+
export { default as InkViewport } from './components/InkViewport.svelte';
|
|
20
|
+
export type { InkViewportProps } from './components/InkViewport.svelte';
|
|
21
|
+
export { default as InkPage } from './components/InkPage.svelte';
|
|
22
|
+
export type { InkPageProps } from './components/InkPage.svelte';
|
|
23
|
+
export { default as InkAnnotation } from './components/InkAnnotation.svelte';
|
|
24
|
+
export type { InkAnnotationProps } from './components/InkAnnotation.svelte';
|
|
25
|
+
export { default as InkToolbar } from './components/InkToolbar.svelte';
|
|
26
|
+
export type { InkToolbarProps } from './components/InkToolbar.svelte';
|
|
27
|
+
export { default as InkIcon } from './components/InkIcon.svelte';
|
|
28
|
+
export type { InkIconProps } from './components/InkIcon.svelte';
|
|
29
|
+
export { default as InkToolButton } from './components/InkToolButton.svelte';
|
|
30
|
+
export type { InkToolButtonProps } from './components/InkToolButton.svelte';
|
|
31
|
+
export { default as InkToolbarSeparator } from './components/InkToolbarSeparator.svelte';
|
|
32
|
+
export type { InkToolbarSeparatorProps } from './components/InkToolbarSeparator.svelte';
|
|
33
|
+
export { default as InkUndo } from './components/InkUndo.svelte';
|
|
34
|
+
export { default as InkRedo } from './components/InkRedo.svelte';
|
|
35
|
+
export type { InkHistoryButtonProps } from './components/history-button.js';
|
|
36
|
+
export { default as InkZoomIn } from './components/InkZoomIn.svelte';
|
|
37
|
+
export { default as InkZoomOut } from './components/InkZoomOut.svelte';
|
|
38
|
+
export type { InkZoomButtonProps } from './components/zoom-button.js';
|
|
39
|
+
export { default as InkZoomSelect } from './components/InkZoomSelect.svelte';
|
|
40
|
+
export type { InkZoomSelectProps } from './components/InkZoomSelect.svelte';
|
|
41
|
+
export { default as InkPageInput } from './components/InkPageInput.svelte';
|
|
42
|
+
export type { InkPageInputProps } from './components/InkPageInput.svelte';
|
|
43
|
+
export { default as InkPageCount } from './components/InkPageCount.svelte';
|
|
44
|
+
export type { InkPageCountProps } from './components/InkPageCount.svelte';
|
|
45
|
+
export { default as InkPrevPage } from './components/InkPrevPage.svelte';
|
|
46
|
+
export { default as InkNextPage } from './components/InkNextPage.svelte';
|
|
47
|
+
export type { InkPageButtonProps } from './components/page-button.js';
|
|
48
|
+
export type { ChildSnippet } from './components/child-snippet.js';
|
|
49
|
+
export { default as InkNotePopover } from './components/InkNotePopover.svelte';
|
|
50
|
+
export type { InkNotePopoverProps } from './components/InkNotePopover.svelte';
|
|
51
|
+
export { default as InkSuggestionCard } from './components/InkSuggestionCard.svelte';
|
|
52
|
+
export type { InkSuggestionCardProps } from './components/InkSuggestionCard.svelte';
|
|
53
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,gBAAgB,MAAM,6BAA6B,CAAA;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,YAAY,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAC3D,YAAY,EACV,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,kBAAkB,CAAA;AACzB,YAAY,EAAE,gBAAgB,EAA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CAAoC,CAAA;AAC7E,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,uCAAuC,CAAA;AACpF,YAAY,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export { useInkContext } from './context.js';
|
|
2
|
+
export { useReadable } from './use-readable.svelte.js';
|
|
3
|
+
export { useDocument } from './hooks/useDocument.svelte.js';
|
|
4
|
+
export { useAnnotations } from './hooks/useAnnotations.svelte.js';
|
|
5
|
+
export { useTool } from './hooks/useTool.svelte.js';
|
|
6
|
+
export { useSelection } from './hooks/useSelection.svelte.js';
|
|
7
|
+
export { useZoom } from './hooks/useZoom.svelte.js';
|
|
8
|
+
export { usePage } from './hooks/usePage.svelte.js';
|
|
9
|
+
export { useHistory } from './hooks/useHistory.svelte.js';
|
|
10
|
+
export { useEmbedded } from './hooks/useEmbedded.svelte.js';
|
|
11
|
+
export { default as InkRoot } from './components/InkRoot.svelte';
|
|
12
|
+
export { default as InkViewport } from './components/InkViewport.svelte';
|
|
13
|
+
export { default as InkPage } from './components/InkPage.svelte';
|
|
14
|
+
export { default as InkAnnotation } from './components/InkAnnotation.svelte';
|
|
15
|
+
export { default as InkToolbar } from './components/InkToolbar.svelte';
|
|
16
|
+
export { default as InkIcon } from './components/InkIcon.svelte';
|
|
17
|
+
export { default as InkToolButton } from './components/InkToolButton.svelte';
|
|
18
|
+
export { default as InkToolbarSeparator } from './components/InkToolbarSeparator.svelte';
|
|
19
|
+
export { default as InkUndo } from './components/InkUndo.svelte';
|
|
20
|
+
export { default as InkRedo } from './components/InkRedo.svelte';
|
|
21
|
+
export { default as InkZoomIn } from './components/InkZoomIn.svelte';
|
|
22
|
+
export { default as InkZoomOut } from './components/InkZoomOut.svelte';
|
|
23
|
+
export { default as InkZoomSelect } from './components/InkZoomSelect.svelte';
|
|
24
|
+
export { default as InkPageInput } from './components/InkPageInput.svelte';
|
|
25
|
+
export { default as InkPageCount } from './components/InkPageCount.svelte';
|
|
26
|
+
export { default as InkPrevPage } from './components/InkPrevPage.svelte';
|
|
27
|
+
export { default as InkNextPage } from './components/InkNextPage.svelte';
|
|
28
|
+
export { default as InkNotePopover } from './components/InkNotePopover.svelte';
|
|
29
|
+
export { default as InkSuggestionCard } from './components/InkSuggestionCard.svelte';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Readable } from '@inkbar/core';
|
|
2
|
+
export interface ReadableRef<T> {
|
|
3
|
+
readonly current: T;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Mirrors a core `Readable` into Svelte. `source` is a getter, so a readable that appears later
|
|
7
|
+
* (the document's status once it opens) is followed, and a change of source re-subscribes.
|
|
8
|
+
* `fromStore` reads synchronously when nothing is tracking, so the first render shows the
|
|
9
|
+
* readable's value rather than `fallback`; under an effect or template it subscribes through
|
|
10
|
+
* `createSubscriber`, so subscriptions start and stop with the readers.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useReadable<T>(source: () => Readable<T> | null | undefined, fallback: T): ReadableRef<T>;
|
|
13
|
+
//# sourceMappingURL=use-readable.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-readable.svelte.d.ts","sourceRoot":"","sources":["../src/lib/use-readable.svelte.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAE5C,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA;CACpB;AAYD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,MAAM,EAAE,MAAM,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,EAC5C,QAAQ,EAAE,CAAC,GACV,WAAW,CAAC,CAAC,CAAC,CAUhB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { fromStore } from 'svelte/store';
|
|
2
|
+
/** Core's `subscribe` does not call back with the current value; Svelte's store contract does. */
|
|
3
|
+
function asStore(source) {
|
|
4
|
+
return {
|
|
5
|
+
subscribe(run) {
|
|
6
|
+
run(source.get());
|
|
7
|
+
return source.subscribe(run);
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Mirrors a core `Readable` into Svelte. `source` is a getter, so a readable that appears later
|
|
13
|
+
* (the document's status once it opens) is followed, and a change of source re-subscribes.
|
|
14
|
+
* `fromStore` reads synchronously when nothing is tracking, so the first render shows the
|
|
15
|
+
* readable's value rather than `fallback`; under an effect or template it subscribes through
|
|
16
|
+
* `createSubscriber`, so subscriptions start and stop with the readers.
|
|
17
|
+
*/
|
|
18
|
+
export function useReadable(source, fallback) {
|
|
19
|
+
const store = $derived.by(() => {
|
|
20
|
+
const s = source();
|
|
21
|
+
return s ? fromStore(asStore(s)) : null;
|
|
22
|
+
});
|
|
23
|
+
return {
|
|
24
|
+
get current() {
|
|
25
|
+
return store ? store.current : fallback;
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,59 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkbar/svelte",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Svelte 5 components and hooks for Inkbar, the browser PDF viewer and editor.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://inkbar.dev",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/inkbar/inkbar.git",
|
|
10
|
+
"directory": "packages/svelte"
|
|
11
|
+
},
|
|
12
|
+
"bugs": "https://github.com/inkbar/inkbar/issues",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"sideEffects": false,
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"svelte": "./dist/index.js",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"svelte": "./dist/index.js",
|
|
24
|
+
"default": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./package.json": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@inkbar/icons": "^0.2.0",
|
|
30
|
+
"@internationalized/date": "^3.12.4",
|
|
31
|
+
"bits-ui": "^2.19.5",
|
|
32
|
+
"esm-env": "^1.2.0"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@inkbar/core": "^0.2.0",
|
|
36
|
+
"svelte": "^5.46.4"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@inkbar/core": "0.2.0",
|
|
40
|
+
"@inkbar/fixtures": "0.0.0",
|
|
41
|
+
"@inkbar/theme": "0.2.0",
|
|
42
|
+
"@sveltejs/package": "^3.0.0",
|
|
43
|
+
"@sveltejs/vite-plugin-svelte": "^7.3.1",
|
|
44
|
+
"@vitest/browser-playwright": "^5.0.4",
|
|
45
|
+
"playwright": "1.62.1",
|
|
46
|
+
"svelte": "^5.57.2",
|
|
47
|
+
"svelte-check": "^4.7.6",
|
|
48
|
+
"vite": "^8.3.4",
|
|
49
|
+
"vitest": "^5.0.4",
|
|
50
|
+
"vitest-browser-svelte": "^3.1.0"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "svelte-package -i src/lib -o dist",
|
|
54
|
+
"typecheck": "svelte-check --tsconfig ./tsconfig.json",
|
|
55
|
+
"lint": "eslint src",
|
|
56
|
+
"test": "vitest run --project node",
|
|
57
|
+
"test:browser": "vitest run --project browser"
|
|
58
|
+
}
|
|
6
59
|
}
|