@seedprotocol/react 0.4.15
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/dist/OPFSFilesManager.d.ts +45 -0
- package/dist/OPFSFilesManager.d.ts.map +1 -0
- package/dist/OPFSImage.d.ts +7 -0
- package/dist/OPFSImage.d.ts.map +1 -0
- package/dist/SeedClientGate.d.ts +28 -0
- package/dist/SeedClientGate.d.ts.map +1 -0
- package/dist/SeedImage.d.ts +13 -0
- package/dist/SeedImage.d.ts.map +1 -0
- package/dist/SeedProvider.d.ts +30 -0
- package/dist/SeedProvider.d.ts.map +1 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/db.d.ts +4 -0
- package/dist/db.d.ts.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1988 -0
- package/dist/index.js.map +1 -0
- package/dist/item.d.ts +42 -0
- package/dist/item.d.ts.map +1 -0
- package/dist/itemProperty.d.ts +116 -0
- package/dist/itemProperty.d.ts.map +1 -0
- package/dist/liveQuery.d.ts +29 -0
- package/dist/liveQuery.d.ts.map +1 -0
- package/dist/model.d.ts +48 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/modelProperty.d.ts +82 -0
- package/dist/modelProperty.d.ts.map +1 -0
- package/dist/queryClient.d.ts +28 -0
- package/dist/queryClient.d.ts.map +1 -0
- package/dist/schema.d.ts +45 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/services.d.ts +24 -0
- package/dist/services.d.ts.map +1 -0
- package/dist/trash.d.ts +9 -0
- package/dist/trash.d.ts.map +1 -0
- package/dist/useFiles.d.ts +22 -0
- package/dist/useFiles.d.ts.map +1 -0
- package/dist/useImageFiles.d.ts +19 -0
- package/dist/useImageFiles.d.ts.map +1 -0
- package/dist/useOPFSFiles.d.ts +27 -0
- package/dist/useOPFSFiles.d.ts.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { OPFSFile } from './useOPFSFiles';
|
|
2
|
+
export type OPFSFilesManagerTheme = 'light' | 'dark';
|
|
3
|
+
export interface OPFSFilesManagerProps {
|
|
4
|
+
/** Optional subdirectory to scan (e.g. 'app-files'). Default: root. */
|
|
5
|
+
rootPath?: string;
|
|
6
|
+
/** Filter which files to include. */
|
|
7
|
+
filter?: (file: OPFSFile) => boolean;
|
|
8
|
+
/** Called when a file is about to be deleted. Return false to cancel. */
|
|
9
|
+
onBeforeDelete?: (file: OPFSFile) => boolean | Promise<boolean>;
|
|
10
|
+
/** Called after a file or files are deleted. Use for clearing app state (e.g. Seed DB). */
|
|
11
|
+
onAfterDelete?: (paths: string[]) => void | Promise<void>;
|
|
12
|
+
/** Custom download handler (e.g. Electron). If not provided, uses browser blob download. */
|
|
13
|
+
onDownload?: (file: OPFSFile, blob: Blob) => void | Promise<void>;
|
|
14
|
+
/** Title for the page. Default: "Files" */
|
|
15
|
+
title?: string;
|
|
16
|
+
/** Description text. Default: OPFS description. */
|
|
17
|
+
description?: string;
|
|
18
|
+
/** Visual theme. Default: "dark" */
|
|
19
|
+
theme?: OPFSFilesManagerTheme;
|
|
20
|
+
/** Class for the container. */
|
|
21
|
+
className?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A React component to browse, download, and delete files stored in OPFS.
|
|
25
|
+
* Useful for debugging and managing Origin Private File System storage.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* <OPFSFilesManager
|
|
30
|
+
* onAfterDelete={(paths) => {
|
|
31
|
+
* if (paths.some(isSeedDbPath)) {
|
|
32
|
+
* clearSeedDependentData()
|
|
33
|
+
* window.location.reload()
|
|
34
|
+
* }
|
|
35
|
+
* }}
|
|
36
|
+
* onDownload={async (file, blob) => {
|
|
37
|
+
* if (window.electron?.downloadFile) {
|
|
38
|
+
* await window.electron.downloadFile({ data: await blob.arrayBuffer(), filename: file.name })
|
|
39
|
+
* }
|
|
40
|
+
* }}
|
|
41
|
+
* />
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function OPFSFilesManager({ rootPath, filter, onBeforeDelete, onAfterDelete, onDownload, title, description, theme, className, }: OPFSFilesManagerProps): import("react/jsx-runtime").JSX.Element;
|
|
45
|
+
//# sourceMappingURL=OPFSFilesManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OPFSFilesManager.d.ts","sourceRoot":"","sources":["../src/OPFSFilesManager.tsx"],"names":[],"mappings":"AACA,OAAO,EAAgB,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAwF5D,MAAM,MAAM,qBAAqB,GAAG,OAAO,GAAG,MAAM,CAAA;AAEpD,MAAM,WAAW,qBAAqB;IACpC,uEAAuE;IACvE,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,qCAAqC;IACrC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO,CAAA;IACpC,yEAAyE;IACzE,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAC/D,2FAA2F;IAC3F,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACzD,4FAA4F;IAC5F,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACjE,2CAA2C;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,mDAAmD;IACnD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,oCAAoC;IACpC,KAAK,CAAC,EAAE,qBAAqB,CAAA;IAC7B,+BAA+B;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAuED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,MAAM,EACN,cAAc,EACd,aAAa,EACb,UAAU,EACV,KAAe,EACf,WAA8F,EAC9F,KAAc,EACd,SAAS,GACV,EAAE,qBAAqB,2CA2RvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OPFSImage.d.ts","sourceRoot":"","sources":["../src/OPFSImage.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAuB,cAAc,EAAE,MAAM,OAAO,CAAC;AAKnE,KAAK,cAAc,GAAG,cAAc,CAAC,gBAAgB,CAAC,GAAG;IACrD,QAAQ,EAAE,MAAM,CAAC;CACpB,CAAC;AAGF,QAAA,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAyEvC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { SeedConstructorOptions, SchemaFileFormat } from '@seedprotocol/sdk';
|
|
3
|
+
/** Schema input: path string or SchemaFileFormat object. Merged into config.schema at init. */
|
|
4
|
+
type SchemaInput = string | SchemaFileFormat;
|
|
5
|
+
export type SeedClientGateProps = {
|
|
6
|
+
/** Seed client init options (config + addresses). Required. */
|
|
7
|
+
initConfig: SeedConstructorOptions;
|
|
8
|
+
/** Optional canonical schema. When provided, merged into config.schema and loaded at init (no separate import). */
|
|
9
|
+
schema?: SchemaInput;
|
|
10
|
+
/** Custom loading UI. Default: simple centered "Loading..." text. */
|
|
11
|
+
loadingComponent?: ReactNode;
|
|
12
|
+
/** @deprecated Schema is now loaded at init via config.schema; no separate import. Kept for backward compatibility. */
|
|
13
|
+
onSchemaImportError?: (err: unknown) => void;
|
|
14
|
+
/** Class for the root wrapper. e.g. "relative flex h-screen w-screen" */
|
|
15
|
+
wrapperClassName?: string;
|
|
16
|
+
/** Class for the loading overlay. e.g. "absolute inset-0 z-50 flex items-center justify-center bg-zinc-950" */
|
|
17
|
+
loadingClassName?: string;
|
|
18
|
+
children: ReactNode;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Gates children until the Seed client is initialized and optionally imports a schema.
|
|
22
|
+
* Mounted inside RouterProvider so we never swap the router—only the route content.
|
|
23
|
+
* This avoids removeChild DOM errors and ensures QueryClientProvider stays stable.
|
|
24
|
+
* Both overlay and content stay in DOM; we only toggle visibility via classes.
|
|
25
|
+
*/
|
|
26
|
+
export declare function SeedClientGate({ initConfig, schema, loadingComponent, wrapperClassName, loadingClassName, children, }: SeedClientGateProps): import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=SeedClientGate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SeedClientGate.d.ts","sourceRoot":"","sources":["../src/SeedClientGate.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAa,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAExD,OAAO,KAAK,EAAE,sBAAsB,EAAc,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAG7F,+FAA+F;AAC/F,KAAK,WAAW,GAAG,MAAM,GAAG,gBAAgB,CAAA;AAkB5C,MAAM,MAAM,mBAAmB,GAAG;IAChC,+DAA+D;IAC/D,UAAU,EAAE,sBAAsB,CAAA;IAClC,mHAAmH;IACnH,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,qEAAqE;IACrE,gBAAgB,CAAC,EAAE,SAAS,CAAA;IAC5B,uHAAuH;IACvH,mBAAmB,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAA;IAC5C,yEAAyE;IACzE,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,+GAA+G;IAC/G,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,EAAE,SAAS,CAAA;CACpB,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,EAC7B,UAAU,EACV,MAAM,EACN,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,QAAQ,GACT,EAAE,mBAAmB,2CAqDrB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { default as React, DetailedHTMLProps, ImgHTMLAttributes } from 'react';
|
|
2
|
+
import { ItemProperty } from '@seedprotocol/sdk';
|
|
3
|
+
type SeedImageProps = DetailedHTMLProps<ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement> & {
|
|
4
|
+
imageProperty: ItemProperty<any>;
|
|
5
|
+
alt?: string;
|
|
6
|
+
width?: number;
|
|
7
|
+
height?: number;
|
|
8
|
+
/** Optional filename override when property hasn't resolved yet (e.g. in tests) */
|
|
9
|
+
filename?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const SeedImage: React.MemoExoticComponent<({ imageProperty, width, filename: filenameOverride, ...props }: SeedImageProps) => React.ReactNode>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=SeedImage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SeedImage.d.ts","sourceRoot":"","sources":["../src/SeedImage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAuB,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAIxF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AA0ChD,KAAK,cAAc,GAAG,iBAAiB,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC,GAAG;IAC/F,aAAa,EAAE,YAAY,CAAC,GAAG,CAAC,CAAA;IAChC,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,mFAAmF;IACnF,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAmJD,eAAO,MAAM,SAAS,6FAjJkE,cAAc,KAAG,KAAK,CAAC,SAAS,CAqJvH,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { default as React, ReactNode } from 'react';
|
|
2
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
3
|
+
export type SeedProviderProps = {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
/** Optional: use your own QueryClient. If not provided, a default client with Seed options is created. */
|
|
6
|
+
queryClient?: QueryClient;
|
|
7
|
+
/** Optional: ref to receive the QueryClient instance (e.g. for tests). */
|
|
8
|
+
queryClientRef?: React.MutableRefObject<QueryClient | null>;
|
|
9
|
+
};
|
|
10
|
+
declare global {
|
|
11
|
+
interface Window {
|
|
12
|
+
__SEED_INVALIDATE_ITEM_PROPERTIES__?: ((canonicalId: string) => void) | null;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Invalidates and refetches the item-properties query for an item.
|
|
17
|
+
* Call this after updating an ItemProperty (e.g. after save()) so useItemProperties
|
|
18
|
+
* refetches and the UI updates. Returns a Promise that resolves when the refetch has completed (if available).
|
|
19
|
+
*/
|
|
20
|
+
export declare function invalidateItemPropertiesForItem(canonicalId: string): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Provider that supplies a React Query client to Seed list hooks (useSchemas, useItems, useModels, etc.)
|
|
23
|
+
* so results are cached and shared across components. Wrap your app (or the subtree that uses Seed hooks)
|
|
24
|
+
* after calling client.init().
|
|
25
|
+
*
|
|
26
|
+
* - No props: uses an internal QueryClient with Seed defaults.
|
|
27
|
+
* - queryClient prop: use your own client (e.g. merge getSeedQueryDefaultOptions when creating it).
|
|
28
|
+
*/
|
|
29
|
+
export declare function SeedProvider({ children, queryClient: queryClientProp, queryClientRef }: SeedProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
//# sourceMappingURL=SeedProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SeedProvider.d.ts","sourceRoot":"","sources":["../src/SeedProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,KAAK,SAAS,EAAsB,MAAM,OAAO,CAAA;AAEjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAIxD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,SAAS,CAAA;IACnB,0GAA0G;IAC1G,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,0EAA0E;IAC1E,cAAc,CAAC,EAAE,KAAK,CAAC,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;CAC5D,CAAA;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,mCAAmC,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,IAAI,CAAA;KAC7E;CACF;AAKD;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMlF;AA+BD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,EAAE,cAAc,EAAE,EAAE,iBAAiB,2CAuBzG"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,gBAAgB,eAW5B,CAAA"}
|
package/dist/db.d.ts
ADDED
package/dist/db.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../src/db.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,cAAc;;CAuD1B,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export * from './item';
|
|
2
|
+
export * from './itemProperty';
|
|
3
|
+
export * from './services';
|
|
4
|
+
export * from './db';
|
|
5
|
+
export * from './schema';
|
|
6
|
+
export * from './modelProperty';
|
|
7
|
+
export { useDeleteItem } from './trash';
|
|
8
|
+
export { useImageFiles } from './useImageFiles';
|
|
9
|
+
export { useFiles, FILES_QUERY_KEY_PREFIX } from './useFiles';
|
|
10
|
+
export { useModels, useModel, useCreateModel, useDestroyModel } from './model';
|
|
11
|
+
export { useLiveQuery } from './liveQuery';
|
|
12
|
+
export { SeedProvider, invalidateItemPropertiesForItem } from './SeedProvider';
|
|
13
|
+
export type { SeedProviderProps } from './SeedProvider';
|
|
14
|
+
export { SeedClientGate } from './SeedClientGate';
|
|
15
|
+
export type { SeedClientGateProps } from './SeedClientGate';
|
|
16
|
+
export { OPFSFilesManager } from './OPFSFilesManager';
|
|
17
|
+
export type { OPFSFilesManagerProps, OPFSFilesManagerTheme } from './OPFSFilesManager';
|
|
18
|
+
export { useOPFSFiles } from './useOPFSFiles';
|
|
19
|
+
export type { OPFSFile, UseOPFSFilesOptions } from './useOPFSFiles';
|
|
20
|
+
export { createSeedQueryClient, getSeedQueryDefaultOptions, mergeSeedQueryDefaults, } from './queryClient';
|
|
21
|
+
export { SeedImage } from './SeedImage';
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,MAAM,CAAA;AACpB,cAAc,UAAU,CAAA;AACxB,cAAc,iBAAiB,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAC7D,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,+BAA+B,EAAE,MAAM,gBAAgB,CAAA;AAC9E,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,YAAY,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AACtF,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,YAAY,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACnE,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA"}
|