react-iframe-bridge 0.4.0 → 0.6.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.
@@ -1,4 +1,4 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  export default function ErrorPage(props) {
3
- return (_jsx("div", { className: "max-w-2xl m-auto md:max-w-4xl", children: _jsx("div", { className: "flex justify-between px-2 pt-4", children: _jsxs("div", { className: "min-w-0", children: [_jsx("h1", { className: "text-5xl font-bold sm:mt-16 text-primary-900", children: props.title }, void 0), _jsx("h2", { className: "mt-16 text-lg sm:mt-8", children: props.subtitle }, void 0), _jsx("div", { className: "mt-4", children: props.children }, void 0)] }, void 0) }, void 0) }, void 0));
3
+ return (_jsx("div", { className: "max-w-2xl m-auto md:max-w-4xl", children: _jsx("div", { className: "flex justify-between px-2 pt-4", children: _jsxs("div", { className: "min-w-0", children: [_jsx("h1", { className: "text-5xl font-bold sm:mt-16 text-primary-900", children: props.title }), _jsx("h2", { className: "mt-16 text-lg sm:mt-8", children: props.subtitle }), _jsx("div", { className: "mt-4", children: props.children })] }) }) }));
4
4
  }
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import Spinner from './Spinner';
3
3
  export default function LoadingFull() {
4
- return (_jsx("div", { className: "flex items-center justify-center w-full h-full", children: _jsx(Spinner, { className: "w-10 h-10 text-alternative-500" }, void 0) }, void 0));
4
+ return (_jsx("div", { className: "flex items-center justify-center w-full h-full", children: _jsx(Spinner, { className: "w-10 h-10 text-alternative-500" }) }));
5
5
  }
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import clsx from 'clsx';
3
3
  export default function Spinner(props) {
4
- return (_jsxs("svg", { className: clsx('animate-spin', props.className), xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [_jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }, void 0), _jsx("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" }, void 0)] }, void 0));
4
+ return (_jsxs("svg", { className: clsx('animate-spin', props.className), xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [_jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }), _jsx("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })] }));
5
5
  }
@@ -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, {}, void 0), _jsxs("div", { className: "flex flex-row flex-1 mt-2 border-t border-neutral-300 ", children: [_jsxs("div", { className: "flex flex-col w-48 px-2 pt-4 space-y-3 border-r h-100 border-neutral-300", children: [_jsx(HomeNoSample, {}, void 0), _jsx(HomeSamples, {}, void 0)] }, void 0), _jsx(HomeIframe, {}, void 0)] }, void 0)] }, void 0) }, void 0));
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, {})] })] }) }));
9
9
  }
