@kolosal-ai/rivet 0.3.0 → 0.4.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/dist/anchor/index.d.ts +31 -4
- package/dist/anchor/index.js +22 -6
- package/dist/anchor/index.js.map +1 -1
- package/dist/chunk-TT2N7KWU.js +676 -0
- package/dist/chunk-TT2N7KWU.js.map +1 -0
- package/dist/{chunk-AXT35ZJV.js → chunk-W5HBJ4VF.js} +25 -3
- package/dist/chunk-W5HBJ4VF.js.map +1 -0
- package/dist/index.d.ts +138 -24
- package/dist/index.js +543 -129
- package/dist/index.js.map +1 -1
- package/dist/presence/index.d.ts +69 -4
- package/dist/presence/index.js +1 -1
- package/dist/{registry-CCBgd7FN.d.ts → registry-Z_oiPyjm.d.ts} +43 -2
- package/dist/svg/index.d.ts +18 -3
- package/dist/svg/index.js +5 -2
- package/dist/svg/index.js.map +1 -1
- package/dist/swimlane/index.d.ts +2 -2
- package/dist/{types-C9Vn1rzy.d.ts → types-D3aldmsO.d.ts} +27 -1
- package/dist/use-node-lock-CbS59CRE.d.ts +716 -0
- package/package.json +1 -1
- package/dist/chunk-A52HZWLH.js +0 -314
- package/dist/chunk-A52HZWLH.js.map +0 -1
- package/dist/chunk-AXT35ZJV.js.map +0 -1
- package/dist/use-node-lock-DH0dB1yA.d.ts +0 -327
package/dist/anchor/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CSSProperties, ReactNode } from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { A as AnchorRef } from '../registry-Z_oiPyjm.js';
|
|
3
|
+
export { a as ANCHOR_SIDES, b as AnchorGeometry, c as AnchorOptions, d as AnchorPoint, e as AnchorRecord, f as AnchorRegistration, g as AnchorRegistrationOptions, h as AnchorStrayPolicy, D as DEFAULT_ANCHOR_OPTIONS, R as ResolvedAnchorOptions, i as anchorAutoHandleId, j as anchorDotHandleId, k as anchorHandleId, l as anchorRect, m as computeAnchorGeometry, n as findSelectableAnchor, o as normalizeAnchorConnection, p as parseAnchorAutoHandleId, q as parseAnchorDotHandleId, r as parseAnchorHandleId, s as strayPlacementPct } from '../registry-Z_oiPyjm.js';
|
|
4
|
+
import '../types-D3aldmsO.js';
|
|
4
5
|
|
|
5
6
|
type AnchorProps = {
|
|
6
7
|
/**
|
|
@@ -10,6 +11,14 @@ type AnchorProps = {
|
|
|
10
11
|
id: string;
|
|
11
12
|
/** Accent color for the anchor's grab dots and stray handles. */
|
|
12
13
|
color?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Let a click on the wrapped content select the anchor. Off by default:
|
|
16
|
+
* inline anchors usually sit in editable text, where a press has to reach the
|
|
17
|
+
* caret rather than be claimed as a selection.
|
|
18
|
+
*/
|
|
19
|
+
selectable?: boolean;
|
|
20
|
+
/** Opaque payload kept on the anchor record and handed back with it. */
|
|
21
|
+
data?: unknown;
|
|
13
22
|
className?: string;
|
|
14
23
|
style?: CSSProperties;
|
|
15
24
|
children: ReactNode;
|
|
@@ -27,6 +36,24 @@ type AnchorProps = {
|
|
|
27
36
|
* explicit consumer action via `RivetInstance.unregisterAnchor` — e.g. when
|
|
28
37
|
* the content the anchor referred to is edited away for good.
|
|
29
38
|
*/
|
|
30
|
-
declare function Anchor({ id, color, className, style, children }: AnchorProps): React.ReactElement;
|
|
39
|
+
declare function Anchor({ id, color, selectable, data, className, style, children, }: AnchorProps): React.ReactElement;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The anchors this client has selected — a click on a shape inside an
|
|
43
|
+
* `<SvgArtwork>`, or on any `<Anchor selectable>` content.
|
|
44
|
+
*
|
|
45
|
+
* Anchor selection is view state, like hover and focus. An anchor isn't in the
|
|
46
|
+
* graph — it's read off rendered DOM — so selecting one emits no change,
|
|
47
|
+
* records nothing to history, and never appears in `RivetSelection`. That also
|
|
48
|
+
* means it can't be driven from props: this reports what the pointer did, and
|
|
49
|
+
* `setSelectedAnchors` on `useRivet()` is how you set it yourself.
|
|
50
|
+
*
|
|
51
|
+
* ```tsx
|
|
52
|
+
* const [anchor] = useSelectedAnchors()
|
|
53
|
+
* const record = anchor && rivet.getAnchor(anchor.nodeId, anchor.anchorId)
|
|
54
|
+
* return <Inspector shape={record?.data} />
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
declare function useSelectedAnchors(): readonly AnchorRef[];
|
|
31
58
|
|
|
32
|
-
export { Anchor, type AnchorProps };
|
|
59
|
+
export { Anchor, type AnchorProps, AnchorRef, useSelectedAnchors };
|
package/dist/anchor/index.js
CHANGED
|
@@ -1,21 +1,37 @@
|
|
|
1
|
-
export { ANCHOR_SIDES, DEFAULT_ANCHOR_OPTIONS, anchorAutoHandleId, anchorDotHandleId, anchorHandleId, computeAnchorGeometry, normalizeAnchorConnection, parseAnchorAutoHandleId, parseAnchorDotHandleId, parseAnchorHandleId, strayPlacementPct } from '../chunk-
|
|
1
|
+
export { ANCHOR_SIDES, DEFAULT_ANCHOR_OPTIONS, anchorAutoHandleId, anchorDotHandleId, anchorHandleId, anchorRect, computeAnchorGeometry, findSelectableAnchor, normalizeAnchorConnection, parseAnchorAutoHandleId, parseAnchorDotHandleId, parseAnchorHandleId, strayPlacementPct } from '../chunk-W5HBJ4VF.js';
|
|
2
2
|
import { useRivetContext, useRivetNodeContext } from '../chunk-VQYN27OK.js';
|
|
3
|
-
import { useRef, useLayoutEffect } from 'react';
|
|
3
|
+
import { useRef, useLayoutEffect, useSyncExternalStore } from 'react';
|
|
4
4
|
import { jsx } from 'react/jsx-runtime';
|
|
5
5
|
|
|
6
|
-
function Anchor({
|
|
6
|
+
function Anchor({
|
|
7
|
+
id,
|
|
8
|
+
color,
|
|
9
|
+
selectable,
|
|
10
|
+
data,
|
|
11
|
+
className,
|
|
12
|
+
style,
|
|
13
|
+
children
|
|
14
|
+
}) {
|
|
7
15
|
const { store } = useRivetContext();
|
|
8
16
|
const { nodeId } = useRivetNodeContext();
|
|
9
17
|
const ref = useRef(null);
|
|
10
18
|
useLayoutEffect(() => {
|
|
11
19
|
const el = ref.current;
|
|
12
20
|
if (!el) return;
|
|
13
|
-
store.registerAnchor(nodeId, id, el, color
|
|
21
|
+
store.registerAnchor(nodeId, id, el, { color, selectable, data });
|
|
14
22
|
return () => store.detachAnchor(nodeId, id);
|
|
15
|
-
}, [store, nodeId, id, color]);
|
|
23
|
+
}, [store, nodeId, id, color, selectable, data]);
|
|
16
24
|
return /* @__PURE__ */ jsx("span", { ref, "data-rivet-anchor": id, className, style, children });
|
|
17
25
|
}
|
|
26
|
+
function useSelectedAnchors() {
|
|
27
|
+
const { store } = useRivetContext();
|
|
28
|
+
return useSyncExternalStore(
|
|
29
|
+
store.subscribeAnchorSelection,
|
|
30
|
+
store.getSelectedAnchors,
|
|
31
|
+
store.getSelectedAnchors
|
|
32
|
+
);
|
|
33
|
+
}
|
|
18
34
|
|
|
19
|
-
export { Anchor };
|
|
35
|
+
export { Anchor, useSelectedAnchors };
|
|
20
36
|
//# sourceMappingURL=index.js.map
|
|
21
37
|
//# sourceMappingURL=index.js.map
|
package/dist/anchor/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/anchor.tsx"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"sources":["../../src/components/anchor.tsx","../../src/hooks/use-selected-anchors.ts"],"names":[],"mappings":";;;;;AAqCO,SAAS,MAAA,CAAO;AAAA,EACrB,EAAA;AAAA,EACA,KAAA;AAAA,EACA,UAAA;AAAA,EACA,IAAA;AAAA,EACA,SAAA;AAAA,EACA,KAAA;AAAA,EACA;AACF,CAAA,EAAoC;AAClC,EAAA,MAAM,EAAE,KAAA,EAAM,GAAI,eAAA,EAAgB;AAClC,EAAA,MAAM,EAAE,MAAA,EAAO,GAAI,mBAAA,EAAoB;AACvC,EAAA,MAAM,GAAA,GAAM,OAAwB,IAAI,CAAA;AAExC,EAAA,eAAA,CAAgB,MAAM;AACpB,IAAA,MAAM,KAAK,GAAA,CAAI,OAAA;AACf,IAAA,IAAI,CAAC,EAAA,EAAI;AACT,IAAA,KAAA,CAAM,cAAA,CAAe,QAAQ,EAAA,EAAI,EAAA,EAAI,EAAE,KAAA,EAAO,UAAA,EAAY,MAAM,CAAA;AAChE,IAAA,OAAO,MAAM,KAAA,CAAM,YAAA,CAAa,MAAA,EAAQ,EAAE,CAAA;AAAA,EAC5C,CAAA,EAAG,CAAC,KAAA,EAAO,MAAA,EAAQ,IAAI,KAAA,EAAO,UAAA,EAAY,IAAI,CAAC,CAAA;AAE/C,EAAA,2BACG,MAAA,EAAA,EAAK,GAAA,EAAU,qBAAmB,EAAA,EAAI,SAAA,EAAsB,OAC1D,QAAA,EACH,CAAA;AAEJ;AC1CO,SAAS,kBAAA,GAA2C;AACzD,EAAA,MAAM,EAAE,KAAA,EAAM,GAAI,eAAA,EAAgB;AAClC,EAAA,OAAO,oBAAA;AAAA,IACL,KAAA,CAAM,wBAAA;AAAA,IACN,KAAA,CAAM,kBAAA;AAAA,IACN,KAAA,CAAM;AAAA,GACR;AACF","file":"index.js","sourcesContent":["import { type CSSProperties, type ReactNode, useLayoutEffect, useRef } from \"react\"\nimport { useRivetContext, useRivetNodeContext } from \"../context\"\n\nexport type AnchorProps = {\n /**\n * Identifies the anchor within its node. Persisted edge handle ids derive\n * from it, so keep it stable across renders and sessions.\n */\n id: string\n /** Accent color for the anchor's grab dots and stray handles. */\n color?: string\n /**\n * Let a click on the wrapped content select the anchor. Off by default:\n * inline anchors usually sit in editable text, where a press has to reach the\n * caret rather than be claimed as a selection.\n */\n selectable?: boolean\n /** Opaque payload kept on the anchor record and handed back with it. */\n data?: unknown\n className?: string\n style?: CSSProperties\n children: ReactNode\n}\n\n/**\n * Declarative anchor registration — wraps any inline content rendered inside a\n * node and binds it as a connectable point. Sugar over the imperative registry\n * (`RivetInstance.registerAnchor`) for consumers whose React tree owns the\n * DOM; the wrapper is a plain unstyled `<span>`, so it doesn't affect inline\n * layout. Rivet measures the span's line boxes and renders grab dots and stray\n * perimeter handles as overlay chrome — nothing is injected here.\n *\n * Unmounting **detaches** the anchor (stale retention: geometry and edges stay\n * put, for display/editor swaps) rather than unregistering it. Removal is an\n * explicit consumer action via `RivetInstance.unregisterAnchor` — e.g. when\n * the content the anchor referred to is edited away for good.\n */\nexport function Anchor({\n id,\n color,\n selectable,\n data,\n className,\n style,\n children,\n}: AnchorProps): React.ReactElement {\n const { store } = useRivetContext()\n const { nodeId } = useRivetNodeContext()\n const ref = useRef<HTMLSpanElement>(null)\n\n useLayoutEffect(() => {\n const el = ref.current\n if (!el) return\n store.registerAnchor(nodeId, id, el, { color, selectable, data })\n return () => store.detachAnchor(nodeId, id)\n }, [store, nodeId, id, color, selectable, data])\n\n return (\n <span ref={ref} data-rivet-anchor={id} className={className} style={style}>\n {children}\n </span>\n )\n}\n","import { useSyncExternalStore } from \"react\"\nimport type { AnchorRef } from \"../anchor/registry\"\nimport { useRivetContext } from \"../context\"\n\n/**\n * The anchors this client has selected — a click on a shape inside an\n * `<SvgArtwork>`, or on any `<Anchor selectable>` content.\n *\n * Anchor selection is view state, like hover and focus. An anchor isn't in the\n * graph — it's read off rendered DOM — so selecting one emits no change,\n * records nothing to history, and never appears in `RivetSelection`. That also\n * means it can't be driven from props: this reports what the pointer did, and\n * `setSelectedAnchors` on `useRivet()` is how you set it yourself.\n *\n * ```tsx\n * const [anchor] = useSelectedAnchors()\n * const record = anchor && rivet.getAnchor(anchor.nodeId, anchor.anchorId)\n * return <Inspector shape={record?.data} />\n * ```\n */\nexport function useSelectedAnchors(): readonly AnchorRef[] {\n const { store } = useRivetContext()\n return useSyncExternalStore(\n store.subscribeAnchorSelection,\n store.getSelectedAnchors,\n store.getSelectedAnchors,\n )\n}\n"]}
|