@inkbar/svelte 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +154 -2
  3. package/dist/class-names.d.ts +3 -0
  4. package/dist/class-names.d.ts.map +1 -0
  5. package/dist/class-names.js +5 -0
  6. package/dist/components/InkAnnotation.svelte +73 -0
  7. package/dist/components/InkAnnotation.svelte.d.ts +13 -0
  8. package/dist/components/InkAnnotation.svelte.d.ts.map +1 -0
  9. package/dist/components/InkNotePopover.svelte +193 -0
  10. package/dist/components/InkNotePopover.svelte.d.ts +9 -0
  11. package/dist/components/InkNotePopover.svelte.d.ts.map +1 -0
  12. package/dist/components/InkPage.svelte +125 -0
  13. package/dist/components/InkPage.svelte.d.ts +22 -0
  14. package/dist/components/InkPage.svelte.d.ts.map +1 -0
  15. package/dist/components/InkPageCount.svelte +20 -0
  16. package/dist/components/InkPageCount.svelte.d.ts +6 -0
  17. package/dist/components/InkPageCount.svelte.d.ts.map +1 -0
  18. package/dist/components/InkPageInput.svelte +49 -0
  19. package/dist/components/InkPageInput.svelte.d.ts +6 -0
  20. package/dist/components/InkPageInput.svelte.d.ts.map +1 -0
  21. package/dist/components/InkRoot.svelte +358 -0
  22. package/dist/components/InkRoot.svelte.d.ts +51 -0
  23. package/dist/components/InkRoot.svelte.d.ts.map +1 -0
  24. package/dist/components/InkSuggestionCard.svelte +121 -0
  25. package/dist/components/InkSuggestionCard.svelte.d.ts +9 -0
  26. package/dist/components/InkSuggestionCard.svelte.d.ts.map +1 -0
  27. package/dist/components/InkToolButton.svelte +54 -0
  28. package/dist/components/InkToolButton.svelte.d.ts +17 -0
  29. package/dist/components/InkToolButton.svelte.d.ts.map +1 -0
  30. package/dist/components/InkToolbar.svelte +40 -0
  31. package/dist/components/InkToolbar.svelte.d.ts +13 -0
  32. package/dist/components/InkToolbar.svelte.d.ts.map +1 -0
  33. package/dist/components/InkViewport.svelte +306 -0
  34. package/dist/components/InkViewport.svelte.d.ts +27 -0
  35. package/dist/components/InkViewport.svelte.d.ts.map +1 -0
  36. package/dist/components/InkZoomIn.svelte +34 -0
  37. package/dist/components/InkZoomIn.svelte.d.ts +5 -0
  38. package/dist/components/InkZoomIn.svelte.d.ts.map +1 -0
  39. package/dist/components/InkZoomOut.svelte +34 -0
  40. package/dist/components/InkZoomOut.svelte.d.ts +5 -0
  41. package/dist/components/InkZoomOut.svelte.d.ts.map +1 -0
  42. package/dist/components/InkZoomSelect.svelte +56 -0
  43. package/dist/components/InkZoomSelect.svelte.d.ts +6 -0
  44. package/dist/components/InkZoomSelect.svelte.d.ts.map +1 -0
  45. package/dist/components/ThreadForm.svelte +42 -0
  46. package/dist/components/ThreadForm.svelte.d.ts +11 -0
  47. package/dist/components/ThreadForm.svelte.d.ts.map +1 -0
  48. package/dist/components/annotation-element.svelte.d.ts +9 -0
  49. package/dist/components/annotation-element.svelte.d.ts.map +1 -0
  50. package/dist/components/annotation-element.svelte.js +25 -0
  51. package/dist/components/child-snippet.d.ts +22 -0
  52. package/dist/components/child-snippet.d.ts.map +1 -0
  53. package/dist/components/child-snippet.js +14 -0
  54. package/dist/components/popover-focus.d.ts +33 -0
  55. package/dist/components/popover-focus.d.ts.map +1 -0
  56. package/dist/components/popover-focus.js +63 -0
  57. package/dist/components/portal.d.ts +26 -0
  58. package/dist/components/portal.d.ts.map +1 -0
  59. package/dist/components/portal.js +55 -0
  60. package/dist/components/zoom-button.d.ts +10 -0
  61. package/dist/components/zoom-button.d.ts.map +1 -0
  62. package/dist/components/zoom-button.js +1 -0
  63. package/dist/compositions/DefaultToolbar.svelte +90 -0
  64. package/dist/compositions/DefaultToolbar.svelte.d.ts +10 -0
  65. package/dist/compositions/DefaultToolbar.svelte.d.ts.map +1 -0
  66. package/dist/context.d.ts +57 -0
  67. package/dist/context.d.ts.map +1 -0
  68. package/dist/context.js +34 -0
  69. package/dist/hooks/useAnnotations.svelte.d.ts +1683 -0
  70. package/dist/hooks/useAnnotations.svelte.d.ts.map +1 -0
  71. package/dist/hooks/useAnnotations.svelte.js +33 -0
  72. package/dist/hooks/useDocument.svelte.d.ts +12 -0
  73. package/dist/hooks/useDocument.svelte.d.ts.map +1 -0
  74. package/dist/hooks/useDocument.svelte.js +28 -0
  75. package/dist/hooks/useEmbedded.svelte.d.ts +7 -0
  76. package/dist/hooks/useEmbedded.svelte.d.ts.map +1 -0
  77. package/dist/hooks/useEmbedded.svelte.js +17 -0
  78. package/dist/hooks/useHistory.svelte.d.ts +7 -0
  79. package/dist/hooks/useHistory.svelte.d.ts.map +1 -0
  80. package/dist/hooks/useHistory.svelte.js +8 -0
  81. package/dist/hooks/usePage.svelte.d.ts +10 -0
  82. package/dist/hooks/usePage.svelte.d.ts.map +1 -0
  83. package/dist/hooks/usePage.svelte.js +29 -0
  84. package/dist/hooks/useSelection.svelte.d.ts +6 -0
  85. package/dist/hooks/useSelection.svelte.d.ts.map +1 -0
  86. package/dist/hooks/useSelection.svelte.js +12 -0
  87. package/dist/hooks/useTool.svelte.d.ts +6 -0
  88. package/dist/hooks/useTool.svelte.d.ts.map +1 -0
  89. package/dist/hooks/useTool.svelte.js +10 -0
  90. package/dist/hooks/useZoom.svelte.d.ts +9 -0
  91. package/dist/hooks/useZoom.svelte.d.ts.map +1 -0
  92. package/dist/hooks/useZoom.svelte.js +18 -0
  93. package/dist/index.d.ts +45 -0
  94. package/dist/index.d.ts.map +1 -0
  95. package/dist/index.js +24 -0
  96. package/dist/use-readable.svelte.d.ts +13 -0
  97. package/dist/use-readable.svelte.d.ts.map +1 -0
  98. package/dist/use-readable.svelte.js +28 -0
  99. 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;AA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBACf,MAAM,SAAS,OAAO,CAAC,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAClC,MAAM;kBACL,MAAM,EAAE;IACtB,sFAAsF;iBACzE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,7 @@