@@ -38,7 +38,7 @@ const homeDispatchContext = createContext(() => {
38
38
  export function HomeContextProvider(props) {
39
39
  const [homeState, dispatch] = useReducer(homeReducer, props, getInitialHomeContext);
40
40
  useSaveToLocalStorage('dev-home-iframePage', homeState.iframePage);
41
- return (_jsx(homeContext.Provider, { value: homeState, children: _jsx(homeDispatchContext.Provider, { value: dispatch, children: _jsx(RocProvider, { url: homeState.rocUrl, database: homeState.database, children: props.children }, void 0) }, void 0) }, void 0));
41
+ return (_jsx(homeContext.Provider, { value: homeState, children: _jsx(homeDispatchContext.Provider, { value: dispatch, children: _jsx(RocProvider, { url: homeState.rocUrl, database: homeState.database, children: props.children }) }) }));
42
42
  }
43
43
  export function useHomeContext() {
44
44
  return useContext(homeContext);
@@ -3,7 +3,7 @@ import { useHomeContext, useHomeDispatchContext } from './HomeContext';
3
3
  export default function HomeHeader() {
4
4
  const { rocUrl, database, iframePage } = useHomeContext();
5
5
  const dispatch = useHomeDispatchContext();
6
- return (_jsxs("header", { className: "flex flex-row p-2 space-x-4", children: [_jsx("input", { name: "rocUrl", type: "text", className: "flex-1 form-input", value: rocUrl, readOnly: true }, void 0), _jsx("input", { name: "database", type: "text", className: "form-input", value: database, readOnly: true }, void 0), _jsx("input", { name: "iframe-page", value: iframePage, type: "text", className: "flex-1 form-input", onChange: (event) => {
6
+ return (_jsxs("header", { className: "flex flex-row p-2 space-x-4", children: [_jsx("input", { name: "rocUrl", type: "text", className: "flex-1 form-input", value: rocUrl, readOnly: true }), _jsx("input", { name: "database", type: "text", className: "form-input", value: database, readOnly: true }), _jsx("input", { name: "iframe-page", value: iframePage, type: "text", className: "flex-1 form-input", onChange: (event) => {
7
7
  dispatch({ type: 'SET_IFRAME_PAGE', payload: event.target.value });
8
- } }, void 0)] }, void 0));
8
+ } })] }));
9
9
  }
@@ -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" }, void 0)) }, void 0));
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" })) }));
34
34
  }
@@ -4,5 +4,5 @@ import HomeSelector from './HomeSelector';
4
4
  export default function HomeNoSample() {
5
5
  const { iframeMode } = useHomeContext();
6
6
  const dispatch = useHomeDispatchContext();
7
- return (_jsx("div", { children: _jsx(HomeSelector, { onClick: () => dispatch({ type: 'OPEN_NO_SAMPLE' }), selected: iframeMode === 'no-sample', text: "No sample" }, void 0) }, void 0));
7
+ return (_jsx("div", { children: _jsx(HomeSelector, { onClick: () => dispatch({ type: 'OPEN_NO_SAMPLE' }), selected: iframeMode === 'no-sample', text: "No sample" }) }));
8
8
  }
@@ -8,7 +8,7 @@ export default function HomeSamples() {
8
8
  if (error) {
9
9
  throw error;
10
10
  }
11
- return (_jsxs(_Fragment, { children: [_jsx("h1", { className: "mb-4 text-lg font-bold text-center", children: "Sample TOC" }, void 0), _jsx("div", { className: "flex-1", children: loading || !result ? _jsx(Loading, {}, void 0) : _jsx(SampleToc, { samples: result }, void 0) }, void 0)] }, void 0));
11
+ return (_jsxs(_Fragment, { children: [_jsx("h1", { className: "mb-4 text-lg font-bold text-center", children: "Sample TOC" }), _jsx("div", { className: "flex-1", children: loading || !result ? _jsx(Loading, {}) : _jsx(SampleToc, { samples: result }) })] }));
12
12
  }
13
13
  function SampleToc(props) {
14
14
  const { selectedSample } = useHomeContext();
@@ -16,8 +16,8 @@ function SampleToc(props) {
16
16
  function selectSample(id) {
17
17
  dispatch({ type: 'SELECT_SAMPLE', payload: id });
18
18
  }
19
- return (_jsx("div", { className: "space-y-2", children: props.samples.map((sample) => (_jsx(HomeSelector, { selected: sample.id === selectedSample, text: sample.value.reference, onClick: () => selectSample(sample.id) }, sample.id))) }, void 0));
19
+ return (_jsx("div", { className: "space-y-2", children: props.samples.map((sample) => (_jsx(HomeSelector, { selected: sample.id === selectedSample, text: sample.value.reference, onClick: () => selectSample(sample.id) }, sample.id))) }));
20
20
  }
21
21
  function Loading() {
22
- return (_jsx("div", { className: "flex justify-center mt-8", children: _jsx(Spinner, { className: "w-8 h-8 text-alternative-500" }, void 0) }, void 0));
22
+ return (_jsx("div", { className: "flex justify-center mt-8", children: _jsx(Spinner, { className: "w-8 h-8 text-alternative-500" }) }));
23
23
  }
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import clsx from 'clsx';
3
3
  export default function HomeSelector(props) {
4
- return (_jsx("div", { className: clsx('p-1 border rounded cursor-pointer border-neutral-400', props.selected && 'bg-primary-50 shadow-inner'), onClick: props.onClick, children: props.text }, void 0));
4
+ return (_jsx("div", { className: clsx('p-1 border rounded cursor-pointer border-neutral-400', props.selected && 'bg-primary-50 shadow-inner'), onClick: props.onClick, children: props.text }));
5
5
  }
@@ -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(): IframeBridgeReadyContextType;
4
+ export declare function useIframeBridgeContext<PublicUserInfo = unknown>(): IframeBridgeReadyContextType<PublicUserInfo>;
5
5
  export declare function useIframeBridgeSample(): RocDocument<SampleEntryContent, SampleEntryId>;
6
- interface IframeBridgeReadyContextTypeBase {
6
+ interface IframeBridgeReadyContextTypeBase<PublicUserInfo> {
7
7
  state: 'ready';
8
8
  data: IframeDataMessage;
9
- roc: Roc;
9
+ roc: Roc<PublicUserInfo>;
10
10
  }
11
- interface IframeBridgeReadyContextTypeWithSample extends IframeBridgeReadyContextTypeBase {
11
+ interface IframeBridgeReadyContextTypeWithSample<PublicUserInfo> extends IframeBridgeReadyContextTypeBase<PublicUserInfo> {
12
12
  hasSample: true;
13
13
  sample: RocDocument<SampleEntryContent, SampleEntryId>;
14
14
  }
15
- interface IframeBridgeReadyContextTypeWithoutSample extends IframeBridgeReadyContextTypeBase {
15
+ interface IframeBridgeReadyContextTypeWithoutSample<PublicUserInfo> extends IframeBridgeReadyContextTypeBase<PublicUserInfo> {
16
16
  hasSample: false;
17
17
  sample: null;
18
18
  }
19
- declare type IframeBridgeReadyContextType = IframeBridgeReadyContextTypeWithSample | IframeBridgeReadyContextTypeWithoutSample;
19
+ declare type IframeBridgeReadyContextType<PublicUserInfo = unknown> = IframeBridgeReadyContextTypeWithSample<PublicUserInfo> | IframeBridgeReadyContextTypeWithoutSample<PublicUserInfo>;
20
20
  interface IframeDataMessage {
21
21
  couchDB: {
22
22
  url: string;
@@ -7,7 +7,9 @@ import { createContext, useContext, useEffect, useReducer, } from 'react';
7
7
  import { Roc } from 'rest-on-couch-client';
8
8
  import ErrorPage from '../components/ErrorPage';
9
9
  import LoadingFull from '../components/LoadingFull';
10
- const iframeBridgeContext = createContext(null);
10
+ const iframeBridgeContext =
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
+ createContext(null);
11
13
  export function useIframeBridgeContext() {
12
14
  const context = useContext(iframeBridgeContext);
13
15
  if (!context) {
@@ -109,13 +111,13 @@ export function IframeBridgeProvider(props) {
109
111
  };
110
112
  }, [state.roc, state.data]);
111
113
  if (state.state === 'standalone-error') {
112
- return (_jsx(ErrorPage, { title: "Invalid access", subtitle: "This page cannot be accessed without iframe-bridge." }, void 0));
114
+ return (_jsx(ErrorPage, { title: "Invalid access", subtitle: "This page cannot be accessed without iframe-bridge." }));
113
115
  }
114
116
  if (state.state !== 'ready') {
115
- return (_jsx("div", { className: "w-screen h-screen", children: _jsx(LoadingFull, {}, void 0) }, void 0));
117
+ return (_jsx("div", { className: "w-screen h-screen", children: _jsx(LoadingFull, {}) }));
116
118
  }
117
119
  if (!state.hasSample && props.requireSample) {
118
- return (_jsx(ErrorPage, { title: "Invalid access", subtitle: "This page must be accessed with a sample." }, void 0));
120
+ return (_jsx(ErrorPage, { title: "Invalid access", subtitle: "This page must be accessed with a sample." }));
119
121
  }
120
- return (_jsx(iframeBridgeContext.Provider, { value: state, children: props.children }, void 0));
122
+ return (_jsx(iframeBridgeContext.Provider, { value: state, children: props.children }));
121
123
  }
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { Roc } from 'rest-on-couch-client';
3
- export declare function useRoc(): Roc;
3
+ export declare function useRoc<PublicUserInfo = unknown>(): Roc<PublicUserInfo>;
4
4
  export declare function RocProvider(props: {
5
5
  children: ReactNode;
6
6
  url: string;
@@ -12,5 +12,5 @@ export function useRoc() {
12
12
  export function RocProvider(props) {
13
13
  const { url, database, children } = props;
14
14
  const roc = useMemo(() => new Roc({ url, database }), [url, database]);
15
- return _jsx(rocContext.Provider, { value: roc, children: children }, void 0);
15
+ return _jsx(rocContext.Provider, { value: roc, children: children });
16
16
  }
@@ -2,6 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const jsx_runtime_1 = require("react/jsx-runtime");
4
4
  function ErrorPage(props) {
5
- return ((0, jsx_runtime_1.jsx)("div", { className: "max-w-2xl m-auto md:max-w-4xl", children: (0, jsx_runtime_1.jsx)("div", { className: "flex justify-between px-2 pt-4", children: (0, jsx_runtime_1.jsxs)("div", { className: "min-w-0", children: [(0, jsx_runtime_1.jsx)("h1", { className: "text-5xl font-bold sm:mt-16 text-primary-900", children: props.title }, void 0), (0, jsx_runtime_1.jsx)("h2", { className: "mt-16 text-lg sm:mt-8", children: props.subtitle }, void 0), (0, jsx_runtime_1.jsx)("div", { className: "mt-4", children: props.children }, void 0)] }, void 0) }, void 0) }, void 0));
5
+ return ((0, jsx_runtime_1.jsx)("div", { className: "max-w-2xl m-auto md:max-w-4xl", children: (0, jsx_runtime_1.jsx)("div", { className: "flex justify-between px-2 pt-4", children: (0, jsx_runtime_1.jsxs)("div", { className: "min-w-0", children: [(0, jsx_runtime_1.jsx)("h1", { className: "text-5xl font-bold sm:mt-16 text-primary-900", children: props.title }), (0, jsx_runtime_1.jsx)("h2", { className: "mt-16 text-lg sm:mt-8", children: props.subtitle }), (0, jsx_runtime_1.jsx)("div", { className: "mt-4", children: props.children })] }) }) }));
6
6
  }
7
7
  exports.default = ErrorPage;
@@ -6,6 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const jsx_runtime_1 = require("react/jsx-runtime");
7
7
  const Spinner_1 = __importDefault(require("./Spinner"));
8
8
  function LoadingFull() {
9
- return ((0, jsx_runtime_1.jsx)("div", { className: "flex items-center justify-center w-full h-full", children: (0, jsx_runtime_1.jsx)(Spinner_1.default, { className: "w-10 h-10 text-alternative-500" }, void 0) }, void 0));
9
+ return ((0, jsx_runtime_1.jsx)("div", { className: "flex items-center justify-center w-full h-full", children: (0, jsx_runtime_1.jsx)(Spinner_1.default, { className: "w-10 h-10 text-alternative-500" }) }));
10
10
  }
11
11
  exports.default = LoadingFull;
@@ -6,6 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const jsx_runtime_1 = require("react/jsx-runtime");
7
7
  const clsx_1 = __importDefault(require("clsx"));
8
8
  function Spinner(props) {
9
- return ((0, jsx_runtime_1.jsxs)("svg", { className: (0, clsx_1.default)('animate-spin', props.className), xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [(0, jsx_runtime_1.jsx)("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }, void 0), (0, jsx_runtime_1.jsx)("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" }, void 0)] }, void 0));
9
+ return ((0, jsx_runtime_1.jsxs)("svg", { className: (0, clsx_1.default)('animate-spin', props.className), xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [(0, jsx_runtime_1.jsx)("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }), (0, jsx_runtime_1.jsx)("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })] }));
10
10
  }
11
11
  exports.default = Spinner;
@@ -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, {}, void 0), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-row flex-1 mt-2 border-t border-neutral-300 ", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col w-48 px-2 pt-4 space-y-3 border-r h-100 border-neutral-300", children: [(0, jsx_runtime_1.jsx)(HomeNoSample_1.default, {}, void 0), (0, jsx_runtime_1.jsx)(HomeSamples_1.default, {}, void 0)] }, void 0), (0, jsx_runtime_1.jsx)(HomeIframe_1.default, {}, void 0)] }, void 0)] }, void 0) }, void 0));
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, {})] })] }) }));
15
15
  }
