wenay-react2 1.0.45 → 1.0.46

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 (38) hide show
  1. package/README.md +4 -0
  2. package/doc/changes/v1.0.46.md +16 -0
  3. package/doc/examples/README.md +6 -0
  4. package/doc/examples/peer-call-media.tsx +8 -0
  5. package/doc/examples/stand.tsx +6 -0
  6. package/doc/progress/common2-adoption-1.0.74.md +24 -0
  7. package/doc/progress/stand-as-examples-audit.md +22 -0
  8. package/doc/target/my.md +12 -0
  9. package/doc/wenay-react2.md +1 -1
  10. package/lib/common/demo/peerMedia.d.ts +6 -0
  11. package/lib/common/demo/peerMedia.js +128 -0
  12. package/lib/common/src/components/Toolbar/Toolbar.d.ts +4 -0
  13. package/lib/common/src/components/Toolbar/Toolbar.js +16 -7
  14. package/lib/common/src/components/index.d.ts +12 -0
  15. package/lib/common/src/components/index.js +12 -0
  16. package/lib/common/src/grid/columnState/CardList.d.ts +2 -0
  17. package/lib/common/src/grid/columnState/CardList.js +1 -1
  18. package/lib/common/src/grid/columnState/ColumnsMenu.d.ts +2 -0
  19. package/lib/common/src/grid/columnState/ColumnsMenu.js +3 -2
  20. package/lib/common/src/grid/columnState/columnState.d.ts +15 -0
  21. package/lib/common/src/grid/columnState/columnState.js +53 -5
  22. package/lib/common/src/hooks/index.d.ts +1 -0
  23. package/lib/common/src/hooks/index.js +1 -0
  24. package/lib/common/src/hooks/usePeerCall.d.ts +68 -0
  25. package/lib/common/src/hooks/usePeerCall.js +79 -0
  26. package/lib/common/src/hooks/useReorder.d.ts +2 -0
  27. package/lib/common/src/hooks/useReorder.js +3 -1
  28. package/lib/common/src/utils/memoryStore.d.ts +2 -2
  29. package/lib/common/testUseReact/qa.d.ts +1 -0
  30. package/lib/common/testUseReact/qa.js +1148 -0
  31. package/lib/common/testUseReact/replayVideo.d.ts +14 -0
  32. package/lib/common/testUseReact/replayVideo.js +311 -0
  33. package/lib/common/testUseReact/testParams.d.ts +1 -0
  34. package/lib/common/testUseReact/testParams.js +15 -0
  35. package/lib/common/testUseReact/useGrid.d.ts +2 -0
  36. package/lib/common/testUseReact/useGrid.js +62 -0
  37. package/lib/style/style.css +24 -0
  38. package/package.json +5 -3