1
+ import type { EmbeddedSummary } from '@inkbar/core';
2
+ export declare function useEmbedded(): {
3
+ readonly summary: readonly EmbeddedSummary[];
4
+ readonly total: number;
5
+ readonly hasAny: boolean;
6
+ };
7
+ //# sourceMappingURL=useEmbedded.svelte.d.ts.map
@@ -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,6 @@
1
+ export declare function useSelection(): {
2
+ readonly selection: readonly string[];
3
+ select: (ids: string[]) => void | undefined;
4
+ clear: () => void | undefined;
5
+ };
6
+ //# sourceMappingURL=useSelection.svelte.d.ts.map
@@ -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,6 @@
1
+ import type { ToolId } from '@inkbar/core/dom';
2
+ export declare function useTool(): {
3
+ readonly tool: ToolId;
4
+ setTool: (id: ToolId) => void;
5
+ };
6
+ //# sourceMappingURL=useTool.svelte.d.ts.map
@@ -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,10 @@
1
+ import { useInkContext } from '../context.js';
2
+ export function useTool() {
3
+ const ctx = useInkContext('useTool()');
4
+ return {
5
+ get tool() {
6
+ return ctx.tool;
7
+ },
8
+ setTool: (id) => ctx.setTool(id),
9
+ };
10
+ }
@@ -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
+ }
@@ -0,0 +1,45 @@
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 InkToolButton } from './components/InkToolButton.svelte';
28
+ export type { InkToolButtonProps } from './components/InkToolButton.svelte';
29
+ export { default as InkZoomIn } from './components/InkZoomIn.svelte';
30
+ export { default as InkZoomOut } from './components/InkZoomOut.svelte';
31
+ export type { InkZoomButtonProps } from './components/zoom-button.js';
32
+ export { default as InkZoomSelect } from './components/InkZoomSelect.svelte';
33
+ export type { InkZoomSelectProps } from './components/InkZoomSelect.svelte';
34
+ export { default as InkPageInput } from './components/InkPageInput.svelte';
35
+ export type { InkPageInputProps } from './components/InkPageInput.svelte';
36
+ export { default as InkPageCount } from './components/InkPageCount.svelte';
37
+ export type { InkPageCountProps } from './components/InkPageCount.svelte';
38
+ export { default as DefaultToolbar } from './compositions/DefaultToolbar.svelte';
39
+ export type { DefaultToolbarProps } from './compositions/DefaultToolbar.svelte';
40
+ export type { ChildSnippet } from './components/child-snippet.js';
41
+ export { default as InkNotePopover } from './components/InkNotePopover.svelte';
42
+ export type { InkNotePopoverProps } from './components/InkNotePopover.svelte';
43
+ export { default as InkSuggestionCard } from './components/InkSuggestionCard.svelte';
44
+ export type { InkSuggestionCardProps } from './components/InkSuggestionCard.svelte';
45
+ //# 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,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAA;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAA;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAC3D,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,6BAA6B,CAAA;AAChE,YAAY,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC/D,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAC/D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,iCAAiC,CAAA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OAAO,IAAI,cAAc,EAAE,MAAM,oCAAoC,CAAA;AAC9E,YAAY,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,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,24 @@
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 InkToolButton } from './components/InkToolButton.svelte';
17
+ export { default as InkZoomIn } from './components/InkZoomIn.svelte';
18
+ export { default as InkZoomOut } from './components/InkZoomOut.svelte';
19
+ export { default as InkZoomSelect } from './components/InkZoomSelect.svelte';
20
+ export { default as InkPageInput } from './components/InkPageInput.svelte';
21
+ export { default as InkPageCount } from './components/InkPageCount.svelte';
22
+ export { default as DefaultToolbar } from './compositions/DefaultToolbar.svelte';
23
+ export { default as InkNotePopover } from './components/InkNotePopover.svelte';
24
+ 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.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.1",
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
+ "@internationalized/date": "^3.12.4",
30
+ "@lucide/svelte": "^1.56.0",
31
+ "bits-ui": "^2.19.5",
32
+ "esm-env": "^1.2.0"
33
+ },
34
+ "peerDependencies": {
35
+ "@inkbar/core": "^0.1.1",
36
+ "svelte": "^5.46.4"
37
+ },
38
+ "devDependencies": {
39
+ "@inkbar/core": "0.1.1",
40
+ "@inkbar/fixtures": "0.0.0",
41
+ "@inkbar/theme": "0.1.1",
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
  }