@ntcore-ts/react 1.0.0-beta.2 → 1.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ntcore-ts/react",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0",
4
4
  "description": "React bindings for @ntcore-ts/client (NetworkTables for FRC)",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/dist/index.d.ts DELETED
@@ -1,14 +0,0 @@
1
- export { NtcoreContext, NtcoreProvider, useNtcore } from './lib/context';
2
- export type { NtcoreProviderProps } from './lib/context';
3
- export { useTopic } from './lib/use-topic';
4
- export type { UseTopicOptions, UseTopicResult } from './lib/use-topic';
5
- export { usePrefixTopic, usePrefixTopicMap } from './lib/use-prefix-topic';
6
- export type { PrefixTopicUpdate, PrefixTopicMapEntry } from './lib/use-prefix-topic';
7
- export { useProtobufTopic } from './lib/use-protobuf-topic';
8
- export type { UseProtobufTopicOptions, UseProtobufTopicResult } from './lib/use-protobuf-topic';
9
- export { useStructTopic } from './lib/use-struct-topic';
10
- export type { UseStructTopicOptions, UseStructTopicTypeOptions, UseStructTopicResult } from './lib/use-struct-topic';
11
- export { useConnectionStatus } from './lib/use-connection-status';
12
- export type { NetworkTablesTypeInfo, NetworkTablesTypes, SubscribeOptions, TopicProperties, RobotPlatform, ParsedRobotAddress, } from '@ntcore-ts/client';
13
- export { NetworkTables, NetworkTablesTypeInfos, LogLevel, getRobotAddress, getTeamIpAddress, parseRobotAddress, SYSTEMCORE_MDNS_HOST, } from '@ntcore-ts/client';
14
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACzE,YAAY,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3E,YAAY,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,YAAY,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAChG,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,YAAY,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACrH,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAElE,YAAY,EACV,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,QAAQ,EACR,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC"}
package/dist/index.esm.js DELETED
@@ -1,516 +0,0 @@
1
- import { jsx } from 'react/jsx-runtime';
2
- import { createContext, useMemo, useEffect, useContext, useRef, useState, useCallback } from 'react';
3
- import { NetworkTables, isStructTypeDescriptor } from '@ntcore-ts/client';
4
- export { LogLevel, NetworkTables, NetworkTablesTypeInfos, SYSTEMCORE_MDNS_HOST, getRobotAddress, getTeamIpAddress, parseRobotAddress } from '@ntcore-ts/client';
5
-
6
- const NtcoreContext = createContext(null);
7
- const DEFAULT_PORT = 5810;
8
- const INVALID_PORT_MESSAGE = 'NtcoreProvider port must be a whole number between 1 and 65535 (e.g. 5810). Check your port value or environment variable.';
9
- const MISSING_PROVIDER_MESSAGE = 'useNtcore must be used within NtcoreProvider';
10
- function isValidPort(port) {
11
- return Number.isFinite(port) && port === Math.floor(port) && port >= 1 && port <= 65535;
12
- }
13
- /** @internal */
14
- function toError(value) {
15
- return value instanceof Error ? value : new Error(String(value));
16
- }
17
- function lookupNetworkTables(team, uri, port, platform) {
18
- if (team != null) {
19
- return platform != null
20
- ? NetworkTables.getInstanceByTeam(team, port, platform)
21
- : NetworkTables.getInstanceByTeam(team, port);
22
- }
23
- if (uri != null) {
24
- return NetworkTables.getInstanceByURI(uri, port);
25
- }
26
- throw new Error('NtcoreProvider requires either team or uri.');
27
- }
28
- /**
29
- * Provides a NetworkTables instance to the component tree. Must specify either
30
- * `team` (robot team number) or `uri` (e.g. "localhost" or "roborio-973-frc.local").
31
- * Use `useNtcore()` in descendants to access the instance.
32
- * Invalid port (NaN, non-integer, or outside 1–65535) throws so misconfiguration is caught early.
33
- *
34
- * When using `team`, optional `platform` selects RoboRIO mDNS (default) or SystemCore `10.TE.AM.2`.
35
- *
36
- * Changing `team`, `uri`, `port`, or `platform` switches to the corresponding NetworkTables singleton.
37
- * The previous instance is released (closed when no other provider still retains it).
38
- */
39
- function NtcoreProvider({ children, port = DEFAULT_PORT, ...rest }) {
40
- const effectivePort = useMemo(() => {
41
- if (!isValidPort(port)) {
42
- throw new Error(INVALID_PORT_MESSAGE);
43
- }
44
- return port;
45
- }, [port]);
46
- const team = 'team' in rest ? rest.team : undefined;
47
- const uri = 'uri' in rest ? rest.uri : undefined;
48
- const platform = 'platform' in rest ? rest.platform : undefined;
49
- const nt = useMemo(() => lookupNetworkTables(team, uri, effectivePort, platform), [team, uri, effectivePort, platform]);
50
- useEffect(() => {
51
- nt.retain();
52
- return () => nt.release();
53
- }, [nt]);
54
- return jsx(NtcoreContext.Provider, { value: nt, children: children });
55
- }
56
- /**
57
- * Returns the NetworkTables instance from the nearest NtcoreProvider.
58
- * Throws when used outside a provider.
59
- */
60
- function useNtcore() {
61
- const nt = useContext(NtcoreContext);
62
- if (nt === null) {
63
- throw new Error(MISSING_PROVIDER_MESSAGE);
64
- }
65
- return nt;
66
- }
67
-
68
- const publishOwnerTokens = new WeakMap();
69
- function trackPublish(promise) {
70
- const tracked = { promise, settled: false };
71
- void promise.finally(() => {
72
- tracked.settled = true;
73
- });
74
- return tracked;
75
- }
76
- /** Marks this effect as the current publisher owner of a shared topic. */
77
- function claimPublishOwner(topic) {
78
- const token = (publishOwnerTokens.get(topic) ?? 0) + 1;
79
- publishOwnerTokens.set(topic, token);
80
- return token;
81
- }
82
- /** Unpublish after an in-flight publish settles so unmount cannot leave a ghost publisher. */
83
- function unpublishWhenDone(topic, tracked, setError, ownerToken) {
84
- const run = () => {
85
- if (publishOwnerTokens.get(topic) !== ownerToken)
86
- return;
87
- if (topic.pubuid == null)
88
- return;
89
- try {
90
- topic.unpublish();
91
- }
92
- catch (e) {
93
- setError(toError(e));
94
- }
95
- };
96
- if (!tracked || tracked.settled) {
97
- run();
98
- return;
99
- }
100
- void tracked.promise.finally(run);
101
- }
102
-
103
- /** Keeps a ref pointed at the latest value without writing to it during render. */
104
- function useLatestRef(value) {
105
- const ref = useRef(value);
106
- useEffect(() => {
107
- ref.current = value;
108
- });
109
- return ref;
110
- }
111
-
112
- function useTopic(name, typeInfo, options) {
113
- const nt = useNtcore();
114
- const publishOpt = options?.publish;
115
- const typeNum = typeInfo[0];
116
- const typeStr = typeInfo[1];
117
- const [state, setState] = useState(options?.defaultValue ?? null);
118
- const [isReadyToWrite, setIsReadyToWrite] = useState(false);
119
- const [error, setError] = useState(null);
120
- const [identity, setIdentity] = useState({ nt, name, typeNum, typeStr });
121
- const optionsRef = useLatestRef(options);
122
- if (nt !== identity.nt || name !== identity.name || typeNum !== identity.typeNum || typeStr !== identity.typeStr) {
123
- setIdentity({ nt, name, typeNum, typeStr });
124
- setState(options?.defaultValue ?? null);
125
- setIsReadyToWrite(false);
126
- setError(null);
127
- }
128
- useEffect(() => {
129
- let cancelled = false;
130
- const topic = typeInfo[1] === 'json'
131
- ? nt.getJsonTopic(name, optionsRef.current?.defaultValue)
132
- : nt.createTopic(name, typeInfo, optionsRef.current?.defaultValue);
133
- const subuid = topic.subscribe((v) => {
134
- if (cancelled)
135
- return;
136
- try {
137
- setState(v);
138
- }
139
- catch (e) {
140
- setError(toError(e));
141
- }
142
- }, optionsRef.current?.subscribeOptions ?? undefined);
143
- const publish = optionsRef.current?.publish;
144
- const unpublishOnUnmount = optionsRef.current?.unpublishOnUnmount ?? publish !== undefined;
145
- const shouldPublish = publish !== undefined;
146
- let trackedPublish;
147
- let ownerToken;
148
- if (shouldPublish) {
149
- ownerToken = claimPublishOwner(topic);
150
- const properties = publish === true ? {} : publish;
151
- trackedPublish = trackPublish(topic
152
- .publish(properties)
153
- .then(() => {
154
- if (!cancelled)
155
- setIsReadyToWrite(true);
156
- })
157
- .catch((e) => {
158
- if (!cancelled)
159
- setError(toError(e));
160
- }));
161
- }
162
- return () => {
163
- cancelled = true;
164
- topic.unsubscribe(subuid);
165
- if (shouldPublish && unpublishOnUnmount && ownerToken !== undefined) {
166
- unpublishWhenDone(topic, trackedPublish, setError, ownerToken);
167
- }
168
- };
169
- }, [nt, name, typeNum, typeStr, optionsRef, typeInfo]);
170
- const setValueCb = useCallback((value) => {
171
- const publish = optionsRef.current?.publish;
172
- if (publish !== undefined && !isReadyToWrite)
173
- return;
174
- try {
175
- const topic = typeInfo[1] === 'json'
176
- ? nt.getJsonTopic(name, optionsRef.current?.defaultValue)
177
- : nt.createTopic(name, typeInfo, optionsRef.current?.defaultValue);
178
- topic.setValue(value);
179
- }
180
- catch (e) {
181
- setError(toError(e));
182
- }
183
- }, [nt, name, typeInfo, isReadyToWrite, optionsRef]);
184
- const setValue = publishOpt !== undefined ? setValueCb : undefined;
185
- return { value: state, setValue, isReadyToWrite, error };
186
- }
187
-
188
- /**
189
- * Shared subscription to a prefix topic. Calls onUpdate for each announcement.
190
- * Callbacks and subscribe options are ref-backed so the subscription stays stable.
191
- */
192
- function usePrefixTopicSubscription(prefix, subscribeOptions, onUpdate) {
193
- const nt = useNtcore();
194
- const onUpdateRef = useLatestRef(onUpdate);
195
- const subscribeOptionsRef = useLatestRef(subscribeOptions);
196
- useEffect(() => {
197
- const topic = nt.getPrefixTopic(prefix);
198
- const subuid = topic.subscribe((value, params) => {
199
- try {
200
- onUpdateRef.current(params.name, value, params.type);
201
- }
202
- catch {
203
- /* consumer callback threw */
204
- }
205
- }, subscribeOptionsRef.current ?? undefined);
206
- return () => topic.unsubscribe(subuid);
207
- }, [nt, prefix, onUpdateRef, subscribeOptionsRef]);
208
- }
209
- /**
210
- * Subscribes to all topics under a NetworkTables prefix and returns only the **latest** update.
211
- * Each new update replaces the previous one in state; rapid updates result in only the most
212
- * recent being visible. Use for "react to any change under prefix" or "show last activity."
213
- * For a full map of all topics under a prefix (e.g. to list or iterate), use `usePrefixTopicMap` instead.
214
- *
215
- * Unsubscribes on unmount. Prefix topics are subscribe-only.
216
- *
217
- * @param prefix - Topic prefix (e.g. "/SmartDashboard" or "/" for all).
218
- * @param subscribeOptions - Optional subscribe options (e.g. { periodic: 0.02 }).
219
- * @returns Latest update `{ name, value, type }` or null before first update.
220
- */
221
- function usePrefixTopic(prefix, subscribeOptions) {
222
- const nt = useNtcore();
223
- const [state, setState] = useState(null);
224
- const [identity, setIdentity] = useState({ nt, prefix });
225
- if (nt !== identity.nt || prefix !== identity.prefix) {
226
- setIdentity({ nt, prefix });
227
- setState(null);
228
- }
229
- usePrefixTopicSubscription(prefix, subscribeOptions, (name, value, type) => setState({ name, value, type }));
230
- return state;
231
- }
232
- /**
233
- * Subscribes to all topics under a NetworkTables prefix and returns a map of every
234
- * topic name to its latest value and NT type. Updates are batched with requestAnimationFrame so
235
- * rapid announcements all appear. Use when you need to list or iterate over all topics
236
- * (e.g. an "all topics" table). For only the latest single update, use `usePrefixTopic` instead.
237
- *
238
- * Unsubscribes on unmount. Prefix topics are subscribe-only.
239
- *
240
- * @param prefix - Topic prefix (e.g. "/SmartDashboard" or "/" for all).
241
- * @param subscribeOptions - Optional subscribe options (e.g. { periodic: 0.02 }).
242
- * @returns Map of topic name to `{ value, type }`. Empty object after first flush when no topics yet.
243
- */
244
- function usePrefixTopicMap(prefix, subscribeOptions) {
245
- const nt = useNtcore();
246
- const [byName, setByName] = useState({});
247
- const [identity, setIdentity] = useState({ nt, prefix });
248
- const pendingRef = useRef({});
249
- const rafRef = useRef(null);
250
- const [mapGeneration, setMapGeneration] = useState(0);
251
- const mapGenerationRef = useLatestRef(mapGeneration);
252
- if (nt !== identity.nt || prefix !== identity.prefix) {
253
- setIdentity({ nt, prefix });
254
- setByName({});
255
- setMapGeneration((g) => g + 1);
256
- }
257
- const flush = useRef(() => {
258
- rafRef.current = null;
259
- const next = pendingRef.current;
260
- if (Object.keys(next).length > 0) {
261
- pendingRef.current = {};
262
- setByName((prev) => ({ ...prev, ...next }));
263
- }
264
- }).current;
265
- useEffect(() => {
266
- pendingRef.current = {};
267
- return () => {
268
- if (rafRef.current != null) {
269
- cancelAnimationFrame(rafRef.current);
270
- rafRef.current = null;
271
- }
272
- pendingRef.current = {};
273
- };
274
- }, [nt, prefix]);
275
- usePrefixTopicSubscription(prefix, subscribeOptions, (name, value, type) => {
276
- if (!name.startsWith(prefix))
277
- return;
278
- pendingRef.current[name] = { value, type };
279
- if (rafRef.current == null) {
280
- const scheduledFor = mapGenerationRef.current;
281
- rafRef.current = requestAnimationFrame(() => {
282
- rafRef.current = null;
283
- if (mapGenerationRef.current !== scheduledFor)
284
- return;
285
- flush();
286
- });
287
- }
288
- });
289
- return byName;
290
- }
291
-
292
- /**
293
- * Subscribes to a NetworkTables protobuf topic and returns the latest decoded value.
294
- * Unsubscribes on unmount.
295
- *
296
- * **Reading only:** Omit `publish` in options. You get `{ value, setValue: undefined, isReadyToWrite: false }`.
297
- *
298
- * **Reading and writing:** Pass `publish: true` or `publish: { retained: true }` (etc.) in options.
299
- * You get `{ value, setValue, isReadyToWrite }`. Only call setValue when isReadyToWrite is true.
300
- *
301
- * Subscription is re-created only when `nt` or `name` change. Optional options are read at subscribe time.
302
- *
303
- * @param name - Topic name (e.g. "/MyTable/Pose").
304
- * @param options - Optional defaultValue, validator, protoFilePath, protoSource, messageType, subscribeOptions, publish.
305
- * @returns { value, setValue, isReadyToWrite, error }.
306
- */
307
- function useProtobufTopic(name, options) {
308
- const nt = useNtcore();
309
- const [state, setState] = useState(options?.defaultValue ?? null);
310
- const [isReadyToWrite, setIsReadyToWrite] = useState(false);
311
- const [error, setError] = useState(null);
312
- const [identity, setIdentity] = useState({ nt, name });
313
- const optionsRef = useLatestRef(options);
314
- if (nt !== identity.nt || name !== identity.name) {
315
- setIdentity({ nt, name });
316
- setState(options?.defaultValue ?? null);
317
- setIsReadyToWrite(false);
318
- setError(null);
319
- }
320
- useEffect(() => {
321
- let cancelled = false;
322
- const topic = nt.getProtobufTopic(name, optionsRef.current);
323
- const subuid = topic.subscribe((v) => {
324
- if (cancelled)
325
- return;
326
- try {
327
- setState(v ?? null);
328
- }
329
- catch (e) {
330
- setError(toError(e));
331
- }
332
- }, optionsRef.current?.subscribeOptions ?? undefined);
333
- const publish = optionsRef.current?.publish;
334
- const unpublishOnUnmount = optionsRef.current?.unpublishOnUnmount ?? publish !== undefined;
335
- const shouldPublish = publish !== undefined;
336
- let trackedPublish;
337
- let ownerToken;
338
- if (shouldPublish) {
339
- ownerToken = claimPublishOwner(topic);
340
- const properties = publish === true ? {} : publish;
341
- trackedPublish = trackPublish(topic
342
- .publish(properties)
343
- .then(() => {
344
- if (!cancelled)
345
- setIsReadyToWrite(true);
346
- })
347
- .catch((e) => {
348
- if (!cancelled)
349
- setError(toError(e));
350
- }));
351
- }
352
- return () => {
353
- cancelled = true;
354
- topic.unsubscribe(subuid);
355
- if (shouldPublish && unpublishOnUnmount && ownerToken !== undefined) {
356
- unpublishWhenDone(topic, trackedPublish, setError, ownerToken);
357
- }
358
- };
359
- }, [nt, name, optionsRef]);
360
- const setValueCb = useCallback((value) => {
361
- const publish = optionsRef.current?.publish;
362
- if (publish !== undefined && !isReadyToWrite)
363
- return;
364
- try {
365
- const topic = nt.getProtobufTopic(name, optionsRef.current);
366
- topic.setValue(value);
367
- }
368
- catch (e) {
369
- setError(toError(e));
370
- }
371
- }, [nt, name, isReadyToWrite, optionsRef]);
372
- const setValue = options?.publish !== undefined ? setValueCb : undefined;
373
- return { value: state, setValue, isReadyToWrite, error };
374
- }
375
-
376
- function toStructTopicOptions(options) {
377
- return {
378
- ...(options.typeName !== undefined ? { typeName: options.typeName } : {}),
379
- ...(options.validator !== undefined ? { validator: options.validator } : {}),
380
- ...(options.defaultValue !== undefined ? { defaultValue: options.defaultValue } : {}),
381
- ...(options.schema !== undefined ? { schema: options.schema } : {}),
382
- };
383
- }
384
- function useStructTopic(name, typeOrOptions, maybeOptions) {
385
- const resolved = isStructTypeDescriptor(typeOrOptions)
386
- ? {
387
- typeName: typeOrOptions.typeName,
388
- validator: typeOrOptions.schema,
389
- ...maybeOptions,
390
- }
391
- : (typeOrOptions ?? {});
392
- const nt = useNtcore();
393
- const [state, setState] = useState(resolved.defaultValue ?? null);
394
- const [isReadyToWrite, setIsReadyToWrite] = useState(false);
395
- const [error, setError] = useState(null);
396
- const [identity, setIdentity] = useState({ nt, name, typeName: resolved.typeName });
397
- const optionsRef = useLatestRef(resolved);
398
- const typeOrOptionsRef = useLatestRef(typeOrOptions);
399
- const maybeOptionsRef = useLatestRef(maybeOptions);
400
- if (nt !== identity.nt || name !== identity.name || resolved.typeName !== identity.typeName) {
401
- setIdentity({ nt, name, typeName: resolved.typeName });
402
- setState(resolved.defaultValue ?? null);
403
- setIsReadyToWrite(false);
404
- setError(null);
405
- }
406
- const getTopic = useCallback(() => {
407
- const arg = typeOrOptionsRef.current;
408
- if (isStructTypeDescriptor(arg)) {
409
- return nt.getStructTopic(name, arg, maybeOptionsRef.current);
410
- }
411
- return nt.getStructTopic(name, toStructTopicOptions(optionsRef.current));
412
- }, [nt, name, typeOrOptionsRef, maybeOptionsRef, optionsRef]);
413
- useEffect(() => {
414
- let cancelled = false;
415
- const topic = getTopic();
416
- const subuid = topic.subscribe((v) => {
417
- if (cancelled)
418
- return;
419
- try {
420
- setState((v ?? null));
421
- }
422
- catch (e) {
423
- setError(toError(e));
424
- }
425
- }, optionsRef.current.subscribeOptions ?? undefined);
426
- const publish = optionsRef.current.publish;
427
- const unpublishOnUnmount = optionsRef.current.unpublishOnUnmount ?? publish !== undefined;
428
- const shouldPublish = publish !== undefined;
429
- let trackedPublish;
430
- let ownerToken;
431
- if (shouldPublish) {
432
- ownerToken = claimPublishOwner(topic);
433
- const properties = publish === true ? {} : publish;
434
- trackedPublish = trackPublish(topic
435
- .publish(properties)
436
- .then(() => {
437
- if (!cancelled)
438
- setIsReadyToWrite(true);
439
- })
440
- .catch((e) => {
441
- if (!cancelled)
442
- setError(toError(e));
443
- }));
444
- }
445
- return () => {
446
- cancelled = true;
447
- topic.unsubscribe(subuid);
448
- if (shouldPublish && unpublishOnUnmount && ownerToken !== undefined) {
449
- unpublishWhenDone(topic, trackedPublish, setError, ownerToken);
450
- }
451
- };
452
- }, [nt, name, resolved.typeName, getTopic, optionsRef]);
453
- const setValueCb = useCallback((value) => {
454
- const publish = optionsRef.current.publish;
455
- if (publish !== undefined && !isReadyToWrite)
456
- return;
457
- try {
458
- getTopic().setValue(value);
459
- }
460
- catch (e) {
461
- setError(toError(e));
462
- }
463
- }, [isReadyToWrite, getTopic, optionsRef]);
464
- const setValue = resolved.publish !== undefined ? setValueCb : undefined;
465
- return { value: state, setValue, isReadyToWrite, error };
466
- }
467
-
468
- const STATUS_POLL_MS = 1000;
469
- /**
470
- * Subscribes to robot connection status and returns the current state. Listener is removed on unmount.
471
- * When connected, RTT (round-trip time in ms) is polled periodically; -1 when not connected or not yet measured.
472
- * When disconnected, `connecting` reflects `NetworkTables.isRobotConnecting()`.
473
- *
474
- * @returns { connected, connecting, rtt }.
475
- */
476
- function useConnectionStatus() {
477
- const nt = useNtcore();
478
- const [listenerConnected, setListenerConnected] = useState(false);
479
- const [connecting, setConnecting] = useState(() => nt.isRobotConnecting());
480
- const [rtt, setRtt] = useState(-1);
481
- const [identity, setIdentity] = useState(nt);
482
- if (nt !== identity) {
483
- setIdentity(nt);
484
- setListenerConnected(false);
485
- setConnecting(nt.isRobotConnecting());
486
- setRtt(-1);
487
- }
488
- useEffect(() => {
489
- const remove = nt.addRobotConnectionListener(setListenerConnected, true);
490
- return remove;
491
- }, [nt]);
492
- useEffect(() => {
493
- if (listenerConnected)
494
- return;
495
- const updateConnecting = () => setConnecting(nt.isRobotConnecting());
496
- updateConnecting();
497
- const interval = setInterval(updateConnecting, STATUS_POLL_MS);
498
- return () => clearInterval(interval);
499
- }, [nt, listenerConnected]);
500
- useEffect(() => {
501
- if (!listenerConnected)
502
- return;
503
- const updateRtt = () => setRtt(nt.getRttMs());
504
- updateRtt();
505
- const interval = setInterval(updateRtt, STATUS_POLL_MS);
506
- return () => clearInterval(interval);
507
- }, [nt, listenerConnected]);
508
- return {
509
- connected: listenerConnected,
510
- connecting: listenerConnected ? false : connecting,
511
- rtt: listenerConnected ? rtt : -1,
512
- };
513
- }
514
-
515
- export { NtcoreContext, NtcoreProvider, useConnectionStatus, useNtcore, usePrefixTopic, usePrefixTopicMap, useProtobufTopic, useStructTopic, useTopic };
516
- //# sourceMappingURL=index.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/lib/context.tsx","../src/lib/unpublish-when-done.ts","../src/lib/use-latest-ref.ts","../src/lib/use-topic.ts","../src/lib/use-prefix-topic.ts","../src/lib/use-protobuf-topic.ts","../src/lib/use-struct-topic.ts","../src/lib/use-connection-status.ts"],"sourcesContent":[null,null,null,null,null,null,null,null],"names":["_jsx"],"mappings":";;;;;MAGa,aAAa,GAAG,aAAa,CAAuB,IAAI;AAwBrE,MAAM,YAAY,GAAG,IAAI;AAEzB,MAAM,oBAAoB,GACxB,4HAA4H;AAE9H,MAAM,wBAAwB,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AAS,CAAC,MAAK;QACb,MAAM,MAAM,GAAG,EAAE,CAAC,0BAA0B,CAAC,oBAAoB,EAAE,IAAI,CAAC;AACxE,QAAA,OAAO,MAAM;AACf,IAAA,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAER,SAAS,CAAC,MAAK;AACb,QAAA,IAAI,iBAAiB;YAAE;AACvB,QAAA,MAAM,gBAAgB,GAAG,MAAM,aAAa,CAAC,EAAE,CAAC,iBAAiB,EAAE,CAAC;AACpE,QAAA,gBAAgB,EAAE;QAClB,MAAM,QAAQ,GAAG,WAAW,CAAC,gBAAgB,EAAE,cAAc,CAAC;AAC9D,QAAA,OAAO,MAAM,aAAa,CAAC,QAAQ,CAAC;AACtC,IAAA,CAAC,EAAE,CAAC,EAAE,EAAE,iBAAiB,CAAC,CAAC;IAE3B,SAAS,CAAC,MAAK;AACb,QAAA,IAAI,CAAC,iBAAiB;YAAE;AACxB,QAAA,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC;AAC7C,QAAA,SAAS,EAAE;QACX,MAAM,QAAQ,GAAG,WAAW,CAAC,SAAS,EAAE,cAAc,CAAC;AACvD,QAAA,OAAO,MAAM,aAAa,CAAC,QAAQ,CAAC;AACtC,IAAA,CAAC,EAAE,CAAC,EAAE,EAAE,iBAAiB,CAAC,CAAC;IAE3B,OAAO;AACL,QAAA,SAAS,EAAE,iBAAiB;QAC5B,UAAU,EAAE,iBAAiB,GAAG,KAAK,GAAG,UAAU;QAClD,GAAG,EAAE,iBAAiB,GAAG,GAAG,GAAG,EAAE;KAClC;AACH;;"}
@@ -1,41 +0,0 @@
1
- import { type ReactNode } from 'react';
2
- import { NetworkTables, type RobotPlatform } from '@ntcore-ts/client';
3
- export declare const NtcoreContext: import("react").Context<NetworkTables | null>;
4
- export type NtcoreProviderProps = {
5
- children: ReactNode;
6
- } & ({
7
- /** FRC team number used to resolve the robot host. */
8
- team: number;
9
- uri?: never;
10
- /** NT server port (default `5810`). */
11
- port?: number;
12
- /** RoboRIO mDNS (default) or SystemCore team IP. */
13
- platform?: RobotPlatform;
14
- } | {
15
- /** Hostname or IP (e.g. `localhost`, `roborio-973-frc.local`). */
16
- uri: string;
17
- team?: never;
18
- /** NT server port (default `5810`). */
19
- port?: number;
20
- platform?: never;
21
- });
22
- /** @internal */
23
- export declare function toError(value: unknown): Error;
24
- /**
25
- * Provides a NetworkTables instance to the component tree. Must specify either
26
- * `team` (robot team number) or `uri` (e.g. "localhost" or "roborio-973-frc.local").
27
- * Use `useNtcore()` in descendants to access the instance.
28
- * Invalid port (NaN, non-integer, or outside 1–65535) throws so misconfiguration is caught early.
29
- *
30
- * When using `team`, optional `platform` selects RoboRIO mDNS (default) or SystemCore `10.TE.AM.2`.
31
- *
32
- * Changing `team`, `uri`, `port`, or `platform` switches to the corresponding NetworkTables singleton.
33
- * The previous instance is released (closed when no other provider still retains it).
34
- */
35
- export declare function NtcoreProvider({ children, port, ...rest }: NtcoreProviderProps): import("react").JSX.Element;
36
- /**
37
- * Returns the NetworkTables instance from the nearest NtcoreProvider.
38
- * Throws when used outside a provider.
39
- */
40
- export declare function useNtcore(): NetworkTables;
41
- //# sourceMappingURL=context.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/lib/context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,SAAS,EAAkC,MAAM,OAAO,CAAC;AACtF,OAAO,EAAE,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEtE,eAAO,MAAM,aAAa,+CAA4C,CAAC;AAEvE,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,CACA;IACE,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,KAAK,CAAC;IACZ,uCAAuC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oDAAoD;IACpD,QAAQ,CAAC,EAAE,aAAa,CAAC;CAC1B,GACD;IACE,kEAAkE;IAClE,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,uCAAuC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB,CACJ,CAAC;AAaF,gBAAgB;AAChB,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAE7C;AAmBD;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,IAAmB,EAAE,GAAG,IAAI,EAAE,EAAE,mBAAmB,+BAuB7F;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI,aAAa,CAMzC"}
@@ -1,14 +0,0 @@
1
- /** Tracks whether an in-flight `publish()` has settled so unmount can unpublish immediately. */
2
- export type TrackedPublish = {
3
- promise: Promise<unknown>;
4
- settled: boolean;
5
- };
6
- export declare function trackPublish(promise: Promise<unknown>): TrackedPublish;
7
- /** Marks this effect as the current publisher owner of a shared topic. */
8
- export declare function claimPublishOwner(topic: object): number;
9
- /** Unpublish after an in-flight publish settles so unmount cannot leave a ghost publisher. */
10
- export declare function unpublishWhenDone(topic: {
11
- unpublish: () => void;
12
- pubuid?: number | null;
13
- }, tracked: TrackedPublish | undefined, setError: (error: Error) => void, ownerToken: number): void;
14
- //# sourceMappingURL=unpublish-when-done.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"unpublish-when-done.d.ts","sourceRoot":"","sources":["../../src/lib/unpublish-when-done.ts"],"names":[],"mappings":"AAEA,gGAAgG;AAChG,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAIF,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,cAAc,CAMtE;AAED,0EAA0E;AAC1E,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIvD;AAED,8FAA8F;AAC9F,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE;IAAE,SAAS,EAAE,MAAM,IAAI,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EACxD,OAAO,EAAE,cAAc,GAAG,SAAS,EACnC,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,EAChC,UAAU,EAAE,MAAM,GACjB,IAAI,CAeN"}
@@ -1,13 +0,0 @@
1
- /**
2
- * Subscribes to robot connection status and returns the current state. Listener is removed on unmount.
3
- * When connected, RTT (round-trip time in ms) is polled periodically; -1 when not connected or not yet measured.
4
- * When disconnected, `connecting` reflects `NetworkTables.isRobotConnecting()`.
5
- *
6
- * @returns { connected, connecting, rtt }.
7
- */
8
- export declare function useConnectionStatus(): {
9
- connected: boolean;
10
- connecting: boolean;
11
- rtt: number;
12
- };
13
- //# sourceMappingURL=use-connection-status.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-connection-status.d.ts","sourceRoot":"","sources":["../../src/lib/use-connection-status.ts"],"names":[],"mappings":"AAKA;;;;;;GAMG;AACH,wBAAgB,mBAAmB,IAAI;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,UAAU,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAwC9F"}
@@ -1,4 +0,0 @@
1
- import { type RefObject } from 'react';
2
- /** Keeps a ref pointed at the latest value without writing to it during render. */
3
- export declare function useLatestRef<T>(value: T): RefObject<T>;
4
- //# sourceMappingURL=use-latest-ref.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-latest-ref.d.ts","sourceRoot":"","sources":["../../src/lib/use-latest-ref.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE1D,mFAAmF;AACnF,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAMtD"}
@@ -1,41 +0,0 @@
1
- import type { NetworkTablesTypes, SubscribeOptions } from '@ntcore-ts/client';
2
- /**
3
- * Last update from a prefix topic: value, NT type string, and subtopic name.
4
- */
5
- export type PrefixTopicUpdate = {
6
- name: string;
7
- value: NetworkTablesTypes | null;
8
- type: string;
9
- };
10
- /** Entry in the map returned by {@link usePrefixTopicMap}. */
11
- export type PrefixTopicMapEntry = {
12
- value: NetworkTablesTypes | null;
13
- type: string;
14
- };
15
- /**
16
- * Subscribes to all topics under a NetworkTables prefix and returns only the **latest** update.
17
- * Each new update replaces the previous one in state; rapid updates result in only the most
18
- * recent being visible. Use for "react to any change under prefix" or "show last activity."
19
- * For a full map of all topics under a prefix (e.g. to list or iterate), use `usePrefixTopicMap` instead.
20
- *
21
- * Unsubscribes on unmount. Prefix topics are subscribe-only.
22
- *
23
- * @param prefix - Topic prefix (e.g. "/SmartDashboard" or "/" for all).
24
- * @param subscribeOptions - Optional subscribe options (e.g. { periodic: 0.02 }).
25
- * @returns Latest update `{ name, value, type }` or null before first update.
26
- */
27
- export declare function usePrefixTopic(prefix: string, subscribeOptions?: Omit<SubscribeOptions, 'prefix'>): PrefixTopicUpdate | null;
28
- /**
29
- * Subscribes to all topics under a NetworkTables prefix and returns a map of every
30
- * topic name to its latest value and NT type. Updates are batched with requestAnimationFrame so
31
- * rapid announcements all appear. Use when you need to list or iterate over all topics
32
- * (e.g. an "all topics" table). For only the latest single update, use `usePrefixTopic` instead.
33
- *
34
- * Unsubscribes on unmount. Prefix topics are subscribe-only.
35
- *
36
- * @param prefix - Topic prefix (e.g. "/SmartDashboard" or "/" for all).
37
- * @param subscribeOptions - Optional subscribe options (e.g. { periodic: 0.02 }).
38
- * @returns Map of topic name to `{ value, type }`. Empty object after first flush when no topics yet.
39
- */
40
- export declare function usePrefixTopicMap(prefix: string, subscribeOptions?: Omit<SubscribeOptions, 'prefix'>): Record<string, PrefixTopicMapEntry>;
41
- //# sourceMappingURL=use-prefix-topic.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-prefix-topic.d.ts","sourceRoot":"","sources":["../../src/lib/use-prefix-topic.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAI9E;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,8DAA8D;AAC9D,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AA8BF;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,gBAAgB,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAC,GAClD,iBAAiB,GAAG,IAAI,CAa1B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,gBAAgB,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAC,GAClD,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAiDrC"}
@@ -1,51 +0,0 @@
1
- import type { SubscribeOptions, TopicProperties } from '@ntcore-ts/client';
2
- import type { ZodType } from 'zod';
3
- /**
4
- * Options for useProtobufTopic (defaultValue, validator, protoFilePath, protoSource, messageType, subscribeOptions, publish).
5
- * `validator` is a Zod schema for the decoded message type.
6
- */
7
- export type UseProtobufTopicOptions<T extends object> = {
8
- defaultValue?: T;
9
- validator?: ZodType<T>;
10
- protoFilePath?: string;
11
- protoSource?: string;
12
- messageType?: import('protobufjs').Type;
13
- subscribeOptions?: SubscribeOptions;
14
- /**
15
- * Make this client the publisher of the topic so you can write with setValue.
16
- * - `true` → publish with default properties (not retained).
17
- * - `{ retained: true }` (or other TopicProperties) → publish with those properties.
18
- * When provided, only call setValue after isReadyToWrite is true.
19
- */
20
- publish?: true | TopicProperties;
21
- /** When `publish` is set, call `topic.unpublish()` on unmount (default `true`). */
22
- unpublishOnUnmount?: boolean;
23
- };
24
- /**
25
- * Result of useProtobufTopic. When you pass `publish`, setValue is defined and you must
26
- * wait for isReadyToWrite before calling it.
27
- */
28
- export type UseProtobufTopicResult<T extends object> = {
29
- value: T | null;
30
- setValue: ((value: T) => void) | undefined;
31
- /** True once the server has acknowledged our publish request. Only check this when you passed `publish`. */
32
- isReadyToWrite: boolean;
33
- error: Error | null;
34
- };
35
- /**
36
- * Subscribes to a NetworkTables protobuf topic and returns the latest decoded value.
37
- * Unsubscribes on unmount.
38
- *
39
- * **Reading only:** Omit `publish` in options. You get `{ value, setValue: undefined, isReadyToWrite: false }`.
40
- *
41
- * **Reading and writing:** Pass `publish: true` or `publish: { retained: true }` (etc.) in options.
42
- * You get `{ value, setValue, isReadyToWrite }`. Only call setValue when isReadyToWrite is true.
43
- *
44
- * Subscription is re-created only when `nt` or `name` change. Optional options are read at subscribe time.
45
- *
46
- * @param name - Topic name (e.g. "/MyTable/Pose").
47
- * @param options - Optional defaultValue, validator, protoFilePath, protoSource, messageType, subscribeOptions, publish.
48
- * @returns { value, setValue, isReadyToWrite, error }.
49
- */
50
- export declare function useProtobufTopic<T extends object>(name: string, options?: UseProtobufTopicOptions<T>): UseProtobufTopicResult<T>;
51
- //# sourceMappingURL=use-protobuf-topic.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-protobuf-topic.d.ts","sourceRoot":"","sources":["../../src/lib/use-protobuf-topic.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAI3E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAEnC;;;GAGG;AACH,MAAM,MAAM,uBAAuB,CAAC,CAAC,SAAS,MAAM,IAAI;IACtD,YAAY,CAAC,EAAE,CAAC,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,YAAY,EAAE,IAAI,CAAC;IACxC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC;;;;;OAKG;IACH,OAAO,CAAC,EAAE,IAAI,GAAG,eAAe,CAAC;IACjC,mFAAmF;IACnF,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,MAAM,IAAI;IACrD,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IAChB,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAC3C,4GAA4G;IAC5G,cAAc,EAAE,OAAO,CAAC;IACxB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,EAC/C,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,uBAAuB,CAAC,CAAC,CAAC,GACnC,sBAAsB,CAAC,CAAC,CAAC,CAuE3B"}
@@ -1,49 +0,0 @@
1
- import { type StructTypeDescriptor, type SubscribeOptions, type TopicProperties } from '@ntcore-ts/client';
2
- import type { ZodType } from 'zod';
3
- /**
4
- * Options for useStructTopic (defaultValue, validator, typeName, schema, subscribeOptions, publish).
5
- */
6
- export type UseStructTopicOptions<T extends object | object[] = object> = {
7
- defaultValue?: T;
8
- validator?: ZodType<T>;
9
- typeName?: string;
10
- schema?: string;
11
- subscribeOptions?: SubscribeOptions;
12
- /**
13
- * Make this client the publisher of the topic so you can write with setValue.
14
- * When provided, only call setValue after isReadyToWrite is true.
15
- */
16
- publish?: true | TopicProperties;
17
- /** When `publish` is set, call `topic.unpublish()` on unmount (default `true`). */
18
- unpublishOnUnmount?: boolean;
19
- };
20
- export type UseStructTopicTypeOptions<T extends object> = Omit<UseStructTopicOptions<T>, 'typeName' | 'validator'>;
21
- /**
22
- * Result of useStructTopic. When you pass `publish`, setValue is defined and you must
23
- * wait for isReadyToWrite before calling it.
24
- */
25
- export type UseStructTopicResult<T extends object | object[]> = {
26
- value: T | null;
27
- setValue: ((value: T) => void) | undefined;
28
- /** True once the server has acknowledged our publish request. */
29
- isReadyToWrite: boolean;
30
- error: Error | null;
31
- };
32
- /**
33
- * Subscribes to a NetworkTables struct topic using a WPILib-style type descriptor
34
- * (e.g. `useStructTopic('/MyTable/PoseStruct', Pose2d)`).
35
- */
36
- export declare function useStructTopic<T extends object>(name: string, type: StructTypeDescriptor<T>, options?: UseStructTopicTypeOptions<T>): UseStructTopicResult<T>;
37
- /**
38
- * Subscribes to a NetworkTables struct topic and returns the latest decoded value.
39
- * Unsubscribes on unmount.
40
- *
41
- * **Reading only:** Omit `publish` in options.
42
- *
43
- * **Reading and writing:** Pass `publish: true` or `publish: { retained: true }` in options.
44
- * Only call setValue when isReadyToWrite is true.
45
- *
46
- * Subscription is re-created only when `nt` or `name` change. Optional options are read at subscribe time.
47
- */
48
- export declare function useStructTopic<T extends object | object[]>(name: string, options?: UseStructTopicOptions<T>): UseStructTopicResult<T>;
49
- //# sourceMappingURL=use-struct-topic.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-struct-topic.d.ts","sourceRoot":"","sources":["../../src/lib/use-struct-topic.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACrB,MAAM,mBAAmB,CAAC;AAI3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E,EACxD,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,qBAAqB,CAAC,CAAC,CAAC,GACjC,oBAAoB,CAAC,CAAC,CAAC,CAAC"}
@@ -1,55 +0,0 @@
1
- import { NetworkTablesTypeInfos, type NetworkTablesTypeInfo, type NetworkTablesTypes, type SubscribeOptions, type TopicProperties } from '@ntcore-ts/client';
2
- /**
3
- * Options for useTopic. Use `publish: true` to become the publisher with default
4
- * properties (not retained). Use `publish: { retained: true }` (or other TopicProperties)
5
- * to become the publisher with specific properties.
6
- */
7
- export type UseTopicOptions<T = NetworkTablesTypes> = {
8
- /** Shown before the first update. */
9
- defaultValue?: T;
10
- /** Subscribe options (e.g. { periodic: 0.02 }). */
11
- subscribeOptions?: SubscribeOptions;
12
- /**
13
- * Make this client the publisher of the topic so you can write with setValue.
14
- * - `true` → publish with default properties (not retained).
15
- * - `{ retained: true }` (or other TopicProperties) → publish with those properties.
16
- * When provided, only call setValue after isReadyToWrite is true.
17
- */
18
- publish?: true | TopicProperties;
19
- /**
20
- * When `publish` is set, call `topic.unpublish()` on unmount (default `true`).
21
- * Set to `false` to keep publishing after the component unmounts.
22
- */
23
- unpublishOnUnmount?: boolean;
24
- };
25
- /**
26
- * Result of useTopic. When you pass `publish`, setValue is defined and you must
27
- * wait for isReadyToWrite before calling it.
28
- */
29
- export type UseTopicResult<T = NetworkTablesTypes> = {
30
- value: T | null;
31
- setValue: ((value: T) => void) | undefined;
32
- /** True once the server has acknowledged our publish request. Only check this when you passed `publish`. */
33
- isReadyToWrite: boolean;
34
- /** Last publish or setValue error, if any. */
35
- error: Error | null;
36
- };
37
- /**
38
- * Subscribes to a NetworkTables topic and returns the latest value. Unsubscribes on unmount.
39
- *
40
- * **Reading only:** Omit `publish` in options. You get `{ value, setValue: undefined, isReadyToWrite: false }`.
41
- *
42
- * **Reading and writing:** Pass `publish: true` or `publish: { retained: true }` (etc.) in options.
43
- * You get `{ value, setValue, isReadyToWrite }`. Only call setValue when isReadyToWrite is true.
44
- *
45
- * Subscription is re-created only when `nt`, `name`, or `typeInfo` change. Optional
46
- * options are read at subscribe time.
47
- *
48
- * @param name - Topic name (e.g. "/MyTable/Gyro").
49
- * @param typeInfo - Type info from NetworkTablesTypeInfos (e.g. NetworkTablesTypeInfos.kDouble).
50
- * @param options - Optional defaultValue, subscribeOptions, and publish (make me the publisher).
51
- * @returns { value, setValue, isReadyToWrite, error }.
52
- */
53
- export declare function useTopic<T extends object>(name: string, typeInfo: typeof NetworkTablesTypeInfos.kJson, options?: UseTopicOptions<T>): UseTopicResult<T>;
54
- export declare function useTopic<T extends NetworkTablesTypes>(name: string, typeInfo: NetworkTablesTypeInfo, options?: UseTopicOptions<T>): UseTopicResult<T>;
55
- //# sourceMappingURL=use-topic.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-topic.d.ts","sourceRoot":"","sources":["../../src/lib/use-topic.ts"],"names":[],"mappings":"AACA,OAAO,EACL,sBAAsB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACrB,MAAM,mBAAmB,CAAC;AAK3B;;;;GAIG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,GAAG,kBAAkB,IAAI;IACpD,qCAAqC;IACrC,YAAY,CAAC,EAAE,CAAC,CAAC;IACjB,mDAAmD;IACnD,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC;;;;;OAKG;IACH,OAAO,CAAC,EAAE,IAAI,GAAG,eAAe,CAAC;IACjC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,GAAG,kBAAkB,IAAI;IACnD,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IAChB,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAC3C,4GAA4G;IAC5G,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