react-iframe-bridge 0.6.0 → 0.8.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.
@@ -10,5 +10,6 @@ export interface HomeProps {
10
10
  * @default 'eln'
11
11
  */
12
12
  database?: string;
13
+ baseUrl?: string;
13
14
  }
14
15
  export declare function Home(props: HomeProps): JSX.Element;
@@ -5,5 +5,5 @@ import HomeIframe from './HomeIframe';
5
5
  import HomeNoSample from './HomeNoSample';
6
6
  import HomeSamples from './HomeSamples';
7
7
  export function Home(props) {
8
- return (_jsx(HomeContextProvider, { rocUrl: props.rocUrl, database: props.database, children: _jsxs("div", { className: "flex flex-col w-screen h-screen", children: [_jsx(HomeHeader, {}), _jsxs("div", { className: "flex flex-row flex-1 mt-2 border-t border-neutral-300 min-h-0", children: [_jsxs("div", { className: "flex flex-col w-48 px-2 pt-4 space-y-3 border-r border-neutral-300 overflow-auto", children: [_jsx(HomeNoSample, {}), _jsx(HomeSamples, {})] }), _jsx(HomeIframe, {})] })] }) }));
8
+ return (_jsx(HomeContextProvider, { rocUrl: props.rocUrl, database: props.database, children: _jsxs("div", { className: "flex flex-col w-screen h-screen", children: [_jsx(HomeHeader, {}), _jsxs("div", { className: "flex flex-row flex-1 mt-2 border-t border-neutral-300 min-h-0", children: [_jsxs("div", { className: "flex flex-col w-48 px-2 pt-4 space-y-3 border-r border-neutral-300 overflow-auto", children: [_jsx(HomeNoSample, {}), _jsx(HomeSamples, {})] }), _jsx(HomeIframe, { baseUrl: props.baseUrl })] })] }) }));
9
9
  }
@@ -1,2 +1,4 @@
1
1
  /// <reference types="react" />
2
- export default function HomeIframe(): JSX.Element;
2
+ export default function HomeIframe(props: {
3
+ baseUrl?: string;
4
+ }): JSX.Element;
@@ -4,7 +4,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
4
4
  import { registerHandler, postMessage } from 'iframe-bridge/main';
5
5
  import { useEffect, useState } from 'react';
6
6
  import { useHomeContext } from './HomeContext';
7
- export default function HomeIframe() {
7
+ export default function HomeIframe(props) {
8
8
  const { database, iframePage, rocUrl, selectedSample, iframeMode } = useHomeContext();
9
9
  const [windowId, setWindowId] = useState();
10
10
  useEffect(() => {
@@ -30,5 +30,5 @@ export default function HomeIframe() {
30
30
  uuid: selectedSample,
31
31
  }, windowId);
32
32
  }, [windowId, database, rocUrl, selectedSample]);
33
- return (_jsx("div", { className: "flex items-center justify-center flex-1", children: iframeMode !== 'closed' ? (_jsx("iframe", { allowFullScreen: true, src: `http://localhost:3000${iframePage}`, className: "w-full h-full" }, selectedSample)) : (_jsx("div", { children: "Please select something" })) }));
33
+ return (_jsx("div", { className: "flex items-center justify-center flex-1", children: iframeMode !== 'closed' ? (_jsx("iframe", { allowFullScreen: true, src: `${props.baseUrl || ''}${iframePage}`, className: "w-full h-full" }, selectedSample)) : (_jsx("div", { children: "Please select something" })) }));
34
34
  }
@@ -1,22 +1,22 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { Roc, RocDocument } from 'rest-on-couch-client';
3
3
  import { SampleEntryContent, SampleEntryId } from '../types/db';
4
- export declare function useIframeBridgeContext<PublicUserInfo = unknown>(): IframeBridgeReadyContextType<PublicUserInfo>;
4
+ export declare function useIframeBridgeContext<PublicUserInfo = unknown, PrivateUserInfo = unknown>(): IframeBridgeReadyContextType<PublicUserInfo, PrivateUserInfo>;
5
5
  export declare function useIframeBridgeSample(): RocDocument<SampleEntryContent, SampleEntryId>;
