react-iframe-bridge 0.3.0 → 0.5.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 (33) hide show
  1. package/lib/components/ErrorPage.js +1 -1
  2. package/lib/components/LoadingFull.js +1 -1
  3. package/lib/components/Spinner.js +1 -1
  4. package/lib/components/home/Home.js +1 -1
  5. package/lib/components/home/HomeContext.js +1 -1
  6. package/lib/components/home/HomeHeader.js +2 -2
  7. package/lib/components/home/HomeIframe.js +3 -1
  8. package/lib/components/home/HomeNoSample.js +1 -1
  9. package/lib/components/home/HomeSamples.js +3 -3
  10. package/lib/components/home/HomeSelector.js +1 -1
  11. package/lib/contexts/iframeBridge.d.ts +9 -9
  12. package/lib/contexts/iframeBridge.js +9 -5
  13. package/lib/contexts/roc.d.ts +1 -1
  14. package/lib/contexts/roc.js +1 -1
  15. package/lib/types/db.d.ts +2 -1
  16. package/lib-cjs/components/ErrorPage.js +1 -1
  17. package/lib-cjs/components/LoadingFull.js +1 -1
  18. package/lib-cjs/components/Spinner.js +1 -1
  19. package/lib-cjs/components/home/Home.js +1 -1
  20. package/lib-cjs/components/home/HomeContext.js +9 -9
  21. package/lib-cjs/components/home/HomeHeader.js +4 -4
  22. package/lib-cjs/components/home/HomeIframe.js +9 -7
  23. package/lib-cjs/components/home/HomeNoSample.js +3 -3
  24. package/lib-cjs/components/home/HomeSamples.js +6 -6
  25. package/lib-cjs/components/home/HomeSelector.js +1 -1
  26. package/lib-cjs/contexts/iframeBridge.d.ts +9 -9
  27. package/lib-cjs/contexts/iframeBridge.js +17 -13
  28. package/lib-cjs/contexts/roc.d.ts +1 -1
  29. package/lib-cjs/contexts/roc.js +4 -4
  30. package/lib-cjs/hooks/localStorage.js +6 -6
  31. package/lib-cjs/hooks/useRocQuery.js +3 -3
  32. package/lib-cjs/types/db.d.ts +2 -1
  33. package/package.json +7 -7
