@memori.ai/memori-react 9.0.0-alpha.22 → 9.0.0-alpha.24

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 (82) hide show
  1. package/CHANGELOG.md +289 -682
  2. package/dist/components/ChatBubble/ChatBubble.js +12 -7
  3. package/dist/components/ChatBubble/ChatBubble.js.map +1 -1
  4. package/dist/components/FeedbackButtons/FeedbackButtons.js +2 -2
  5. package/dist/components/FeedbackButtons/FeedbackButtons.js.map +1 -1
  6. package/dist/components/MemoriWidget/MemoriWidget.d.ts +1 -0
  7. package/dist/components/MemoriWidget/MemoriWidget.js +58 -1
  8. package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
  9. package/dist/components/UploadButton/UploadButton.js +3 -0
  10. package/dist/components/UploadButton/UploadButton.js.map +1 -1
  11. package/dist/components/UploadButton/UploadDocuments/UploadDocuments.js +15 -3
  12. package/dist/components/UploadButton/UploadDocuments/UploadDocuments.js.map +1 -1
  13. package/dist/components/layouts/chat.css +5 -2
  14. package/dist/helpers/constants.d.ts +3 -2
  15. package/dist/helpers/constants.js +19 -20
  16. package/dist/helpers/constants.js.map +1 -1
  17. package/dist/helpers/nats/getNatsConfig.js.map +1 -1
  18. package/dist/helpers/nats/useNats.d.ts +2 -1
  19. package/dist/helpers/nats/useNats.js +87 -20
  20. package/dist/helpers/nats/useNats.js.map +1 -1
  21. package/dist/helpers/nats/useNatsSession.d.ts +6 -1
  22. package/dist/helpers/nats/useNatsSession.js +48 -7
  23. package/dist/helpers/nats/useNatsSession.js.map +1 -1
  24. package/dist/helpers/utils.d.ts +2 -1
  25. package/dist/helpers/utils.js +7 -1
  26. package/dist/helpers/utils.js.map +1 -1
  27. package/dist/styles.css +1 -1
  28. package/dist/version.d.ts +1 -1
  29. package/dist/version.js +1 -1
  30. package/esm/components/ChatBubble/ChatBubble.js +12 -7
  31. package/esm/components/ChatBubble/ChatBubble.js.map +1 -1
  32. package/esm/components/FeedbackButtons/FeedbackButtons.js +2 -2
  33. package/esm/components/FeedbackButtons/FeedbackButtons.js.map +1 -1
  34. package/esm/components/MemoriWidget/MemoriWidget.d.ts +1 -0
  35. package/esm/components/MemoriWidget/MemoriWidget.js +57 -1
  36. package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
  37. package/esm/components/UploadButton/UploadButton.js +4 -1
  38. package/esm/components/UploadButton/UploadButton.js.map +1 -1
  39. package/esm/components/UploadButton/UploadDocuments/UploadDocuments.js +16 -4
  40. package/esm/components/UploadButton/UploadDocuments/UploadDocuments.js.map +1 -1
  41. package/esm/components/layouts/chat.css +5 -2
  42. package/esm/helpers/constants.d.ts +3 -2
  43. package/esm/helpers/constants.js +18 -19
  44. package/esm/helpers/constants.js.map +1 -1
  45. package/esm/helpers/nats/getNatsConfig.js.map +1 -1
  46. package/esm/helpers/nats/useNats.d.ts +2 -1
  47. package/esm/helpers/nats/useNats.js +87 -20
  48. package/esm/helpers/nats/useNats.js.map +1 -1
  49. package/esm/helpers/nats/useNatsSession.d.ts +6 -1
  50. package/esm/helpers/nats/useNatsSession.js +48 -8
  51. package/esm/helpers/nats/useNatsSession.js.map +1 -1
  52. package/esm/helpers/utils.d.ts +2 -1
  53. package/esm/helpers/utils.js +6 -1
  54. package/esm/helpers/utils.js.map +1 -1
  55. package/esm/styles.css +1 -1
  56. package/esm/version.d.ts +1 -1
  57. package/esm/version.js +1 -1
  58. package/package.json +4 -46
  59. package/src/components/Chat/__snapshots__/Chat.test.tsx.snap +71 -71
  60. package/src/components/ChatBubble/ChatBubble.stories.tsx +11 -0
  61. package/src/components/ChatBubble/ChatBubble.test.tsx +16 -0
  62. package/src/components/ChatBubble/ChatBubble.tsx +307 -292
  63. package/src/components/ChatBubble/__snapshots__/ChatBubble.test.tsx.snap +268 -121
  64. package/src/components/FeedbackButtons/FeedbackButtons.tsx +2 -0
  65. package/src/components/FeedbackButtons/__snapshots__/FeedbackButtons.test.tsx.snap +1 -1
  66. package/src/components/KnownFacts/__snapshots__/KnownFacts.test.tsx.snap +6 -2
  67. package/src/components/LoginDrawer/__snapshots__/LoginDrawer.test.tsx.snap +33 -11
  68. package/src/components/MemoriWidget/MemoriWidget.tsx +65 -1
  69. package/src/components/UploadButton/UploadButton.tsx +4 -0
  70. package/src/components/UploadButton/UploadDocuments/UploadDocuments.tsx +21 -5
  71. package/src/components/UploadButton/__snapshots__/UploadButton.test.tsx.snap +2 -2
  72. package/src/components/WhyThisAnswer/__snapshots__/WhyThisAnswer.test.tsx.snap +9 -3
  73. package/src/components/layouts/chat.css +5 -2
  74. package/src/helpers/constants.ts +21 -20
  75. package/src/helpers/nats/getNatsConfig.ts +4 -1
  76. package/src/helpers/nats/useNats.test.tsx +81 -0
  77. package/src/helpers/nats/useNats.ts +109 -29
  78. package/src/helpers/nats/useNatsSession.test.ts +16 -0
  79. package/src/helpers/nats/useNatsSession.ts +79 -13
  80. package/src/helpers/utils.test.ts +14 -4
  81. package/src/helpers/utils.ts +6 -1
  82. package/src/version.ts +1 -1
