@soppiya/app-bridge 1.0.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/README.md +23 -0
- package/dist/assets/images/docs.js +2 -0
- package/dist/assets/images/document.js +2 -0
- package/dist/assets/images/pdf.js +2 -0
- package/dist/assets/images/play.js +2 -0
- package/dist/assets/images/ppt.js +2 -0
- package/dist/assets/images/rar.js +2 -0
- package/dist/assets/images/sound.js +2 -0
- package/dist/assets/images/txt.js +2 -0
- package/dist/assets/images/xls.js +2 -0
- package/dist/assets/images/zip.js +2 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +3 -0
- package/dist/components/infinity-scroll/InfinityScroll.d.ts +5 -0
- package/dist/components/infinity-scroll/InfinityScroll.js +29 -0
- package/dist/components/infinity-scroll/index.d.ts +1 -0
- package/dist/components/infinity-scroll/index.js +2 -0
- package/dist/components/media/Media.d.ts +11 -0
- package/dist/components/media/Media.js +349 -0
- package/dist/components/media/Media.stories.d.ts +18 -0
- package/dist/components/media/Media.stories.js +13 -0
- package/dist/components/media/MediaItem.d.ts +12 -0
- package/dist/components/media/MediaItem.js +104 -0
- package/dist/components/media/MediaPreview.d.ts +7 -0
- package/dist/components/media/MediaPreview.js +127 -0
- package/dist/components/media/MediaSorting.d.ts +8 -0
- package/dist/components/media/MediaSorting.js +85 -0
- package/dist/components/media/format.d.ts +1 -0
- package/dist/components/media/format.js +28 -0
- package/dist/components/media/graph.d.ts +22 -0
- package/dist/components/media/graph.js +75 -0
- package/dist/components/media/index.d.ts +1 -0
- package/dist/components/media/index.js +2 -0
- package/dist/components/media/types.d.ts +13 -0
- package/dist/components/media/types.js +6 -0
- package/dist/components/media/uploadMedias.d.ts +7 -0
- package/dist/components/media/uploadMedias.js +31 -0
- package/dist/components/media/useDeleteMedias.d.ts +7 -0
- package/dist/components/media/useDeleteMedias.js +14 -0
- package/dist/components/media/useDrop.d.ts +11 -0
- package/dist/components/media/useDrop.js +41 -0
- package/dist/components/media/useMediaFilter.d.ts +5 -0
- package/dist/components/media/useMediaFilter.js +15 -0
- package/dist/components/media/useMediaSorting.d.ts +6 -0
- package/dist/components/media/useMediaSorting.js +19 -0
- package/dist/components/media/useMedias.d.ts +31 -0
- package/dist/components/media/useMedias.js +58 -0
- package/dist/components/media/useStorage.d.ts +8 -0
- package/dist/components/media/useStorage.js +17 -0
- package/dist/components/media/useThumbnail.d.ts +5 -0
- package/dist/components/media/useThumbnail.js +64 -0
- package/dist/components/savebar/SaveBar.d.ts +9 -0
- package/dist/components/savebar/SaveBar.js +21 -0
- package/dist/components/savebar/index.d.ts +1 -0
- package/dist/components/savebar/index.js +2 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/useSoppiyaBridge.d.ts +3 -0
- package/dist/hooks/useSoppiyaBridge.js +9 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/shared/graphql/fragment-masking.d.ts +19 -0
- package/dist/shared/graphql/fragment-masking.js +15 -0
- package/dist/shared/graphql/gql.d.ts +56 -0
- package/dist/shared/graphql/gql.js +12 -0
- package/dist/shared/graphql/graphql.d.ts +3881 -0
- package/dist/shared/graphql/graphql.js +1226 -0
- package/dist/shared/graphql/index.d.ts +2 -0
- package/dist/shared/graphql/index.js +2 -0
- package/dist/static/image/docs.png +0 -0
- package/dist/static/image/document.png +0 -0
- package/dist/static/image/pdf.png +0 -0
- package/dist/static/image/play.png +0 -0
- package/dist/static/image/ppt.png +0 -0
- package/dist/static/image/rar.png +0 -0
- package/dist/static/image/sound.png +0 -0
- package/dist/static/image/txt.png +0 -0
- package/dist/static/image/xls.png +0 -0
- package/dist/static/image/zip.png +0 -0
- package/dist/styles.css +869 -0
- package/package.json +66 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useQuery } from "@apollo/client/react";
|
|
2
|
+
import { mediaUsagesQuery, storagePlanQuery } from "./graph.js";
|
|
3
|
+
const useStorage = ()=>{
|
|
4
|
+
const { data } = useQuery(storagePlanQuery);
|
|
5
|
+
const { data: mediaUsageData, refetch: refetchMediaUsage } = useQuery(mediaUsagesQuery);
|
|
6
|
+
const plan = data?.plan;
|
|
7
|
+
const totalStorage = ((plan?.storage ?? 0) + (plan?.package?.storage ?? 0)) * 1048576;
|
|
8
|
+
const mediaUsage = Number(mediaUsageData?.mediaUsage ?? 0);
|
|
9
|
+
const usageStorage = mediaUsage / totalStorage * 100;
|
|
10
|
+
return {
|
|
11
|
+
mediaUsage,
|
|
12
|
+
totalStorage,
|
|
13
|
+
usageStorage,
|
|
14
|
+
refetchMediaUsage
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export { useStorage };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import docs from "../../assets/images/docs.js";
|
|
2
|
+
import pdf from "../../assets/images/pdf.js";
|
|
3
|
+
import ppt from "../../assets/images/ppt.js";
|
|
4
|
+
import rar from "../../assets/images/rar.js";
|
|
5
|
+
import sound from "../../assets/images/sound.js";
|
|
6
|
+
import txt from "../../assets/images/txt.js";
|
|
7
|
+
import xls from "../../assets/images/xls.js";
|
|
8
|
+
import zip from "../../assets/images/zip.js";
|
|
9
|
+
import { useEffect, useState } from "react";
|
|
10
|
+
const useThumbnail = (media, seekTo = 1)=>{
|
|
11
|
+
const [url, setUrl] = useState(media?.url);
|
|
12
|
+
const [loading, setLoading] = useState(false);
|
|
13
|
+
useEffect(()=>{
|
|
14
|
+
switch(media?.type){
|
|
15
|
+
case "video":
|
|
16
|
+
{
|
|
17
|
+
setLoading(true);
|
|
18
|
+
const video = document.createElement("video");
|
|
19
|
+
video.preload = "auto";
|
|
20
|
+
video.muted = true;
|
|
21
|
+
video.crossOrigin = "anonymous";
|
|
22
|
+
video.src = String(media?.url);
|
|
23
|
+
video.onloadeddata = ()=>{
|
|
24
|
+
video.currentTime = seekTo;
|
|
25
|
+
};
|
|
26
|
+
video.onseeked = ()=>{
|
|
27
|
+
const canvas = document.createElement("canvas");
|
|
28
|
+
canvas.width = video.videoWidth;
|
|
29
|
+
canvas.height = video.videoHeight;
|
|
30
|
+
const ctx = canvas.getContext("2d");
|
|
31
|
+
if (!ctx) return;
|
|
32
|
+
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
|
|
33
|
+
const imageUrl = canvas.toDataURL("image/png");
|
|
34
|
+
setUrl(imageUrl);
|
|
35
|
+
setLoading(false);
|
|
36
|
+
};
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
case "audio":
|
|
40
|
+
setUrl(sound);
|
|
41
|
+
break;
|
|
42
|
+
case "file":
|
|
43
|
+
setUrl(()=>{
|
|
44
|
+
if (media?.mimetype?.includes("pdf")) return pdf;
|
|
45
|
+
if (media?.mimetype?.includes("vnd.openxmlformats-officedocument.spreadsheetml.sheet") || media?.mimetype?.includes("vnd.ms-excel")) return xls;
|
|
46
|
+
if (media?.mimetype?.includes("x-zip-compressed")) return zip;
|
|
47
|
+
if (media?.mimetype?.includes("x-compressed")) return rar;
|
|
48
|
+
if (media?.mimetype?.includes("text/plain") || media?.mimetype?.includes("rtf")) return txt;
|
|
49
|
+
else if (media?.mimetype?.includes("vnd.openxmlformats-officedocument.presentationml.presentation") || media?.mimetype?.includes("vnd.ms-powerpoint")) return ppt;
|
|
50
|
+
else if (media?.mimetype?.includes("vnd.openxmlformats-officedocument.wordprocessingml.document") || media?.mimetype?.includes("msword")) return docs;
|
|
51
|
+
});
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
if (media?.type !== "video") return;
|
|
55
|
+
}, [
|
|
56
|
+
media,
|
|
57
|
+
seekTo
|
|
58
|
+
]);
|
|
59
|
+
return {
|
|
60
|
+
url,
|
|
61
|
+
loading
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
export { useThumbnail };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface IProps {
|
|
2
|
+
open?: boolean;
|
|
3
|
+
confirmationOnLeave?: boolean;
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
onShow?: () => void;
|
|
6
|
+
onHide?: () => void;
|
|
7
|
+
}
|
|
8
|
+
declare const SaveBar: ({ open, confirmationOnLeave, children, onHide, onShow, }: IProps) => null;
|
|
9
|
+
export default SaveBar;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
const SaveBar = ({ open, confirmationOnLeave, children, onHide, onShow })=>{
|
|
3
|
+
useEffect(()=>{
|
|
4
|
+
window.initSaveBar({
|
|
5
|
+
open,
|
|
6
|
+
children: open ? children : null,
|
|
7
|
+
confirmationOnLeave,
|
|
8
|
+
onShow,
|
|
9
|
+
onHide
|
|
10
|
+
});
|
|
11
|
+
}, [
|
|
12
|
+
open,
|
|
13
|
+
children,
|
|
14
|
+
confirmationOnLeave,
|
|
15
|
+
onShow,
|
|
16
|
+
onHide
|
|
17
|
+
]);
|
|
18
|
+
return null;
|
|
19
|
+
};
|
|
20
|
+
const savebar_SaveBar = SaveBar;
|
|
21
|
+
export { savebar_SaveBar as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as SaveBar } from "./SaveBar";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useSoppiyaBridge } from './useSoppiyaBridge';
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ResultOf, DocumentTypeDecoration, TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
2
|
+
import type { Incremental } from './graphql';
|
|
3
|
+
export type FragmentType<TDocumentType extends DocumentTypeDecoration<any, any>> = TDocumentType extends DocumentTypeDecoration<infer TType, any> ? [TType] extends [{
|
|
4
|
+
' $fragmentName'?: infer TKey;
|
|
5
|
+
}] ? TKey extends string ? {
|
|
6
|
+
' $fragmentRefs'?: {
|
|
7
|
+
[key in TKey]: TType;
|
|
8
|
+
};
|
|
9
|
+
} : never : never : never;
|
|
10
|
+
export declare function useFragment<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: FragmentType<DocumentTypeDecoration<TType, any>>): TType;
|
|
11
|
+
export declare function useFragment<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | undefined): TType | undefined;
|
|
12
|
+
export declare function useFragment<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | null): TType | null;
|
|
13
|
+
export declare function useFragment<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | null | undefined): TType | null | undefined;
|
|
14
|
+
export declare function useFragment<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>>>): Array<TType>;
|
|
15
|
+
export declare function useFragment<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined): Array<TType> | null | undefined;
|
|
16
|
+
export declare function useFragment<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>): ReadonlyArray<TType>;
|
|
17
|
+
export declare function useFragment<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined): ReadonlyArray<TType> | null | undefined;
|
|
18
|
+
export declare function makeFragmentData<F extends DocumentTypeDecoration<any, any>, FT extends ResultOf<F>>(data: FT, _fragment: F): FragmentType<F>;
|
|
19
|
+
export declare function isFragmentReady<TQuery, TFrag>(queryNode: DocumentTypeDecoration<TQuery, any>, fragmentNode: TypedDocumentNode<TFrag>, data: FragmentType<TypedDocumentNode<Incremental<TFrag>, any>> | null | undefined): data is FragmentType<typeof fragmentNode>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function useFragment(_documentNode, fragmentType) {
|
|
2
|
+
return fragmentType;
|
|
3
|
+
}
|
|
4
|
+
function makeFragmentData(data, _fragment) {
|
|
5
|
+
return data;
|
|
6
|
+
}
|
|
7
|
+
function isFragmentReady(queryNode, fragmentNode, data) {
|
|
8
|
+
const deferredFields = queryNode.__meta__?.deferredFields;
|
|
9
|
+
if (!deferredFields) return true;
|
|
10
|
+
const fragDef = fragmentNode.definitions[0];
|
|
11
|
+
const fragName = fragDef?.name?.value;
|
|
12
|
+
const fields = fragName && deferredFields[fragName] || [];
|
|
13
|
+
return fields.length > 0 && fields.every((field)=>data && field in data);
|
|
14
|
+
}
|
|
15
|
+
export { isFragmentReady, makeFragmentData, useFragment };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as types from './graphql';
|
|
2
|
+
import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
|
|
3
|
+
/**
|
|
4
|
+
* Map of all GraphQL operations in the project.
|
|
5
|
+
*
|
|
6
|
+
* This map has several performance disadvantages:
|
|
7
|
+
* 1. It is not tree-shakeable, so it will include all operations in the project.
|
|
8
|
+
* 2. It is not minifiable, so the string of a GraphQL query will be multiple times inside the bundle.
|
|
9
|
+
* 3. It does not support dead code elimination, so it will add unused operations.
|
|
10
|
+
*
|
|
11
|
+
* Therefore it is highly recommended to use the babel or swc plugin for production.
|
|
12
|
+
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
|
|
13
|
+
*/
|
|
14
|
+
type Documents = {
|
|
15
|
+
"\n query Medias(\n $after: ID\n $before: ID\n $first: Int\n $last: Int\n $query: String\n $reverse: Boolean\n $sortKey: MediaSortKeys\n $filterKeys: MediaFilterKeys\n ) {\n medias(\n after: $after\n before: $before\n first: $first\n last: $last\n query: $query\n reverse: $reverse\n sortKey: $sortKey\n filterKeys: $filterKeys\n ) {\n edges {\n node {\n _id\n file_name\n url\n size\n type\n mimetype\n }\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n }\n": typeof types.MediasDocument;
|
|
16
|
+
"\n query StoragePlan {\n plan {\n storage\n package {\n _id\n storage\n }\n }\n }\n": typeof types.StoragePlanDocument;
|
|
17
|
+
"\n query MediaUsage {\n mediaUsage\n }\n": typeof types.MediaUsageDocument;
|
|
18
|
+
"\n mutation AddMedias($input: [Upload!]!) {\n addMedias(input: $input) {\n _id\n file_name\n url\n size\n }\n }\n": typeof types.AddMediasDocument;
|
|
19
|
+
"\n mutation DeleteMedias($cursors: [ID!]!) {\n deleteMedias(cursors: $cursors) {\n message\n }\n }\n": typeof types.DeleteMediasDocument;
|
|
20
|
+
};
|
|
21
|
+
declare const documents: Documents;
|
|
22
|
+
/**
|
|
23
|
+
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
|
24
|
+
*
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* const query = graphql(`query GetUser($id: ID!) { user(id: $id) { name } }`);
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* The query argument is unknown!
|
|
32
|
+
* Please regenerate the types.
|
|
33
|
+
*/
|
|
34
|
+
export declare function graphql(source: string): unknown;
|
|
35
|
+
/**
|
|
36
|
+
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
|
37
|
+
*/
|
|
38
|
+
export declare function graphql(source: "\n query Medias(\n $after: ID\n $before: ID\n $first: Int\n $last: Int\n $query: String\n $reverse: Boolean\n $sortKey: MediaSortKeys\n $filterKeys: MediaFilterKeys\n ) {\n medias(\n after: $after\n before: $before\n first: $first\n last: $last\n query: $query\n reverse: $reverse\n sortKey: $sortKey\n filterKeys: $filterKeys\n ) {\n edges {\n node {\n _id\n file_name\n url\n size\n type\n mimetype\n }\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n }\n"): (typeof documents)["\n query Medias(\n $after: ID\n $before: ID\n $first: Int\n $last: Int\n $query: String\n $reverse: Boolean\n $sortKey: MediaSortKeys\n $filterKeys: MediaFilterKeys\n ) {\n medias(\n after: $after\n before: $before\n first: $first\n last: $last\n query: $query\n reverse: $reverse\n sortKey: $sortKey\n filterKeys: $filterKeys\n ) {\n edges {\n node {\n _id\n file_name\n url\n size\n type\n mimetype\n }\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n }\n"];
|
|
39
|
+
/**
|
|
40
|
+
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
|
41
|
+
*/
|
|
42
|
+
export declare function graphql(source: "\n query StoragePlan {\n plan {\n storage\n package {\n _id\n storage\n }\n }\n }\n"): (typeof documents)["\n query StoragePlan {\n plan {\n storage\n package {\n _id\n storage\n }\n }\n }\n"];
|
|
43
|
+
/**
|
|
44
|
+
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
|
45
|
+
*/
|
|
46
|
+
export declare function graphql(source: "\n query MediaUsage {\n mediaUsage\n }\n"): (typeof documents)["\n query MediaUsage {\n mediaUsage\n }\n"];
|
|
47
|
+
/**
|
|
48
|
+
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
|
49
|
+
*/
|
|
50
|
+
export declare function graphql(source: "\n mutation AddMedias($input: [Upload!]!) {\n addMedias(input: $input) {\n _id\n file_name\n url\n size\n }\n }\n"): (typeof documents)["\n mutation AddMedias($input: [Upload!]!) {\n addMedias(input: $input) {\n _id\n file_name\n url\n size\n }\n }\n"];
|
|
51
|
+
/**
|
|
52
|
+
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
|
53
|
+
*/
|
|
54
|
+
export declare function graphql(source: "\n mutation DeleteMedias($cursors: [ID!]!) {\n deleteMedias(cursors: $cursors) {\n message\n }\n }\n"): (typeof documents)["\n mutation DeleteMedias($cursors: [ID!]!) {\n deleteMedias(cursors: $cursors) {\n message\n }\n }\n"];
|
|
55
|
+
export type DocumentType<TDocumentNode extends DocumentNode<any, any>> = TDocumentNode extends DocumentNode<infer TType, any> ? TType : never;
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AddMediasDocument, DeleteMediasDocument, MediaUsageDocument, MediasDocument, StoragePlanDocument } from "./graphql.js";
|
|
2
|
+
const documents = {
|
|
3
|
+
"\n query Medias(\n $after: ID\n $before: ID\n $first: Int\n $last: Int\n $query: String\n $reverse: Boolean\n $sortKey: MediaSortKeys\n $filterKeys: MediaFilterKeys\n ) {\n medias(\n after: $after\n before: $before\n first: $first\n last: $last\n query: $query\n reverse: $reverse\n sortKey: $sortKey\n filterKeys: $filterKeys\n ) {\n edges {\n node {\n _id\n file_name\n url\n size\n type\n mimetype\n }\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n }\n": MediasDocument,
|
|
4
|
+
"\n query StoragePlan {\n plan {\n storage\n package {\n _id\n storage\n }\n }\n }\n": StoragePlanDocument,
|
|
5
|
+
"\n query MediaUsage {\n mediaUsage\n }\n": MediaUsageDocument,
|
|
6
|
+
"\n mutation AddMedias($input: [Upload!]!) {\n addMedias(input: $input) {\n _id\n file_name\n url\n size\n }\n }\n": AddMediasDocument,
|
|
7
|
+
"\n mutation DeleteMedias($cursors: [ID!]!) {\n deleteMedias(cursors: $cursors) {\n message\n }\n }\n": DeleteMediasDocument
|
|
8
|
+
};
|
|
9
|
+
function graphql(source) {
|
|
10
|
+
return documents[source] ?? {};
|
|
11
|
+
}
|
|
12
|
+
export { graphql };
|