16
16
  exports.Home = Home;
@@ -41,7 +41,7 @@ const homeDispatchContext = (0, react_1.createContext)(() => {
41
41
  function HomeContextProvider(props) {
42
42
  const [homeState, dispatch] = (0, react_1.useReducer)(homeReducer, props, getInitialHomeContext);
43
43
  (0, localStorage_1.useSaveToLocalStorage)('dev-home-iframePage', homeState.iframePage);
44
- return ((0, jsx_runtime_1.jsx)(homeContext.Provider, { value: homeState, children: (0, jsx_runtime_1.jsx)(homeDispatchContext.Provider, { value: dispatch, children: (0, jsx_runtime_1.jsx)(roc_1.RocProvider, { url: homeState.rocUrl, database: homeState.database, children: props.children }, void 0) }, void 0) }, void 0));
44
+ return ((0, jsx_runtime_1.jsx)(homeContext.Provider, { value: homeState, children: (0, jsx_runtime_1.jsx)(homeDispatchContext.Provider, { value: dispatch, children: (0, jsx_runtime_1.jsx)(roc_1.RocProvider, { url: homeState.rocUrl, database: homeState.database, children: props.children }) }) }));
45
45
  }
46
46
  exports.HomeContextProvider = HomeContextProvider;
47
47
  function useHomeContext() {
@@ -5,8 +5,8 @@ const HomeContext_1 = require("./HomeContext");
5
5
  function HomeHeader() {
6
6
  const { rocUrl, database, iframePage } = (0, HomeContext_1.useHomeContext)();
7
7
  const dispatch = (0, HomeContext_1.useHomeDispatchContext)();
8
- return ((0, jsx_runtime_1.jsxs)("header", { className: "flex flex-row p-2 space-x-4", children: [(0, jsx_runtime_1.jsx)("input", { name: "rocUrl", type: "text", className: "flex-1 form-input", value: rocUrl, readOnly: true }, void 0), (0, jsx_runtime_1.jsx)("input", { name: "database", type: "text", className: "form-input", value: database, readOnly: true }, void 0), (0, jsx_runtime_1.jsx)("input", { name: "iframe-page", value: iframePage, type: "text", className: "flex-1 form-input", onChange: (event) => {
8
+ return ((0, jsx_runtime_1.jsxs)("header", { className: "flex flex-row p-2 space-x-4", children: [(0, jsx_runtime_1.jsx)("input", { name: "rocUrl", type: "text", className: "flex-1 form-input", value: rocUrl, readOnly: true }), (0, jsx_runtime_1.jsx)("input", { name: "database", type: "text", className: "form-input", value: database, readOnly: true }), (0, jsx_runtime_1.jsx)("input", { name: "iframe-page", value: iframePage, type: "text", className: "flex-1 form-input", onChange: (event) => {
9
9
  dispatch({ type: 'SET_IFRAME_PAGE', payload: event.target.value });
10
- } }, void 0)] }, void 0));
10
+ } })] }));
11
11
  }
12
12
  exports.default = HomeHeader;
@@ -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" }, void 0)) }, void 0));
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" })) }));
36
36
  }
37
37
  exports.default = HomeIframe;
@@ -9,6 +9,6 @@ const HomeSelector_1 = __importDefault(require("./HomeSelector"));
9
9
  function HomeNoSample() {
10
10
  const { iframeMode } = (0, HomeContext_1.useHomeContext)();
11
11
  const dispatch = (0, HomeContext_1.useHomeDispatchContext)();
12
- return ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(HomeSelector_1.default, { onClick: () => dispatch({ type: 'OPEN_NO_SAMPLE' }), selected: iframeMode === 'no-sample', text: "No sample" }, void 0) }, void 0));
12
+ return ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(HomeSelector_1.default, { onClick: () => dispatch({ type: 'OPEN_NO_SAMPLE' }), selected: iframeMode === 'no-sample', text: "No sample" }) }));
13
13
  }