@@ -0,0 +1,68 @@
1
+ import { Peer } from "wenay-common2";
2
+ export type PeerPresence = {
3
+ account: string;
4
+ online: boolean;
5
+ };
6
+ /** React binding for common2 host presence. Subscribe before list(): `changes` is the
7
+ * authoritative edge stream and React does not create its own presence transport. */
8
+ export declare function usePeerPresence(presence: Peer.PeerRemote["presence"] | undefined): {
9
+ accounts: string[];
10
+ online: (account: string) => boolean;
11
+ };
12
+ /** Thin UI binding over common2 CallManager. Signaling, busy/glare policy, timeout,
13
+ * offline verdict and lifecycle ownership stay in common2; callers own manager.close(). */
14
+ export declare function usePeerCalls(manager: Peer.CallManager): {
15
+ ready: boolean;
16
+ active: {
17
+ id: string;
18
+ peer: string;
19
+ direction: "out" | "in";
20
+ meta: unknown;
21
+ state: () => Peer.tCallState;
22
+ reason: () => Peer.tCallEnd | null;
23
+ changed: import("wenay-common2").ListenApi<[Peer.tCallState]>;
24
+ ended: Promise<Peer.tCallEnd>;
25
+ accept(): void;
26
+ decline(why?: Peer.tCallEnd): void;
27
+ hangup(): void;
28
+ } | null;
29
+ rings: {
30
+ id: string;
31
+ peer: string;
32
+ direction: "out" | "in";
33
+ meta: unknown;
34
+ state: () => Peer.tCallState;
35
+ reason: () => Peer.tCallEnd | null;
36
+ changed: import("wenay-common2").ListenApi<[Peer.tCallState]>;
37
+ ended: Promise<Peer.tCallEnd>;
38
+ accept(): void;
39
+ decline(why?: Peer.tCallEnd): void;
40
+ hangup(): void;
41
+ }[];
42
+ calls: {
43
+ id: string;
44
+ peer: string;
45
+ direction: "out" | "in";
46
+ meta: unknown;
47
+ state: () => Peer.tCallState;
48
+ reason: () => Peer.tCallEnd | null;
49
+ changed: import("wenay-common2").ListenApi<[Peer.tCallState]>;
50
+ ended: Promise<Peer.tCallEnd>;
51
+ accept(): void;
52
+ decline(why?: Peer.tCallEnd): void;
53
+ hangup(): void;
54
+ }[];
55
+ call: (account: string, meta?: unknown) => {
56
+ id: string;
57
+ peer: string;
58
+ direction: "out" | "in";
59
+ meta: unknown;
60
+ state: () => Peer.tCallState;
61
+ reason: () => Peer.tCallEnd | null;
62
+ changed: import("wenay-common2").ListenApi<[Peer.tCallState]>;
63
+ ended: Promise<Peer.tCallEnd>;
64
+ accept(): void;
65
+ decline(why?: Peer.tCallEnd): void;
66
+ hangup(): void;
67
+ };
68
+ };
@@ -0,0 +1,79 @@
1
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
2
+ /** React binding for common2 host presence. Subscribe before list(): `changes` is the
3
+ * authoritative edge stream and React does not create its own presence transport. */
4
+ export function usePeerPresence(presence) {
5
+ const [accounts, setAccounts] = useState([]);
6
+ useEffect(() => {
7
+ if (!presence) {
8
+ setAccounts([]);
9
+ return;
10
+ }
11
+ let alive = true;
12
+ const off = presence.changes.on(({ account, online }) => {
13
+ if (!alive)
14
+ return;
15
+ setAccounts(current => online
16
+ ? current.includes(account) ? current : [...current, account].sort()
17
+ : current.filter(value => value !== account));
18
+ });
19
+ Promise.resolve(presence.list()).then(list => {
20
+ if (alive)
21
+ setAccounts([...new Set(list)].sort());
22
+ });
23
+ return () => { alive = false; off(); };
24
+ }, [presence]);
25
+ return useMemo(() => ({ accounts, online: (account) => accounts.includes(account) }), [accounts]);
26
+ }
27
+ /** Thin UI binding over common2 CallManager. Signaling, busy/glare policy, timeout,
28
+ * offline verdict and lifecycle ownership stay in common2; callers own manager.close(). */
29
+ export function usePeerCalls(manager) {
30
+ const calls = useRef(new Map());
31
+ const [version, setVersion] = useState(0);
32
+ const touch = useCallback(() => setVersion(value => value + 1), []);
33
+ useEffect(() => {
34
+ let alive = true;
35
+ const offs = new Map();
36
+ const watch = (call) => {
37
+ if (calls.current.has(call.id))
38
+ return;
39
+ calls.current.set(call.id, call);
40
+ offs.set(call.id, call.changed.on(touch));
41
+ void call.ended.then(() => {
42
+ offs.get(call.id)?.();
43
+ offs.delete(call.id);
44
+ calls.current.delete(call.id);
45
+ if (alive)
46
+ touch();
47
+ });
48
+ touch();
49
+ };
50
+ const offRings = manager.rings.on(watch);
51
+ void manager.ready.then(() => { if (alive)
52
+ touch(); });
53
+ return () => {
54
+ alive = false;
55
+ offRings();
56
+ offs.forEach(off => off());
57
+ calls.current.clear();
58
+ };
59
+ }, [manager, touch]);
60
+ const call = useCallback((account, meta) => {
61
+ const handle = manager.call(account, meta);
62
+ // Outgoing calls do not arrive through `rings`; register them immediately.
63
+ calls.current.set(handle.id, handle);
64
+ const off = handle.changed.on(touch);
65
+ void handle.ended.then(() => { off(); calls.current.delete(handle.id); touch(); });
66
+ touch();
67
+ return handle;
68
+ }, [manager, touch]);
69
+ return useMemo(() => {
70
+ const known = [...calls.current.values()];
71
+ return {
72
+ ready: version > 0,
73
+ active: manager.active(),
74
+ rings: known.filter(handle => handle.state() === "ringing"),
75
+ calls: known,
76
+ call,
77
+ };
78
+ }, [manager, call, version]);
79
+ }
@@ -27,6 +27,8 @@ export type ReorderOptions = {
27
27
  preview?: 'slots' | 'measure';
28
28
  /** hold before the drag starts (touch-friendly fields); default 0 */
29
29
  holdMs?: number;
30
+ /** transient simulated order while dragging; null on drop/cancel */
31
+ onPreviewChange?: (next: string[] | null) => void;
30
32
  };
31
33
  export type ReorderItem = {
32
34
  /** spread on the block element */
@@ -1,4 +1,4 @@
1
- import { useRef, useState } from 'react';
1
+ import { useEffect, useRef, useState } from 'react';
2
2
  import { useDraggableApi } from './useDraggable';
3
3
  export function useReorder(o) {
4
4
  const listRef = useRef(null);
@@ -96,6 +96,8 @@ export function useReorder(o) {
96
96
  const from = dragKey != null ? o.order.indexOf(dragKey) : -1;
97
97
  const target = from != -1 ? dragTarget(from, local(drag.position.x), local(drag.position.y)) : -1;
98
98
  const preview = from != -1 && dragKey != null ? move(o.order, dragKey, target) : null;
99
+ const previewKey = preview?.join("\u0000") ?? "";
100
+ useEffect(() => o.onPreviewChange?.(preview), [previewKey]);
99
101
  function item(key) {
100
102
  const active = preview != null;
101
103
  const dragging = key == dragKey;
@@ -27,8 +27,8 @@ export declare const memoryCache: {
27
27
  getArr: [k: string, v: Map<string, unknown>][];
28
28
  };
29
29
  export declare const memoryMaps: {
30
- rnd: ObservableMap<string, import("../components/Dnd").FloatingWindowSavedGeometry>;
30
+ rnd: ObservableMap<string, import("../components").FloatingWindowSavedGeometry>;
31
31
  resize: ObservableMap<string, import("./persistedMaps").ResizableSavedSize>;
32
- rightMenu: ObservableMap<string, import("../components/Menu").MenuRightSavedState>;
32
+ rightMenu: ObservableMap<string, import("../components").MenuRightSavedState>;
33
33
  other: ObservableMap<string, object>;
34
34
  };
@@ -0,0 +1 @@
1
+ export declare function QABoard(): import("react/jsx-runtime").JSX.Element;