@synnaxlabs/drift 0.47.0 → 0.49.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 +3 -3
- package/dist/eslint.config.d.ts +2 -1
- package/dist/eslint.config.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +209 -223
- package/dist/react.cjs +1 -1
- package/dist/react.js +16 -16
- package/dist/{selectors-BjelCGzn.cjs → selectors-C-yu1uR2.cjs} +1 -1
- package/dist/{selectors-ZKSe28UL.js → selectors-UsB3Nvlx.js} +1 -1
- package/dist/src/configureStore.d.ts +13 -14
- package/dist/src/configureStore.d.ts.map +1 -1
- package/dist/src/react/hooks.d.ts +2 -2
- package/dist/src/react/hooks.d.ts.map +1 -1
- package/dist/state-B6GRS-m8.cjs +28 -0
- package/dist/{state-DhV1kb1g.js → state-D-AHxNXX.js} +3557 -3397
- package/dist/tauri.cjs +1 -1
- package/dist/tauri.js +72 -69
- package/package.json +16 -23
- package/dist/debounce-BUAIXXZt.cjs +0 -1
- package/dist/debounce-DOZKRZa9.js +0 -9
- package/dist/electron.cjs +0 -1
- package/dist/electron.js +0 -249
- package/dist/src/electron/index.d.ts +0 -49
- package/dist/src/electron/index.d.ts.map +0 -1
- package/dist/state-CpvoH8kq.cjs +0 -28
package/dist/react.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),u=require("react-redux"),a=require("proxy-memoize"),d=require("./selectors-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),u=require("react-redux"),a=require("proxy-memoize"),d=require("./selectors-C-yu1uR2.cjs"),i=require("./state-B6GRS-m8.cjs"),y=e=>u.useSelector(n.useCallback(a.memoize(s=>d.selectWindow(s,e)),[e])),w=()=>u.useSelector(n.useCallback(a.memoize(d.selectWindows),[])),S=e=>u.useSelector(n.useCallback(a.memoize(s=>d.selectWindowKey(s,e)),[e])),W=(e,s)=>u.useSelector(n.useCallback(a.memoize(t=>d.selectWindowAttribute(t,e,s)),[e,s])),m=(e,s)=>{const t=y(s),o=u.useDispatch(),c=n.useRef(null);n.useEffect(()=>{if(t==null)return;const{stage:r}=t;if(r==="created"&&c.current==null){const l=e();l!=null&&(c.current=l),o(i.registerProcess({key:t.key}))}else(r==="closing"||r==="reloading")&&c.current!=null&&(c.current(),c.current=null,o(i.completeProcess({key:t.key})))},[t])},h=(e,s)=>{const t=y(s),o=u.useDispatch(),c=n.useRef(null),r=n.useRef(!1);n.useEffect(()=>{if(t==null)return;const{stage:l}=t;if(l==="created"&&c.current==null)r.current=!0,e().then(f=>{c.current=f??(async()=>{}),o(i.registerProcess({key:t.key}))}).catch(console.error).finally(()=>{r.current=!1});else if((l==="closing"||l==="reloading")&&c.current!=null){const f=c.current;c.current=null,f().then(()=>{c.current=null}).catch(console.error).finally(()=>{o(i.completeProcess({key:t.key}))})}},[t])},g=({store:e,emptyContent:s=null,children:t})=>{const[o,c]=n.useState(null),[r,l]=n.useState(null);if(r!=null)throw l(null),r;return o==null?(e instanceof Promise?e.then(c).catch(l):c(e),s):n.createElement(u.Provider,{store:o},t)};exports.Provider=g;exports.useAsyncWindowLifecycle=h;exports.useSelectWindow=y;exports.useSelectWindowAttribute=W;exports.useSelectWindowKey=S;exports.useSelectWindows=w;exports.useWindowLifecycle=m;
|
package/dist/react.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { useCallback as l, useRef as f, useEffect as m, useState as d, createElement as W } from "react";
|
|
2
|
-
import { useSelector as u, useDispatch as y, Provider as
|
|
2
|
+
import { useSelector as u, useDispatch as y, Provider as k } from "react-redux";
|
|
3
3
|
import { memoize as i } from "proxy-memoize";
|
|
4
|
-
import { a as
|
|
5
|
-
import {
|
|
4
|
+
import { a as g, e as S, c as P, b as v } from "./selectors-UsB3Nvlx.js";
|
|
5
|
+
import { p as w, k as p } from "./state-D-AHxNXX.js";
|
|
6
6
|
const h = (e) => u(
|
|
7
7
|
l(
|
|
8
|
-
i((r) =>
|
|
8
|
+
i((r) => g(r, e)),
|
|
9
9
|
[e]
|
|
10
10
|
)
|
|
11
|
-
),
|
|
11
|
+
), x = () => u(l(i(S), [])), z = (e) => u(
|
|
12
12
|
l(
|
|
13
13
|
i((r) => P(r, e)),
|
|
14
14
|
[e]
|
|
15
15
|
)
|
|
16
|
-
),
|
|
16
|
+
), C = (e, r) => u(
|
|
17
17
|
l(
|
|
18
18
|
i((t) => v(t, e, r)),
|
|
19
19
|
[e, r]
|
|
20
20
|
)
|
|
21
|
-
),
|
|
21
|
+
), L = (e, r) => {
|
|
22
22
|
const t = h(r), o = y(), n = f(null);
|
|
23
23
|
m(() => {
|
|
24
24
|
if (t == null) return;
|
|
@@ -28,7 +28,7 @@ const h = (e) => u(
|
|
|
28
28
|
s != null && (n.current = s), o(w({ key: t.key }));
|
|
29
29
|
} else (c === "closing" || c === "reloading") && n.current != null && (n.current(), n.current = null, o(p({ key: t.key })));
|
|
30
30
|
}, [t]);
|
|
31
|
-
},
|
|
31
|
+
}, R = (e, r) => {
|
|
32
32
|
const t = h(r), o = y(), n = f(null), c = f(!1);
|
|
33
33
|
m(() => {
|
|
34
34
|
if (t == null) return;
|
|
@@ -49,7 +49,7 @@ const h = (e) => u(
|
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
}, [t]);
|
|
52
|
-
},
|
|
52
|
+
}, j = ({
|
|
53
53
|
store: e,
|
|
54
54
|
emptyContent: r = null,
|
|
55
55
|
children: t
|
|
@@ -57,14 +57,14 @@ const h = (e) => u(
|
|
|
57
57
|
const [o, n] = d(null), [c, s] = d(null);
|
|
58
58
|
if (c != null)
|
|
59
59
|
throw s(null), c;
|
|
60
|
-
return o == null ? (e instanceof Promise ? e.then(n).catch(s) : n(e), r) : W(
|
|
60
|
+
return o == null ? (e instanceof Promise ? e.then(n).catch(s) : n(e), r) : W(k, { store: o }, t);
|
|
61
61
|
};
|
|
62
62
|
export {
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
j as Provider,
|
|
64
|
+
R as useAsyncWindowLifecycle,
|
|
65
65
|
h as useSelectWindow,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
C as useSelectWindowAttribute,
|
|
67
|
+
z as useSelectWindowKey,
|
|
68
|
+
x as useSelectWindows,
|
|
69
|
+
L as useWindowLifecycle
|
|
70
70
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const i=require("./state-
|
|
1
|
+
"use strict";const i=require("./state-B6GRS-m8.cjs"),s=n=>n.drift,r=n=>Object.values(s(n).windows),c=(n,e)=>{const t=s(n);if(e==null)return t.windows[t.label];let l=t.windows[e];if(l!=null)return l;const o=t.keyLabels[e];return l=t.windows[o],l==null&&e!=null?null:l??t.windows[t.label]},u=(n,e)=>{const t=s(n);if(e==null)return t.labelKeys[t.label];const l=t.labelKeys[e];return l==null&&e==i.MAIN_WINDOW?i.MAIN_WINDOW:l},w=(n,e,t)=>c(n,e)?.[t]??null,d=(n,e)=>s(n).keyLabels[e];exports.selectSliceState=s;exports.selectWindow=c;exports.selectWindowAttribute=w;exports.selectWindowKey=u;exports.selectWindowLabel=d;exports.selectWindows=r;
|
|
@@ -16,27 +16,26 @@ export interface ConfigureStoreOptions<S extends StoreState, A extends CoreActio
|
|
|
16
16
|
defaultWindowProps?: Omit<WindowProps, "key">;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
* configureStore replaces the standard Redux Toolkit configureStore function
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* important differences.
|
|
19
|
+
* configureStore replaces the standard Redux Toolkit configureStore function with one
|
|
20
|
+
* that enables drift to synchronize state between windows. The API is identical to the
|
|
21
|
+
* standard configureStore function, except for two important differences.
|
|
23
22
|
*
|
|
24
|
-
* @param options.runtime - The core runtime of the application. This should
|
|
25
|
-
*
|
|
26
|
-
* @param options.debug - If true, drift will log debug information to the
|
|
27
|
-
*
|
|
23
|
+
* @param options.runtime - The core runtime of the application. This should be chosen
|
|
24
|
+
* based on the platform you are running on (Tauri, etc.).
|
|
25
|
+
* @param options.debug - If true, drift will log debug information to the console.
|
|
26
|
+
* @default false
|
|
28
27
|
* @param props.enablePrerender - If true, drift will create an invisible, pre-rendered
|
|
29
28
|
* window before it is needed. While it adds an additional process to your application,
|
|
30
29
|
* it also dramatically reduces the time it takes to open a new window. @default true
|
|
31
|
-
* @param props.defaultWindowProps - A partial set of window props to merge with
|
|
32
|
-
*
|
|
30
|
+
* @param props.defaultWindowProps - A partial set of window props to merge with the
|
|
31
|
+
* props passed to drift.createWindow. This is useful for setting default window
|
|
33
32
|
* properties, especially with prerendering. @default {}
|
|
34
33
|
* @param options - The standard Redux Toolkit configureStore options.
|
|
35
34
|
*
|
|
36
|
-
* @returns A !PROMISE! that resolves to a Redux store. This is necessary because
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
35
|
+
* @returns A !PROMISE! that resolves to a Redux store. This is necessary because the
|
|
36
|
+
* store must receive it's initial state from the main window, which is an asynchronous
|
|
37
|
+
* operation. The promise will resolve when the store is configured and the window is
|
|
38
|
+
* ready for use.
|
|
40
39
|
*/
|
|
41
40
|
export declare const configureStore: <S extends StoreState, A extends CoreAction = UnknownAction, M extends Tuple<Middlewares<S>> = Tuple<Middlewares<S>>, E extends Tuple<Enhancers> = Tuple<Enhancers>>(options: ConfigureStoreOptions<S, A, M, E>) => Promise<EnhancedStore<S, A | Action>>;
|
|
42
41
|
export declare const resetInitialState: <S extends StoreState>(defaultWindowProps?: Omit<WindowProps, "key">, debug?: boolean, state?: S) => S | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configureStore.d.ts","sourceRoot":"","sources":["../../src/configureStore.ts"],"names":[],"mappings":"AASA,OAAO,EACL,KAAK,MAAM,IAAI,UAAU,EAEzB,KAAK,qBAAqB,IAAI,QAAQ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SAAS,UAAU,GAAG,aAAa,EACpC,CAAC,SAAS,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EACvD,CAAC,SAAS,KAAK,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,EAE7C,OAAO,EAAE,qBAAqB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KACvC,OAAO,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,CAA0B,CAAC;AAEpE,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,UAAU,EACpD,qBAAqB,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,EAC7C,QAAQ,OAAO,EACf,QAAQ,CAAC,KACR,CAAC,GAAG,SAiBN,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { destructor } from '@synnaxlabs/x';
|
|
2
2
|
import { EffectCallback } from 'react';
|
|
3
3
|
/**
|
|
4
4
|
* A hook that allows a user to tap into the lifecycle of a window.
|
|
@@ -11,5 +11,5 @@ import { EffectCallback } from 'react';
|
|
|
11
11
|
* If not provided, the current window is used.
|
|
12
12
|
*/
|
|
13
13
|
export declare const useWindowLifecycle: (cb: EffectCallback, key?: string) => void;
|
|
14
|
-
export declare const useAsyncWindowLifecycle: (cb: () => Promise<
|
|
14
|
+
export declare const useAsyncWindowLifecycle: (cb: () => Promise<destructor.Async | undefined>, key?: string) => void;
|
|
15
15
|
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../src/react/hooks.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../src/react/hooks.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,KAAK,cAAc,EAAqB,MAAM,OAAO,CAAC;AAM/D;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,GAAI,IAAI,cAAc,EAAE,MAAM,MAAM,KAAG,IAoBrE,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAClC,IAAI,MAAM,OAAO,CAAC,UAAU,CAAC,KAAK,GAAG,SAAS,CAAC,EAC/C,MAAM,MAAM,KACX,IAmCF,CAAC"}
|