14
14
  exports.default = HomeNoSample;
@@ -13,7 +13,7 @@ function HomeSamples() {
13
13
  if (error) {
14
14
  throw error;
15
15
  }
16
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("h1", { className: "mb-4 text-lg font-bold text-center", children: "Sample TOC" }, void 0), (0, jsx_runtime_1.jsx)("div", { className: "flex-1", children: loading || !result ? (0, jsx_runtime_1.jsx)(Loading, {}, void 0) : (0, jsx_runtime_1.jsx)(SampleToc, { samples: result }, void 0) }, void 0)] }, void 0));
16
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("h1", { className: "mb-4 text-lg font-bold text-center", children: "Sample TOC" }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1", children: loading || !result ? (0, jsx_runtime_1.jsx)(Loading, {}) : (0, jsx_runtime_1.jsx)(SampleToc, { samples: result }) })] }));
17
17
  }
18
18
  exports.default = HomeSamples;
19
19
  function SampleToc(props) {
@@ -22,8 +22,8 @@ function SampleToc(props) {
22
22
  function selectSample(id) {
23
23
  dispatch({ type: 'SELECT_SAMPLE', payload: id });
24
24
  }
25
- return ((0, jsx_runtime_1.jsx)("div", { className: "space-y-2", children: props.samples.map((sample) => ((0, jsx_runtime_1.jsx)(HomeSelector_1.default, { selected: sample.id === selectedSample, text: sample.value.reference, onClick: () => selectSample(sample.id) }, sample.id))) }, void 0));
25
+ return ((0, jsx_runtime_1.jsx)("div", { className: "space-y-2", children: props.samples.map((sample) => ((0, jsx_runtime_1.jsx)(HomeSelector_1.default, { selected: sample.id === selectedSample, text: sample.value.reference, onClick: () => selectSample(sample.id) }, sample.id))) }));
26
26
  }
27
27
  function Loading() {
28
- return ((0, jsx_runtime_1.jsx)("div", { className: "flex justify-center mt-8", children: (0, jsx_runtime_1.jsx)(Spinner_1.default, { className: "w-8 h-8 text-alternative-500" }, void 0) }, void 0));
28
+ return ((0, jsx_runtime_1.jsx)("div", { className: "flex justify-center mt-8", children: (0, jsx_runtime_1.jsx)(Spinner_1.default, { className: "w-8 h-8 text-alternative-500" }) }));
29
29
  }
@@ -6,6 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const jsx_runtime_1 = require("react/jsx-runtime");
7
7
  const clsx_1 = __importDefault(require("clsx"));
8
8
  function HomeSelector(props) {
9
- return ((0, jsx_runtime_1.jsx)("div", { className: (0, clsx_1.default)('p-1 border rounded cursor-pointer border-neutral-400', props.selected && 'bg-primary-50 shadow-inner'), onClick: props.onClick, children: props.text }, void 0));
9
+ return ((0, jsx_runtime_1.jsx)("div", { className: (0, clsx_1.default)('p-1 border rounded cursor-pointer border-neutral-400', props.selected && 'bg-primary-50 shadow-inner'), onClick: props.onClick, children: props.text }));
10
10
  }
11
11
  exports.default = HomeSelector;
@@ -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(): IframeBridgeReadyContextType;
4
+ export declare function useIframeBridgeContext<PublicUserInfo = unknown>(): IframeBridgeReadyContextType<PublicUserInfo>;
5
5
  export declare function useIframeBridgeSample(): RocDocument<SampleEntryContent, SampleEntryId>;
6
- interface IframeBridgeReadyContextTypeBase {
6
+ interface IframeBridgeReadyContextTypeBase<PublicUserInfo> {
7
7
  state: 'ready';
8
8
  data: IframeDataMessage;
9
- roc: Roc;
9
+ roc: Roc<PublicUserInfo>;
10
10
  }
11
- interface IframeBridgeReadyContextTypeWithSample extends IframeBridgeReadyContextTypeBase {
11
+ interface IframeBridgeReadyContextTypeWithSample<PublicUserInfo> extends IframeBridgeReadyContextTypeBase<PublicUserInfo> {
12
12
  hasSample: true;
13
13
  sample: RocDocument<SampleEntryContent, SampleEntryId>;
14
14
  }
15
- interface IframeBridgeReadyContextTypeWithoutSample extends IframeBridgeReadyContextTypeBase {
15
+ interface IframeBridgeReadyContextTypeWithoutSample<PublicUserInfo> extends IframeBridgeReadyContextTypeBase<PublicUserInfo> {
16
16
  hasSample: false;
17
17
  sample: null;
18
18
  }
19
- declare type IframeBridgeReadyContextType = IframeBridgeReadyContextTypeWithSample | IframeBridgeReadyContextTypeWithoutSample;
19
+ declare type IframeBridgeReadyContextType<PublicUserInfo = unknown> = IframeBridgeReadyContextTypeWithSample<PublicUserInfo> | IframeBridgeReadyContextTypeWithoutSample<PublicUserInfo>;
20
20
  interface IframeDataMessage {
21
21
  couchDB: {
22
22
  url: string;
@@ -13,7 +13,9 @@ const react_1 = require("react");
13
13
  const rest_on_couch_client_1 = require("rest-on-couch-client");
14
14
  const ErrorPage_1 = __importDefault(require("../components/ErrorPage"));
15
15
  const LoadingFull_1 = __importDefault(require("../components/LoadingFull"));
16
- const iframeBridgeContext = (0, react_1.createContext)(null);
16
+ const iframeBridgeContext =
17
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
+ (0, react_1.createContext)(null);
17
19
  function useIframeBridgeContext() {
18
20
  const context = (0, react_1.useContext)(iframeBridgeContext);
19
21
  if (!context) {
@@ -117,14 +119,14 @@ function IframeBridgeProvider(props) {
117
119
  };
118
120
  }, [state.roc, state.data]);
119
121
  if (state.state === 'standalone-error') {
120
- return ((0, jsx_runtime_1.jsx)(ErrorPage_1.default, { title: "Invalid access", subtitle: "This page cannot be accessed without iframe-bridge." }, void 0));
122
+ return ((0, jsx_runtime_1.jsx)(ErrorPage_1.default, { title: "Invalid access", subtitle: "This page cannot be accessed without iframe-bridge." }));
121
123
  }
122
124
  if (state.state !== 'ready') {
123
- return ((0, jsx_runtime_1.jsx)("div", { className: "w-screen h-screen", children: (0, jsx_runtime_1.jsx)(LoadingFull_1.default, {}, void 0) }, void 0));
125
+ return ((0, jsx_runtime_1.jsx)("div", { className: "w-screen h-screen", children: (0, jsx_runtime_1.jsx)(LoadingFull_1.default, {}) }));
124
126
  }
125
127
  if (!state.hasSample && props.requireSample) {
126
- return ((0, jsx_runtime_1.jsx)(ErrorPage_1.default, { title: "Invalid access", subtitle: "This page must be accessed with a sample." }, void 0));
128
+ return ((0, jsx_runtime_1.jsx)(ErrorPage_1.default, { title: "Invalid access", subtitle: "This page must be accessed with a sample." }));
127
129
  }
128
- return ((0, jsx_runtime_1.jsx)(iframeBridgeContext.Provider, { value: state, children: props.children }, void 0));
130
+ return ((0, jsx_runtime_1.jsx)(iframeBridgeContext.Provider, { value: state, children: props.children }));
129
131
  }
130
132
  exports.IframeBridgeProvider = IframeBridgeProvider;
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { Roc } from 'rest-on-couch-client';
3
- export declare function useRoc(): Roc;
3
+ export declare function useRoc<PublicUserInfo = unknown>(): Roc<PublicUserInfo>;
4
4
  export declare function RocProvider(props: {
5
5
  children: ReactNode;
6
6
  url: string;
@@ -16,6 +16,6 @@ exports.useRoc = useRoc;
16
16
  function RocProvider(props) {
17
17
  const { url, database, children } = props;
18
18
  const roc = (0, react_1.useMemo)(() => new rest_on_couch_client_1.Roc({ url, database }), [url, database]);
19
- return (0, jsx_runtime_1.jsx)(rocContext.Provider, { value: roc, children: children }, void 0);
19
+ return (0, jsx_runtime_1.jsx)(rocContext.Provider, { value: roc, children: children });
20
20
  }
21
21
  exports.RocProvider = RocProvider;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-iframe-bridge",
3
- "version": "0.4.0",
3
+ "version": "0.6.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",
@@ -20,24 +20,24 @@
20
20
  },
21
21
  "repository": {
22
22
  "type": "git",
23
- "url": "git+https://github.com/zakodium/react-iframe-bridge.git"
23
+ "url": "git+https://github.com/zakodium-oss/react-iframe-bridge.git"
24
24
  },
25
25
  "license": "MIT",
26
26
  "bugs": {
27
- "url": "https://github.com/zakodium/react-iframe-bridge/issues"
27
+ "url": "https://github.com/zakodium-oss/react-iframe-bridge/issues"
28
28
  },
29
- "homepage": "https://github.com/zakodium/react-iframe-bridge#readme",
29
+ "homepage": "https://github.com/zakodium-oss/react-iframe-bridge#readme",
30
30
  "dependencies": {
31
31
  "clsx": "^1.1.1",
32
32
  "iframe-bridge": "^2.0.0",
33
33
  "immer": "^9.0.5",
34
- "rest-on-couch-client": "^4.2.1"
34
+ "rest-on-couch-client": "^5.0.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/react": "^17.0.16",
38
38
  "@types/react-dom": "^17.0.9",
39
- "@zakodium/eslint-config": "^3.0.3",
40
- "eslint": "^7.32.0",
39
+ "@zakodium/eslint-config": "^5.1.1",
40
+ "eslint": "^8.14.0",
41
41
  "prettier": "^2.3.2",
42
42
  "react": "^17.0.2",
43
43
  "react-dom": "^17.0.2"