@@ -24,6 +24,11 @@ export interface UseNatsOptions {
24
24
  onDialogResponse?: (event: NatsDialogResponseEvent) => void;
25
25
  /** `error` events (logging / user notification). */
26
26
  onError?: (event: NatsErrorEvent) => void;
27
+ /**
28
+ * Reconcile a pending turn from the engine after a resumed or reauthenticated
29
+ * subscription is installed.
30
+ */
31
+ onCatchUp?: () => void | Promise<void>;
27
32
  }
28
33
 
29
34
  /**
@@ -38,6 +43,7 @@ export function useNats({
38
43
  onProgress,
39
44
  onDialogResponse,
40
45
  onError,
46
+ onCatchUp,
41
47
  }: UseNatsOptions) {
42
48
  const [config, setConfig] = useState<NatsConfig | null>(null);
43
49
  const [configError, setConfigError] = useState<Error | null>(null);
@@ -46,33 +52,42 @@ export function useNats({
46
52
  const onProgressRef = useRef(onProgress);
47
53
  const onDialogResponseRef = useRef(onDialogResponse);
48
54
  const onErrorRef = useRef(onError);
55
+ const onCatchUpRef = useRef(onCatchUp);
56
+ const abortRef = useRef<AbortController | null>(null);
57
+ const catchUpAfterConnectRef = useRef(false);
58
+ const refreshInFlightRef = useRef(false);
59
+ const lastAuthRefreshRef = useRef(0);
49
60
  useEffect(() => {
50
61
  onProgressRef.current = onProgress;
51
62
  onDialogResponseRef.current = onDialogResponse;
52
63
  onErrorRef.current = onError;
53
- }, [onProgress, onDialogResponse, onError]);
64
+ onCatchUpRef.current = onCatchUp;
65
+ }, [onProgress, onDialogResponse, onError, onCatchUp]);
54
66
 
55
- // Fetch connection config whenever the active session changes.
56
- useEffect(() => {
57
- if (!sessionId) {
58
- console.debug('[NATS] no sessionId, skipping config fetch');
59
- setConfig(null);
60
- setConfigError(null);
61
- return;
62
- }
67
+ const refreshConfig = useCallback(
68
+ async (reason: 'initial' | 'resume' | 'auth') => {
69
+ if (!sessionId || refreshInFlightRef.current) return;
70
+ if (reason === 'auth' && Date.now() - lastAuthRefreshRef.current < 5000) {
71
+ return;
72
+ }
63
73
 
64
- const controller = new AbortController();
65
- let cancelled = false;
66
-
67
- console.info(
68
- '[NATS] fetching config from',
69
- `${baseUrl}/api/nats`,
70
- 'for session',
71
- sessionId
72
- );
73
- getNatsConfig(baseUrl, sessionId, controller.signal)
74
- .then(cfg => {
75
- if (!cancelled) {
74
+ refreshInFlightRef.current = true;
75
+ if (reason === 'auth') lastAuthRefreshRef.current = Date.now();
76
+ abortRef.current?.abort();
77
+ const controller = new AbortController();
78
+ abortRef.current = controller;
79
+
80
+ console.info(
81
+ '[NATS] fetching config from',
82
+ `${baseUrl}/api/nats`,
83
+ 'for session',
84
+ sessionId,
85
+ `(${reason})`
86
+ );
87
+ try {
88
+ const cfg = await getNatsConfig(baseUrl, sessionId, controller.signal);
89
+ if (!controller.signal.aborted) {
90
+ catchUpAfterConnectRef.current = reason !== 'initial';
76
91
  console.info('[NATS] config received', {
77
92
  url: cfg.url,
78
93
  jetStream: !!cfg.stream,
@@ -81,20 +96,65 @@ export function useNats({
81
96
  setConfig(cfg);
82
97
  setConfigError(null);
83
98
  }
84
- })
85
- .catch(err => {
86
- if (!cancelled && err?.name !== 'AbortError') {
99
+ } catch (err: any) {
100
+ if (!controller.signal.aborted && err?.name !== 'AbortError') {
87
101
  console.error('[NATS] config error', err);
88
102
  setConfig(null);
89
103
  setConfigError(err instanceof Error ? err : new Error(String(err)));
90
104
  }
91
- });
105
+ } finally {
106
+ if (abortRef.current === controller) {
107
+ abortRef.current = null;
108
+ refreshInFlightRef.current = false;
109
+ }
110
+ }
111
+ },
112
+ [baseUrl, sessionId]
113
+ );
92
114
 
115
+ // Fetch connection config whenever the active session changes.
116
+ useEffect(() => {
117
+ if (!sessionId) {
118
+ console.debug('[NATS] no sessionId, skipping config fetch');
119
+ setConfig(null);
120
+ setConfigError(null);
121
+ return;
122
+ }
123
+
124
+ void refreshConfig('initial');
93
125
  return () => {
94
- cancelled = true;
95
- controller.abort();
126
+ abortRef.current?.abort();
127
+ abortRef.current = null;
128
+ refreshInFlightRef.current = false;
96
129
  };
97
- }, [baseUrl, sessionId]);
130
+ }, [sessionId, refreshConfig]);
131
+
132
+ // A suspended browser may lose core NATS messages. Refresh the short-lived
133
+ // JWT, reconnect, then reconcile the pending turn from the engine.
134
+ useEffect(() => {
135
+ if (!sessionId) return;
136
+
137
+ const requestResume = () => {
138
+ if (document.visibilityState === 'visible') {
139
+ void refreshConfig('resume');
140
+ }
141
+ };
142
+ const onVisibilityChange = () => {
143
+ if (document.visibilityState === 'visible') requestResume();
144
+ };
145
+ const onPageShow = (event: PageTransitionEvent) => {
146
+ if (event.persisted) requestResume();
147
+ };
148
+
149
+ document.addEventListener('visibilitychange', onVisibilityChange);
150
+ window.addEventListener('online', requestResume);
151
+ window.addEventListener('pageshow', onPageShow);
152
+ return () => {
153
+ document.removeEventListener('visibilitychange', onVisibilityChange);
154
+ window.removeEventListener('online', requestResume);
155
+ window.removeEventListener('pageshow', onPageShow);
156
+ };
157
+ }, [sessionId, refreshConfig]);
98
158
 
99
159
  const handleMessage = useCallback((event: NatsSessionEvent) => {
100
160
  console.debug('[NATS] dispatching event', { eventType: event.eventType });
@@ -113,7 +173,27 @@ export function useNats({
113
173
  }
114
174
  }, []);
115
175
 
116
- useNatsSession(sessionId, config ?? undefined, handleMessage);
176
+ const handleConnected = useCallback(() => {
177
+ if (!catchUpAfterConnectRef.current) return;
178
+ catchUpAfterConnectRef.current = false;
179
+ void onCatchUpRef.current?.();
180
+ }, []);
181
+
182
+ const handleAuthError = useCallback(
183
+ (error: Error) => {
184
+ console.warn(
185
+ '[NATS] JWT rejected or expired; refreshing credentials',
186
+ error
187
+ );
188
+ void refreshConfig('auth');
189
+ },
190
+ [refreshConfig]
191
+ );
192
+
193
+ useNatsSession(sessionId, config ?? undefined, handleMessage, {
194
+ onConnected: handleConnected,
195
+ onAuthError: handleAuthError,
196
+ });
117
197
 
118
198
  return {
119
199
  /** True once connection config has been retrieved. */