@@ -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", Object.assign({ className: "max-w-2xl m-auto md:max-w-4xl" }, { children: _jsx("div", Object.assign({ className: "flex justify-between px-2 pt-4" }, { children: _jsxs("div", Object.assign({ className: "min-w-0" }, { children: [_jsx("h1", Object.assign({ className: "text-5xl font-bold sm:mt-16 text-primary-900" }, { children: props.title }), void 0), _jsx("h2", Object.assign({ className: "mt-16 text-lg sm:mt-8" }, { children: props.subtitle }), void 0), _jsx("div", Object.assign({ 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", Object.assign({ 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", Object.assign({ 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, Object.assign({ rocUrl: props.rocUrl, database: props.database }, { children: _jsxs("div", Object.assign({ className: "flex flex-col w-screen h-screen" }, { children: [_jsx(HomeHeader, {}, void 0), _jsxs("div", Object.assign({ className: "flex flex-row flex-1 mt-2 border-t border-neutral-300 " }, { children: [_jsxs("div", Object.assign({ 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 ", 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, {}), _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, Object.assign({ value: homeState }, { children: _jsx(homeDispatchContext.Provider, Object.assign({ value: dispatch }, { children: _jsx(RocProvider, Object.assign({ 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", Object.assign({ 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
  }
@@ -1,4 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ // https://github.com/import-js/eslint-plugin-import/issues/1810
3
+ /* eslint-disable import/no-unresolved */
2
4
  import { registerHandler, postMessage } from 'iframe-bridge/main';
3
5
  import { useEffect, useState } from 'react';
4
6
  import { useHomeContext } from './HomeContext';
@@ -28,5 +30,5 @@ export default function HomeIframe() {
28
30
  uuid: selectedSample,
29
31
  }, windowId);
30
32
  }, [windowId, database, rocUrl, selectedSample]);
31
- return (_jsx("div", Object.assign({ 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" })) }));
32
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", Object.assign({ className: "mb-4 text-lg font-bold text-center" }, { children: "Sample TOC" }), void 0), _jsx("div", Object.assign({ 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", Object.assign({ 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", Object.assign({ 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", Object.assign({ 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
- import { SampleEntryContent } from '../types/db';
4
- export declare function useIframeBridgeContext(): IframeBridgeReadyContextType;
5
- export declare function useIframeBridgeSample(): RocDocument<SampleEntryContent>;
6
- interface IframeBridgeReadyContextTypeBase {
3
+ import { SampleEntryContent, SampleEntryId } from '../types/db';
4
+ export declare function useIframeBridgeContext<PublicUserInfo = unknown>(): IframeBridgeReadyContextType<PublicUserInfo>;
5
+ export declare function useIframeBridgeSample(): RocDocument<SampleEntryContent, SampleEntryId>;
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
- sample: RocDocument<SampleEntryContent>;
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;
@@ -1,11 +1,15 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ // https://github.com/import-js/eslint-plugin-import/issues/1810
3
+ /* eslint-disable import/no-unresolved */
2
4
  import { ready, onMessage } from 'iframe-bridge/iframe';
3
5
  import { produce } from 'immer';
4
6
  import { createContext, useContext, useEffect, useReducer, } from 'react';
5
7
  import { Roc } from 'rest-on-couch-client';
6
8
  import ErrorPage from '../components/ErrorPage';
7
9
  import LoadingFull from '../components/LoadingFull';
8
- const iframeBridgeContext = createContext(null);
10
+ const iframeBridgeContext =
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
+ createContext(null);
9
13
  export function useIframeBridgeContext() {
10
14
  const context = useContext(iframeBridgeContext);
11
15
  if (!context) {
@@ -107,13 +111,13 @@ export function IframeBridgeProvider(props) {
107
111
  };
108
112
  }, [state.roc, state.data]);
109
113
  if (state.state === 'standalone-error') {
110
- 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." }));
111
115
  }
112
116
  if (state.state !== 'ready') {
113
- return (_jsx("div", Object.assign({ className: "w-screen h-screen" }, { children: _jsx(LoadingFull, {}, void 0) }), void 0));
117
+ return (_jsx("div", { className: "w-screen h-screen", children: _jsx(LoadingFull, {}) }));
114
118
  }
115
119
  if (!state.hasSample && props.requireSample) {
116
- 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." }));
117
121
  }
118
- return (_jsx(iframeBridgeContext.Provider, Object.assign({ value: state }, { children: props.children }), void 0));
122
+ return (_jsx(iframeBridgeContext.Provider, { value: state, children: props.children }));
119
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, Object.assign({ value: roc }, { children: children }), void 0);
15
+ return _jsx(rocContext.Provider, { value: roc, children: children });
16
16
  }
package/lib/types/db.d.ts CHANGED
@@ -27,11 +27,12 @@ export interface TocEntry {
27
27
  names: string[];
28
28
  reference: string;
29
29
  }
30
+ export declare type SampleEntryId = [string, string];
30
31
  export interface SampleEntry {
31
32
  _id: string;
32
33
  _rev: string;
33
34
  $type: 'entry';
34
- $id: [string, string];
35
+ $id: SampleEntryId;
35
36
  $kind: 'sample';
36
37
  $owners: string[];
37
38
  $content: SampleEntryContent;
@@ -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 (jsx_runtime_1.jsx("div", Object.assign({ className: "max-w-2xl m-auto md:max-w-4xl" }, { children: jsx_runtime_1.jsx("div", Object.assign({ className: "flex justify-between px-2 pt-4" }, { children: jsx_runtime_1.jsxs("div", Object.assign({ className: "min-w-0" }, { children: [jsx_runtime_1.jsx("h1", Object.assign({ className: "text-5xl font-bold sm:mt-16 text-primary-900" }, { children: props.title }), void 0), jsx_runtime_1.jsx("h2", Object.assign({ className: "mt-16 text-lg sm:mt-8" }, { children: props.subtitle }), void 0), jsx_runtime_1.jsx("div", Object.assign({ 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 (jsx_runtime_1.jsx("div", Object.assign({ className: "flex items-center justify-center w-full h-full" }, { children: 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 (jsx_runtime_1.jsxs("svg", Object.assign({ className: clsx_1.default('animate-spin', props.className), xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24" }, { children: [jsx_runtime_1.jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }, void 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 (jsx_runtime_1.jsx(HomeContext_1.HomeContextProvider, Object.assign({ rocUrl: props.rocUrl, database: props.database }, { children: jsx_runtime_1.jsxs("div", Object.assign({ className: "flex flex-col w-screen h-screen" }, { children: [jsx_runtime_1.jsx(HomeHeader_1.default, {}, void 0), jsx_runtime_1.jsxs("div", Object.assign({ className: "flex flex-row flex-1 mt-2 border-t border-neutral-300 " }, { children: [jsx_runtime_1.jsxs("div", Object.assign({ className: "flex flex-col w-48 px-2 pt-4 space-y-3 border-r h-100 border-neutral-300" }, { children: [jsx_runtime_1.jsx(HomeNoSample_1.default, {}, void 0), jsx_runtime_1.jsx(HomeSamples_1.default, {}, void 0)] }), void 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 ", 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, {}), (0, jsx_runtime_1.jsx)(HomeSamples_1.default, {})] }), (0, jsx_runtime_1.jsx)(HomeIframe_1.default, {})] })] }) }));
15
15
  }
16
16
  exports.Home = Home;
@@ -12,12 +12,12 @@ function getInitialHomeContext(config = {}) {
12
12
  return {
13
13
  rocUrl,
14
14
  database,
15
- iframePage: localStorage_2.getItem('dev-home-iframePage') || '/dev/base-page',
15
+ iframePage: (0, localStorage_2.getItem)('dev-home-iframePage') || '/dev/base-page',
16
16
  iframeMode: 'closed',
17
17
  selectedSample: null,
18
18
  };
19
19
  }
20
- const homeReducer = immer_1.produce((state, action) => {
20
+ const homeReducer = (0, immer_1.produce)((state, action) => {
21
21
  switch (action.type) {
22
22
  case 'OPEN_NO_SAMPLE':
23
23
  state.iframeMode = 'no-sample';
@@ -34,21 +34,21 @@ const homeReducer = immer_1.produce((state, action) => {
34
34
  throw new Error('unreachable');
35
35
  }
36
36
  });
37
- const homeContext = react_1.createContext(getInitialHomeContext());
38
- const homeDispatchContext = react_1.createContext(() => {
37
+ const homeContext = (0, react_1.createContext)(getInitialHomeContext());
38
+ const homeDispatchContext = (0, react_1.createContext)(() => {
39
39
  // noop
40
40
  });
41
41
  function HomeContextProvider(props) {
42
- const [homeState, dispatch] = react_1.useReducer(homeReducer, props, getInitialHomeContext);
43
- localStorage_1.useSaveToLocalStorage('dev-home-iframePage', homeState.iframePage);
44
- return (jsx_runtime_1.jsx(homeContext.Provider, Object.assign({ value: homeState }, { children: jsx_runtime_1.jsx(homeDispatchContext.Provider, Object.assign({ value: dispatch }, { children: jsx_runtime_1.jsx(roc_1.RocProvider, Object.assign({ url: homeState.rocUrl, database: homeState.database }, { children: props.children }), void 0) }), void 0) }), void 0));
42
+ const [homeState, dispatch] = (0, react_1.useReducer)(homeReducer, props, getInitialHomeContext);
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 }) }) }));
45
45
  }
46
46
  exports.HomeContextProvider = HomeContextProvider;
47
47
  function useHomeContext() {
48
- return react_1.useContext(homeContext);
48
+ return (0, react_1.useContext)(homeContext);
49
49
  }
50
50
  exports.useHomeContext = useHomeContext;
51
51
  function useHomeDispatchContext() {
52
- return react_1.useContext(homeDispatchContext);
52
+ return (0, react_1.useContext)(homeDispatchContext);
53
53
  }
54
54
  exports.useHomeDispatchContext = useHomeDispatchContext;
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const jsx_runtime_1 = require("react/jsx-runtime");
4
4
  const HomeContext_1 = require("./HomeContext");
5
5
  function HomeHeader() {
6
- const { rocUrl, database, iframePage } = HomeContext_1.useHomeContext();
7
- const dispatch = HomeContext_1.useHomeDispatchContext();
8
- return (jsx_runtime_1.jsxs("header", Object.assign({ className: "flex flex-row p-2 space-x-4" }, { children: [jsx_runtime_1.jsx("input", { name: "rocUrl", type: "text", className: "flex-1 form-input", value: rocUrl, readOnly: true }, void 0), jsx_runtime_1.jsx("input", { name: "database", type: "text", className: "form-input", value: database, readOnly: true }, void 0), jsx_runtime_1.jsx("input", { name: "iframe-page", value: iframePage, type: "text", className: "flex-1 form-input", onChange: (event) => {
6
+ const { rocUrl, database, iframePage } = (0, HomeContext_1.useHomeContext)();
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 }), (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;
@@ -1,14 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const jsx_runtime_1 = require("react/jsx-runtime");
4
+ // https://github.com/import-js/eslint-plugin-import/issues/1810
5
+ /* eslint-disable import/no-unresolved */
4
6
  const main_1 = require("iframe-bridge/main");
5
7
  const react_1 = require("react");
6
8
  const HomeContext_1 = require("./HomeContext");
7
9
  function HomeIframe() {
8
- const { database, iframePage, rocUrl, selectedSample, iframeMode } = HomeContext_1.useHomeContext();
9
- const [windowId, setWindowId] = react_1.useState();
10
- react_1.useEffect(() => {
11
- main_1.registerHandler('admin', (message) => {
10
+ const { database, iframePage, rocUrl, selectedSample, iframeMode } = (0, HomeContext_1.useHomeContext)();
11
+ const [windowId, setWindowId] = (0, react_1.useState)();
12
+ (0, react_1.useEffect)(() => {
13
+ (0, main_1.registerHandler)('admin', (message) => {
12
14
  switch (message.type) {
13
15
  case 'admin.connect': {
14
16
  setWindowId(message.windowID);
@@ -19,10 +21,10 @@ function HomeIframe() {
19
21
  }
20
22
  });
21
23
  }, []);
22
- react_1.useEffect(() => {
24
+ (0, react_1.useEffect)(() => {
23
25
  if (windowId === undefined)
24
26
  return;
25
- main_1.postMessage('tab.data', {
27
+ (0, main_1.postMessage)('tab.data', {
26
28
  couchDB: {
27
29
  url: rocUrl,
28
30
  database,
@@ -30,6 +32,6 @@ function HomeIframe() {
30
32
  uuid: selectedSample,
31
33
  }, windowId);
32
34
  }, [windowId, database, rocUrl, selectedSample]);
33
- return (jsx_runtime_1.jsx("div", Object.assign({ className: "flex items-center justify-center flex-1" }, { children: iframeMode !== 'closed' ? (jsx_runtime_1.jsx("iframe", { allowFullScreen: true, src: `http://localhost:3000${iframePage}`, className: "w-full h-full" }, selectedSample)) : (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" })) }));
34
36
  }
35
37
  exports.default = HomeIframe;
@@ -7,8 +7,8 @@ const jsx_runtime_1 = require("react/jsx-runtime");
7
7
  const HomeContext_1 = require("./HomeContext");
8
8
  const HomeSelector_1 = __importDefault(require("./HomeSelector"));
9
9
  function HomeNoSample() {
10
- const { iframeMode } = HomeContext_1.useHomeContext();
11
- const dispatch = HomeContext_1.useHomeDispatchContext();
12
- return (jsx_runtime_1.jsx("div", { children: jsx_runtime_1.jsx(HomeSelector_1.default, { onClick: () => dispatch({ type: 'OPEN_NO_SAMPLE' }), selected: iframeMode === 'no-sample', text: "No sample" }, void 0) }, void 0));
10
+ const { iframeMode } = (0, HomeContext_1.useHomeContext)();
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" }) }));
13
13
  }
14
14
  exports.default = HomeNoSample;
@@ -9,21 +9,21 @@ const Spinner_1 = __importDefault(require("../Spinner"));
9
9
  const HomeContext_1 = require("./HomeContext");
10
10
  const HomeSelector_1 = __importDefault(require("./HomeSelector"));
11
11
  function HomeSamples() {
12
- const { loading, error, result } = useRocQuery_1.useRocQuery('sample_toc');
12
+ const { loading, error, result } = (0, useRocQuery_1.useRocQuery)('sample_toc');
13
13
  if (error) {
14
14
  throw error;
15
15
  }
16
- return (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [jsx_runtime_1.jsx("h1", Object.assign({ className: "mb-4 text-lg font-bold text-center" }, { children: "Sample TOC" }), void 0), jsx_runtime_1.jsx("div", Object.assign({ className: "flex-1" }, { children: loading || !result ? jsx_runtime_1.jsx(Loading, {}, void 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) {
20
- const { selectedSample } = HomeContext_1.useHomeContext();
21
- const dispatch = HomeContext_1.useHomeDispatchContext();
20
+ const { selectedSample } = (0, HomeContext_1.useHomeContext)();
21
+ const dispatch = (0, HomeContext_1.useHomeDispatchContext)();
22
22
  function selectSample(id) {
23
23
  dispatch({ type: 'SELECT_SAMPLE', payload: id });
24
24
  }
25
- return (jsx_runtime_1.jsx("div", Object.assign({ className: "space-y-2" }, { children: props.samples.map((sample) => (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 (jsx_runtime_1.jsx("div", Object.assign({ className: "flex justify-center mt-8" }, { children: 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 (jsx_runtime_1.jsx("div", Object.assign({ className: 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
- import { SampleEntryContent } from '../types/db';
4
- export declare function useIframeBridgeContext(): IframeBridgeReadyContextType;
5
- export declare function useIframeBridgeSample(): RocDocument<SampleEntryContent>;
6
- interface IframeBridgeReadyContextTypeBase {
3
+ import { SampleEntryContent, SampleEntryId } from '../types/db';
4
+ export declare function useIframeBridgeContext<PublicUserInfo = unknown>(): IframeBridgeReadyContextType<PublicUserInfo>;
5
+ export declare function useIframeBridgeSample(): RocDocument<SampleEntryContent, SampleEntryId>;
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
- sample: RocDocument<SampleEntryContent>;
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;
@@ -5,15 +5,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.IframeBridgeProvider = exports.useIframeBridgeSample = exports.useIframeBridgeContext = void 0;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
+ // https://github.com/import-js/eslint-plugin-import/issues/1810
9
+ /* eslint-disable import/no-unresolved */
8
10
  const iframe_1 = require("iframe-bridge/iframe");
9
11
  const immer_1 = require("immer");
10
12
  const react_1 = require("react");
11
13
  const rest_on_couch_client_1 = require("rest-on-couch-client");
12
14
  const ErrorPage_1 = __importDefault(require("../components/ErrorPage"));
13
15
  const LoadingFull_1 = __importDefault(require("../components/LoadingFull"));
14
- const iframeBridgeContext = react_1.createContext(null);
16
+ const iframeBridgeContext =
17
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
+ (0, react_1.createContext)(null);
15
19
  function useIframeBridgeContext() {
16
- const context = react_1.useContext(iframeBridgeContext);
20
+ const context = (0, react_1.useContext)(iframeBridgeContext);
17
21
  if (!context) {
18
22
  throw new Error('Iframe bridge context is not ready');
19
23
  }
@@ -28,7 +32,7 @@ function useIframeBridgeSample() {
28
32
  return context.sample;
29
33
  }
30
34
  exports.useIframeBridgeSample = useIframeBridgeSample;
31
- const iframeBridgeReducer = immer_1.produce((state, action) => {
35
+ const iframeBridgeReducer = (0, immer_1.produce)((state, action) => {
32
36
  switch (action.type) {
33
37
  case 'RECEIVE_DATA': {
34
38
  state.data = action.payload;
@@ -64,9 +68,9 @@ const initialState = {
64
68
  sample: null,
65
69
  };
66
70
  function IframeBridgeProvider(props) {
67
- const [state, dispatch] = react_1.useReducer(iframeBridgeReducer, initialState);
68
- react_1.useEffect(() => {
69
- iframe_1.onMessage((message) => {
71
+ const [state, dispatch] = (0, react_1.useReducer)(iframeBridgeReducer, initialState);
72
+ (0, react_1.useEffect)(() => {
73
+ (0, iframe_1.onMessage)((message) => {
70
74
  switch (message.type) {
71
75
  case 'tab.data': {
72
76
  dispatch({ type: 'RECEIVE_DATA', payload: message.message });
@@ -83,9 +87,9 @@ function IframeBridgeProvider(props) {
83
87
  throw new Error('unreachable');
84
88
  }
85
89
  });
86
- iframe_1.ready();
90
+ (0, iframe_1.ready)();
87
91
  }, []);
88
- react_1.useEffect(() => {
92
+ (0, react_1.useEffect)(() => {
89
93
  if (!props.allowStandalone && state.state === 'initial') {
90
94
  const timeout = setTimeout(() => {
91
95
  dispatch({ type: 'STANDALONE_TIMEOUT' });
@@ -93,7 +97,7 @@ function IframeBridgeProvider(props) {
93
97
  return () => clearTimeout(timeout);
94
98
  }
95
99
  }, [props.allowStandalone, state.state]);
96
- react_1.useEffect(() => {
100
+ (0, react_1.useEffect)(() => {
97
101
  if (!state.roc || !state.data || !state.data.uuid)
98
102
  return;
99
103
  let cancelled = false;
@@ -115,14 +119,14 @@ function IframeBridgeProvider(props) {
115
119
  };
116
120
  }, [state.roc, state.data]);
117
121
  if (state.state === 'standalone-error') {
118
- return (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." }));
119
123
  }
120
124
  if (state.state !== 'ready') {
121
- return (jsx_runtime_1.jsx("div", Object.assign({ className: "w-screen h-screen" }, { children: 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, {}) }));
122
126
  }
123
127
  if (!state.hasSample && props.requireSample) {
124
- return (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." }));
125
129
  }
126
- return (jsx_runtime_1.jsx(iframeBridgeContext.Provider, Object.assign({ value: state }, { children: props.children }), void 0));
130
+ return ((0, jsx_runtime_1.jsx)(iframeBridgeContext.Provider, { value: state, children: props.children }));
127
131
  }
128
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;
@@ -4,9 +4,9 @@ exports.RocProvider = exports.useRoc = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const rest_on_couch_client_1 = require("rest-on-couch-client");
7
- const rocContext = react_1.createContext(null);
7
+ const rocContext = (0, react_1.createContext)(null);
8
8
  function useRoc() {
9
- const roc = react_1.useContext(rocContext);
9
+ const roc = (0, react_1.useContext)(rocContext);
10
10
  if (!roc) {
11
11
  throw new Error('missing roc');
12
12
  }
@@ -15,7 +15,7 @@ function useRoc() {
15
15
  exports.useRoc = useRoc;
16
16
  function RocProvider(props) {
17
17
  const { url, database, children } = props;
18
- const roc = react_1.useMemo(() => new rest_on_couch_client_1.Roc({ url, database }), [url, database]);
19
- return jsx_runtime_1.jsx(rocContext.Provider, Object.assign({ value: roc }, { children: children }), void 0);
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 });
20
20
  }
21
21
  exports.RocProvider = RocProvider;
@@ -10,18 +10,18 @@ const localStorage_1 = require("../utils/localStorage");
10
10
  * @param initialValue Value to use if the storage is empty.
11
11
  */
12
12
  function useLocalStorage(key, initialValue) {
13
- const [storedValue, setStoredValue] = react_1.useState(() => {
13
+ const [storedValue, setStoredValue] = (0, react_1.useState)(() => {
14
14
  // Get from local storage by key.
15
- const item = localStorage_1.getItem(key);
15
+ const item = (0, localStorage_1.getItem)(key);
16
16
  // Parse stored json or if none return initialValue.
17
17
  return item ? item : initialValue;
18
18
  });
19
19
  // Return a wrapped version of useState's setter function that persists the new value to localStorage.
20
- const setValue = react_1.useCallback((value) => {
20
+ const setValue = (0, react_1.useCallback)((value) => {
21
21
  // Save state.
22
22
  setStoredValue(value);
23
23
  // Save to local storage.
24
- localStorage_1.setItem(key, value);
24
+ (0, localStorage_1.setItem)(key, value);
25
25
  }, [key]);
26
26
  return [storedValue, setValue];
27
27
  }
@@ -32,8 +32,8 @@ exports.useLocalStorage = useLocalStorage;
32
32
  * @param value Value to save.
33
33
  */
34
34
  function useSaveToLocalStorage(key, value) {
35
- react_1.useEffect(() => {
36
- localStorage_1.setItem(key, value);
35
+ (0, react_1.useEffect)(() => {
36
+ (0, localStorage_1.setItem)(key, value);
37
37
  }, [key, value]);
38
38
  }
39
39
  exports.useSaveToLocalStorage = useSaveToLocalStorage;
@@ -25,13 +25,13 @@ function rocQueryReducer(state, action) {
25
25
  }
26
26
  function useRocQuery(viewName, options = {}) {
27
27
  const { mine = false } = options;
28
- const roc = roc_1.useRoc();
29
- const [state, dispatch] = react_1.useReducer(rocQueryReducer, {
28
+ const roc = (0, roc_1.useRoc)();
29
+ const [state, dispatch] = (0, react_1.useReducer)(rocQueryReducer, {
30
30
  loading: true,
31
31
  error: null,
32
32
  result: null,
33
33
  });
34
- react_1.useEffect(() => {
34
+ (0, react_1.useEffect)(() => {
35
35
  dispatch({ type: 'LOAD' });
36
36
  const query = roc.getQuery(viewName, { mine });
37
37
  query
@@ -27,11 +27,12 @@ export interface TocEntry {
27
27
  names: string[];
28
28
  reference: string;
29
29
  }
30
+ export declare type SampleEntryId = [string, string];
30
31
  export interface SampleEntry {
31
32
  _id: string;
32
33
  _rev: string;
33
34
  $type: 'entry';
34
- $id: [string, string];
35
+ $id: SampleEntryId;
35
36
  $kind: 'sample';
36
37
  $owners: string[];
37
38
  $content: SampleEntryContent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-iframe-bridge",
3
- "version": "0.3.0",
3
+ "version": "0.5.1",
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": "^3.1.0"
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"