6
- interface IframeBridgeReadyContextTypeBase<PublicUserInfo> {
6
+ interface IframeBridgeReadyContextTypeBase<PublicUserInfo, PrivateUserInfo> {
7
7
  state: 'ready';
8
8
  data: IframeDataMessage;
9
- roc: Roc<PublicUserInfo>;
9
+ roc: Roc<PublicUserInfo, PrivateUserInfo>;
10
10
  }
11
- interface IframeBridgeReadyContextTypeWithSample<PublicUserInfo> extends IframeBridgeReadyContextTypeBase<PublicUserInfo> {
11
+ interface IframeBridgeReadyContextTypeWithSample<PublicUserInfo, PrivateUserInfo> extends IframeBridgeReadyContextTypeBase<PublicUserInfo, PrivateUserInfo> {
12
12
  hasSample: true;
13
13
  sample: RocDocument<SampleEntryContent, SampleEntryId>;
14
14
  }
15
- interface IframeBridgeReadyContextTypeWithoutSample<PublicUserInfo> extends IframeBridgeReadyContextTypeBase<PublicUserInfo> {
15
+ interface IframeBridgeReadyContextTypeWithoutSample<PublicUserInfo, PrivateUserInfo> extends IframeBridgeReadyContextTypeBase<PublicUserInfo, PrivateUserInfo> {
16
16
  hasSample: false;
17
17
  sample: null;
18
18
  }
19
- declare type IframeBridgeReadyContextType<PublicUserInfo = unknown> = IframeBridgeReadyContextTypeWithSample<PublicUserInfo> | IframeBridgeReadyContextTypeWithoutSample<PublicUserInfo>;
19
+ declare type IframeBridgeReadyContextType<PublicUserInfo = unknown, PrivateUserInfo = unknown> = IframeBridgeReadyContextTypeWithSample<PublicUserInfo, PrivateUserInfo> | IframeBridgeReadyContextTypeWithoutSample<PublicUserInfo, PrivateUserInfo>;
20
20
  interface IframeDataMessage {
21
21
  couchDB: {
22
22
  url: string;
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { Roc } from 'rest-on-couch-client';
3
- export declare function useRoc<PublicUserInfo = unknown>(): Roc<PublicUserInfo>;
3
+ export declare function useRoc<PublicUserInfo = unknown, PrivateUserInfo = unknown>(): Roc<PublicUserInfo, PrivateUserInfo>;
4
4
  export declare function RocProvider(props: {
5
5
  children: ReactNode;
6
6
  url: string;
@@ -10,5 +10,6 @@ export interface HomeProps {
10
10
  * @default 'eln'
11
11
  */
12
12
  database?: string;
13
+ baseUrl?: string;
13
14
  }
14
15
  export declare function Home(props: HomeProps): JSX.Element;
@@ -11,6 +11,6 @@ const HomeIframe_1 = __importDefault(require("./HomeIframe"));
11
11
  const HomeNoSample_1 = __importDefault(require("./HomeNoSample"));
12
12
  const HomeSamples_1 = __importDefault(require("./HomeSamples"));
13
13
  function Home(props) {
14
- return ((0, jsx_runtime_1.jsx)(HomeContext_1.HomeContextProvider, { rocUrl: props.rocUrl, database: props.database, children: (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col w-screen h-screen", children: [(0, jsx_runtime_1.jsx)(HomeHeader_1.default, {}), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-row flex-1 mt-2 border-t border-neutral-300 min-h-0", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col w-48 px-2 pt-4 space-y-3 border-r border-neutral-300 overflow-auto", children: [(0, jsx_runtime_1.jsx)(HomeNoSample_1.default, {}), (0, jsx_runtime_1.jsx)(HomeSamples_1.default, {})] }), (0, jsx_runtime_1.jsx)(HomeIframe_1.default, {})] })] }) }));
14
+ return ((0, jsx_runtime_1.jsx)(HomeContext_1.HomeContextProvider, { rocUrl: props.rocUrl, database: props.database, children: (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col w-screen h-screen", children: [(0, jsx_runtime_1.jsx)(HomeHeader_1.default, {}), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-row flex-1 mt-2 border-t border-neutral-300 min-h-0", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col w-48 px-2 pt-4 space-y-3 border-r border-neutral-300 overflow-auto", children: [(0, jsx_runtime_1.jsx)(HomeNoSample_1.default, {}), (0, jsx_runtime_1.jsx)(HomeSamples_1.default, {})] }), (0, jsx_runtime_1.jsx)(HomeIframe_1.default, { baseUrl: props.baseUrl })] })] }) }));
15
15
  }
16
16
  exports.Home = Home;
@@ -1,2 +1,4 @@
1
1
  /// <reference types="react" />
2
- export default function HomeIframe(): JSX.Element;
2
+ export default function HomeIframe(props: {
3
+ baseUrl?: string;
4
+ }): JSX.Element;
@@ -6,7 +6,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
6
6
  const main_1 = require("iframe-bridge/main");
7
7
  const react_1 = require("react");
8
8
  const HomeContext_1 = require("./HomeContext");
9
- function HomeIframe() {
9
+ function HomeIframe(props) {
10
10
  const { database, iframePage, rocUrl, selectedSample, iframeMode } = (0, HomeContext_1.useHomeContext)();
11
11
  const [windowId, setWindowId] = (0, react_1.useState)();
12
12
  (0, react_1.useEffect)(() => {
@@ -32,6 +32,6 @@ function HomeIframe() {
32
32
  uuid: selectedSample,
33
33
  }, windowId);
34
34
  }, [windowId, database, rocUrl, selectedSample]);
35
- return ((0, jsx_runtime_1.jsx)("div", { className: "flex items-center justify-center flex-1", children: iframeMode !== 'closed' ? ((0, jsx_runtime_1.jsx)("iframe", { allowFullScreen: true, src: `http://localhost:3000${iframePage}`, className: "w-full h-full" }, selectedSample)) : ((0, jsx_runtime_1.jsx)("div", { children: "Please select something" })) }));
35
+ return ((0, jsx_runtime_1.jsx)("div", { className: "flex items-center justify-center flex-1", children: iframeMode !== 'closed' ? ((0, jsx_runtime_1.jsx)("iframe", { allowFullScreen: true, src: `${props.baseUrl || ''}${iframePage}`, className: "w-full h-full" }, selectedSample)) : ((0, jsx_runtime_1.jsx)("div", { children: "Please select something" })) }));
36
36
  }
37
37
  exports.default = HomeIframe;
@@ -1,22 +1,22 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { Roc, RocDocument } from 'rest-on-couch-client';
3
3
  import { SampleEntryContent, SampleEntryId } from '../types/db';
4
- export declare function useIframeBridgeContext<PublicUserInfo = unknown>(): IframeBridgeReadyContextType<PublicUserInfo>;
4
+ export declare function useIframeBridgeContext<PublicUserInfo = unknown, PrivateUserInfo = unknown>(): IframeBridgeReadyContextType<PublicUserInfo, PrivateUserInfo>;
5
5
  export declare function useIframeBridgeSample(): RocDocument<SampleEntryContent, SampleEntryId>;
6
- interface IframeBridgeReadyContextTypeBase<PublicUserInfo> {
6
+ interface IframeBridgeReadyContextTypeBase<PublicUserInfo, PrivateUserInfo> {
7
7
  state: 'ready';
8
8
  data: IframeDataMessage;
9
- roc: Roc<PublicUserInfo>;
9
+ roc: Roc<PublicUserInfo, PrivateUserInfo>;
10
10
  }
11
- interface IframeBridgeReadyContextTypeWithSample<PublicUserInfo> extends IframeBridgeReadyContextTypeBase<PublicUserInfo> {
11
+ interface IframeBridgeReadyContextTypeWithSample<PublicUserInfo, PrivateUserInfo> extends IframeBridgeReadyContextTypeBase<PublicUserInfo, PrivateUserInfo> {
12
12
  hasSample: true;
13
13
  sample: RocDocument<SampleEntryContent, SampleEntryId>;
14
14
  }
15
- interface IframeBridgeReadyContextTypeWithoutSample<PublicUserInfo> extends IframeBridgeReadyContextTypeBase<PublicUserInfo> {
15
+ interface IframeBridgeReadyContextTypeWithoutSample<PublicUserInfo, PrivateUserInfo> extends IframeBridgeReadyContextTypeBase<PublicUserInfo, PrivateUserInfo> {
16
16
  hasSample: false;
17
17
  sample: null;
18
18
  }
19
- declare type IframeBridgeReadyContextType<PublicUserInfo = unknown> = IframeBridgeReadyContextTypeWithSample<PublicUserInfo> | IframeBridgeReadyContextTypeWithoutSample<PublicUserInfo>;
19
+ declare type IframeBridgeReadyContextType<PublicUserInfo = unknown, PrivateUserInfo = unknown> = IframeBridgeReadyContextTypeWithSample<PublicUserInfo, PrivateUserInfo> | IframeBridgeReadyContextTypeWithoutSample<PublicUserInfo, PrivateUserInfo>;
20
20
  interface IframeDataMessage {
21
21
  couchDB: {
22
22
  url: string;
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { Roc } from 'rest-on-couch-client';
3
- export declare function useRoc<PublicUserInfo = unknown>(): Roc<PublicUserInfo>;
3
+ export declare function useRoc<PublicUserInfo = unknown, PrivateUserInfo = unknown>(): Roc<PublicUserInfo, PrivateUserInfo>;
4
4
  export declare function RocProvider(props: {
5
5
  children: ReactNode;
6
6
  url: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-iframe-bridge",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "React hooks and components to work with iframe-bridge.",
5
5
  "main": "lib-cjs/index.js",
6
6
  "module": "lib/index.js",
@@ -31,7 +31,7 @@
31
31
  "clsx": "^1.1.1",
32
32
  "iframe-bridge": "^2.0.0",
33
33
  "immer": "^9.0.5",
34
- "rest-on-couch-client": "^5.0.0"
34
+ "rest-on-couch-client": "^5.1.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/react": "^17.0.16",