@@ -0,0 +1,16 @@
1
+ import { AuthorizationError } from '@nats-io/nats-core';
2
+ import { isNatsAuthError } from './useNatsSession';
3
+
4
+ describe('isNatsAuthError', () => {
5
+ it('recognizes typed NATS authorization failures', () => {
6
+ expect(isNatsAuthError(new AuthorizationError('test'))).toBe(true);
7
+ });
8
+
9
+ it('recognizes the server authorization violation message', () => {
10
+ expect(isNatsAuthError(new Error('Authorization Violation'))).toBe(true);
11
+ });
12
+
13
+ it('does not classify unrelated connection failures as auth failures', () => {
14
+ expect(isNatsAuthError(new Error('connection refused'))).toBe(false);
15
+ });
16
+ });
@@ -11,7 +11,13 @@
11
11
  // The cleanup (`consumerMessages.stop()` + `nc.close()`) is essential: without
12
12
  // it, every `sessionId` change would leave orphan connections / iterators.
13
13
  import { useEffect, useRef, useState, type MutableRefObject } from 'react';
14
- import { wsconnect, NatsConnection } from '@nats-io/nats-core';
14
+ import {
15
+ wsconnect,
16
+ jwtAuthenticator,
17
+ AuthorizationError,
18
+ NatsConnection,
19
+ UserAuthenticationExpiredError,
20
+ } from '@nats-io/nats-core';
15
21
  import {
16
22
  jetstream,
17
23
  DeliverPolicy,
@@ -66,6 +72,24 @@ export type NatsSessionEvent =
66
72
 
67
73
  type JetStreamConsumeMode = 'live' | 'catch-up';
68
74
 
75
+ export interface NatsSessionLifecycle {
76
+ /** Called after the live subscription is installed. */
77
+ onConnected?: () => void;
78
+ /** Called once when this connection is rejected because its JWT expired. */
79
+ onAuthError?: (error: Error) => void;
80
+ }
81
+
82
+ export function isNatsAuthError(error: unknown): error is Error {
83
+ return (
84
+ error instanceof AuthorizationError ||
85
+ error instanceof UserAuthenticationExpiredError ||
86
+ (error instanceof Error &&
87
+ /authorization violation|authentication expired|user authentication expired/i.test(
88
+ error.message
89
+ ))
90
+ );
91
+ }
92
+
69
93
  function readString(
70
94
  raw: Record<string, unknown>,
71
95
  camelKey: string,
@@ -107,7 +131,9 @@ function unwrapDialogState(value: unknown): unknown {
107
131
  /**
108
132
  * Normalizes raw NATS payloads (snake_case or camelCase) into typed events.
109
133
  */
110
- export function normalizeNatsEvent(raw: Record<string, unknown>): NatsSessionEvent {
134
+ export function normalizeNatsEvent(
135
+ raw: Record<string, unknown>
136
+ ): NatsSessionEvent {
111
137
  const eventType = (readString(raw, 'eventType', 'event_type') ??
112
138
  'unknown') as NatsSessionEvent['eventType'];
113
139
 
@@ -130,8 +156,7 @@ export function normalizeNatsEvent(raw: Record<string, unknown>): NatsSessionEve
130
156
  if (eventType === 'dialog_text_entered_response') {
131
157
  return {
132
158
  eventType: 'dialog_text_entered_response',
133
- requestID:
134
- typeof raw.requestID === 'string' ? raw.requestID : undefined,
159
+ requestID: typeof raw.requestID === 'string' ? raw.requestID : undefined,
135
160
  resultCode:
136
161
  typeof raw.resultCode === 'number' ? raw.resultCode : undefined,
137
162
  resultMessage:
@@ -144,7 +169,10 @@ export function normalizeNatsEvent(raw: Record<string, unknown>): NatsSessionEve
144
169
  if (eventType === 'error') {
145
170
  return {
146
171
  eventType: 'error',
147
- errorCode: (raw.errorCode ?? raw.error_code) as string | number | undefined,
172
+ errorCode: (raw.errorCode ?? raw.error_code) as
173
+ | string
174
+ | number
175
+ | undefined,
148
176
  errorMessage: readString(raw, 'errorMessage', 'error_message'),
149
177
  backtrace: typeof raw.backtrace === 'string' ? raw.backtrace : undefined,
150
178
  correlationID,
@@ -174,10 +202,12 @@ function decodeMessage(
174
202
  async function consumeCoreSubscription(
175
203
  nc: NatsConnection,
176
204
  subject: string,
177
- onMessage: (event: NatsSessionEvent) => void
205
+ onMessage: (event: NatsSessionEvent) => void,
206
+ onReady: () => void
178
207
  ) {
179
208
  const sub = nc.subscribe(subject);
180
209
  console.info('[NATS] subscribed to subject', subject);
210
+ onReady();
181
211
  let received = 0;
182
212
  for await (const msg of sub) {
183
213
  received += 1;
@@ -203,7 +233,8 @@ async function consumeJetStream(
203
233
  subject: string,
204
234
  mode: JetStreamConsumeMode,
205
235
  onMessage: (event: NatsSessionEvent) => void,
206
- setConsumerMessages: (messages: ConsumerMessages) => void
236
+ setConsumerMessages: (messages: ConsumerMessages) => void,
237
+ onReady: () => void
207
238
  ) {
208
239
  const js = jetstream(nc);
209
240
  const consumer = config.consumer
@@ -225,6 +256,7 @@ async function consumeJetStream(
225
256
 
226
257
  const messages = await consumer.consume();
227
258
  setConsumerMessages(messages);
259
+ onReady();
228
260
  let received = 0;
229
261
  for await (const msg of messages) {
230
262
  received += 1;
@@ -258,17 +290,19 @@ function closeNatsSession(
258
290
  * change.
259
291
  *
260
292
  * @param sessionId Current session UUID (subscription is skipped when falsy).
261
- * @param config Connection config from `/api/nats` (url + token required).
293
+ * @param config Connection config from `/api/nats` (url + per-session JWT).
262
294
  * @param onMessage Callback invoked for each decoded event.
263
295
  */
264
296
  export function useNatsSession(
265
297
  sessionId: string | undefined,
266
298
  config: NatsConfig | undefined,
267
- onMessage: (event: NatsSessionEvent) => void
299
+ onMessage: (event: NatsSessionEvent) => void,
300
+ lifecycle: NatsSessionLifecycle = {}
268
301
  ) {
269
302
  const connRef = useRef<NatsConnection | null>(null);
270
303
  const consumerMessagesRef = useRef<ConsumerMessages | null>(null);
271
304
  const onMessageRef = useRef(onMessage);
305
+ const lifecycleRef = useRef(lifecycle);
272
306
  const wasHiddenRef = useRef(false);
273
307
  const [resumeGeneration, setResumeGeneration] = useState(0);
274
308
 
@@ -277,6 +311,10 @@ export function useNatsSession(
277
311
  onMessageRef.current = onMessage;
278
312
  }, [onMessage]);
279
313
 
314
+ useEffect(() => {
315
+ lifecycleRef.current = lifecycle;
316
+ }, [lifecycle]);
317
+
280
318
  // Reconnect when the tab returns from background or the network comes back.
281
319
  useEffect(() => {
282
320
  if (!sessionId || !config?.stream) {
@@ -348,7 +386,7 @@ export function useNatsSession(
348
386
  );
349
387
  const nc = await wsconnect({
350
388
  servers: [config.url],
351
- token: config.token,
389
+ authenticator: jwtAuthenticator(config.token),
352
390
  });
353
391
  if (closed) {
354
392
  console.debug(
@@ -363,6 +401,28 @@ export function useNatsSession(
363
401
  const dispatch = (event: NatsSessionEvent) => {
364
402
  onMessageRef.current(event);
365
403
  };
404
+ const ready = () => lifecycleRef.current.onConnected?.();
405
+ let authRefreshRequested = false;
406
+ const requestAuthRefresh = (error: Error) => {
407
+ if (closed || authRefreshRequested) return;
408
+ authRefreshRequested = true;
409
+ lifecycleRef.current.onAuthError?.(error);
410
+ };
411
+
412
+ void (async () => {
413
+ for await (const status of nc.status()) {
414
+ if (status.type === 'error' && isNatsAuthError(status.error)) {
415
+ requestAuthRefresh(status.error);
416
+ return;
417
+ }
418
+ }
419
+ })();
420
+
421
+ void nc.closed().then(error => {
422
+ if (error && isNatsAuthError(error)) {
423
+ requestAuthRefresh(error);
424
+ }
425
+ });
366
426
 
367
427
  if (useJetStream) {
368
428
  await consumeJetStream(
@@ -373,12 +433,18 @@ export function useNatsSession(
373
433
  dispatch,
374
434
  messages => {
375
435
  consumerMessagesRef.current = messages;
376
- }
436
+ },
437
+ ready
377
438
  );
378
439
  } else {
379
- await consumeCoreSubscription(nc, subject, dispatch);
440
+ await consumeCoreSubscription(nc, subject, dispatch, ready);
441
+ }
442
+ })().catch(err => {
443
+ console.error('[NATS] connection error', err);
444
+ if (!closed && isNatsAuthError(err)) {
445
+ lifecycleRef.current.onAuthError?.(err);
380
446
  }
381
- })().catch(err => console.error('[NATS] connection error', err));
447
+ });
382
448
 
383
449
  return () => {
384
450
  console.info('[NATS] cleanup: closing connection for subject', subject);
@@ -8,6 +8,7 @@ import {
8
8
  extractAttachmentLinks,
9
9
  extractAttachmentLink,
10
10
  isAssetOnlyDocumentAttachment,
11
+ isLocalTextFilename,
11
12
  isOfficeNativeFilename,
12
13
  parseDocumentAttachmentsFromMessage,
13
14
  } from './utils';
@@ -176,15 +177,24 @@ describe('utils/attachment helpers', () => {
176
177
  });
177
178
 
178
179
  it('detects office native filenames', () => {
179
- expect(isOfficeNativeFilename('report.doc')).toBe(true);
180
- expect(isOfficeNativeFilename('report.docx')).toBe(true);
180
+ expect(isOfficeNativeFilename('report.doc')).toBe(false);
181
+ expect(isOfficeNativeFilename('report.docx')).toBe(false);
181
182
  expect(isOfficeNativeFilename('budget.xls')).toBe(false);
182
- expect(isOfficeNativeFilename('template.XLTX')).toBe(true);
183
- expect(isOfficeNativeFilename('slides.potx')).toBe(true);
183
+ expect(isOfficeNativeFilename('template.XLTX')).toBe(false);
184
+ expect(isOfficeNativeFilename('slides.potx')).toBe(false);
184
185
  expect(isOfficeNativeFilename('notes.pdf')).toBe(false);
185
186
  expect(isOfficeNativeFilename('data.xlsx')).toBe(false);
186
187
  });
187
188
 
189
+ it('detects filenames read locally instead of converted', () => {
190
+ expect(isLocalTextFilename('notes.txt')).toBe(true);
191
+ expect(isLocalTextFilename('export.CSV')).toBe(true);
192
+ expect(isLocalTextFilename('readme.md')).toBe(true);
193
+ expect(isLocalTextFilename('readme.markdown')).toBe(false);
194
+ expect(isLocalTextFilename('report.docx')).toBe(false);
195
+ expect(isLocalTextFilename('notes.pdf')).toBe(false);
196
+ });
197
+
188
198
  it('detects asset-only document attachments', () => {
189
199
  expect(
190
200
  isAssetOnlyDocumentAttachment({
@@ -1,7 +1,7 @@
1
1
  import { useState, useEffect, useRef, useMemo } from 'react';
2
2
  import { Material, MeshStandardMaterial, SkinnedMesh } from 'three';
3
3
  import * as THREE from 'three';
4
- import { officeNativeExtensions } from './constants';
4
+ import { localTextExtensions, officeNativeExtensions } from './constants';
5
5
 
6
6
  export const hasTouchscreen = (): boolean => {
7
7
  let hasTouchScreen = false;
@@ -245,6 +245,11 @@ export const isOfficeNativeFilename = (filename: string): boolean => {
245
245
  return (officeNativeExtensions as readonly string[]).includes(ext);
246
246
  };
247
247
 
248
+ export const isLocalTextFilename = (filename: string): boolean => {
249
+ const ext = `.${filename.split('.').pop()?.toLowerCase() || ''}`;
250
+ return (localTextExtensions as readonly string[]).includes(ext);
251
+ };
252
+
248
253
  export type ParsedDocumentAttachment = {
249
254
  filename: string;
250
255
  type: string;
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // This file is auto-generated. Do not edit manually.
2
- export const version = '9.0.0-alpha.22';
2
+ export const version = '9.0.0-alpha.24';