@tanstack/ai-remix 1.0.0 → 1.1.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 +8 -8
- package/src/create-generate-3d-model.ts +97 -0
- package/src/index.ts +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/ai-remix",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Remix 3 bindings for TanStack AI streaming chat, structured outputs, and media generation.",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -47,20 +47,20 @@
|
|
|
47
47
|
"README.md"
|
|
48
48
|
],
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@tanstack/ai-client": "^1.
|
|
50
|
+
"@tanstack/ai-client": "^1.2.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"remix": "^3.0.0-rc.1",
|
|
54
|
-
"@tanstack/ai": "^1.
|
|
54
|
+
"@tanstack/ai": "^1.7.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/node": "^24.10.1",
|
|
58
|
-
"@vitest/coverage-v8": "4.1.
|
|
59
|
-
"happy-dom": "^20.
|
|
58
|
+
"@vitest/coverage-v8": "4.1.12",
|
|
59
|
+
"happy-dom": "^20.14.6",
|
|
60
60
|
"remix": "^3.0.0-rc.1",
|
|
61
|
-
"vite": "^8.
|
|
62
|
-
"vitest": "^4.1.
|
|
63
|
-
"@tanstack/ai": "1.
|
|
61
|
+
"vite": "^8.3.8",
|
|
62
|
+
"vitest": "^4.1.12",
|
|
63
|
+
"@tanstack/ai": "1.7.0"
|
|
64
64
|
},
|
|
65
65
|
"scripts": {
|
|
66
66
|
"lint:fix": "oxlint src --type-aware --fix",
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { createGeneration } from './create-generation.ts'
|
|
2
|
+
import type { Handle } from 'remix/ui'
|
|
3
|
+
import type { Model3DResult } from '@tanstack/ai'
|
|
4
|
+
import type { Model3DGenerateInput } from '@tanstack/ai-client'
|
|
5
|
+
import type {
|
|
6
|
+
CreateGenerationOptions,
|
|
7
|
+
CreateGenerationReturn,
|
|
8
|
+
} from './create-generation.ts'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Options for the createGenerate3DModel helper.
|
|
12
|
+
*
|
|
13
|
+
* Handle is the first argument of the helper. It is not part of this type.
|
|
14
|
+
*
|
|
15
|
+
* @experimental 3D model generation is experimental. The shape can change in
|
|
16
|
+
* a minor release.
|
|
17
|
+
*
|
|
18
|
+
* @template TOutput - The output type after optional transform (defaults to Model3DResult)
|
|
19
|
+
*/
|
|
20
|
+
export type CreateGenerate3DModelOptions<TOutput = Model3DResult> = Omit<
|
|
21
|
+
CreateGenerationOptions<Model3DGenerateInput, Model3DResult, TOutput>,
|
|
22
|
+
| 'onResult'
|
|
23
|
+
| 'reconstructResult'
|
|
24
|
+
| 'persistence'
|
|
25
|
+
| 'hydrateGeneration'
|
|
26
|
+
| 'joinRun'
|
|
27
|
+
> & {
|
|
28
|
+
onResult?: (result: Model3DResult) => TOutput | null | void
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Return type for the createGenerate3DModel helper.
|
|
33
|
+
*
|
|
34
|
+
* @experimental 3D model generation is experimental. The shape can change in
|
|
35
|
+
* a minor release.
|
|
36
|
+
*
|
|
37
|
+
* @template TOutput - The output type (after optional transform)
|
|
38
|
+
*/
|
|
39
|
+
export type CreateGenerate3DModelReturn<TOutput = Model3DResult> =
|
|
40
|
+
CreateGenerationReturn<TOutput, Model3DGenerateInput>
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Creates a 3D model generation helper for Remix setup (text-to-3D,
|
|
44
|
+
* image-to-3D, 3D-to-3D).
|
|
45
|
+
*
|
|
46
|
+
* Supports two transport modes:
|
|
47
|
+
* - **ConnectConnectionAdapter**: streaming transport (SSE, HTTP stream, custom)
|
|
48
|
+
* - **Fetcher**: direct async function call
|
|
49
|
+
*
|
|
50
|
+
* The server streams a `generation:progress` event for each provider poll and
|
|
51
|
+
* one `generation:result` event with the finished model.
|
|
52
|
+
*
|
|
53
|
+
* Call this in a Remix component setup function. Pass the component Handle as
|
|
54
|
+
* the first argument.
|
|
55
|
+
*
|
|
56
|
+
* @experimental 3D model generation is experimental. The shape can change in
|
|
57
|
+
* a minor release.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```tsx
|
|
61
|
+
* import { createGenerate3DModel } from '@tanstack/ai-remix'
|
|
62
|
+
* import { fetchServerSentEvents } from '@tanstack/ai-client'
|
|
63
|
+
* import type { Handle } from 'remix/ui'
|
|
64
|
+
*
|
|
65
|
+
* function ModelGenerator(handle: Handle) {
|
|
66
|
+
* const model = createGenerate3DModel(handle, {
|
|
67
|
+
* threadId: 'hero-model',
|
|
68
|
+
* connection: fetchServerSentEvents('/api/3d-model'),
|
|
69
|
+
* })
|
|
70
|
+
*
|
|
71
|
+
* return () => (
|
|
72
|
+
* <div>
|
|
73
|
+
* <button onClick={() => model.generate({ prompt: 'A low-poly fox' })}>
|
|
74
|
+
* Generate
|
|
75
|
+
* </button>
|
|
76
|
+
* {model.isLoading ? <p>Generating...</p> : null}
|
|
77
|
+
* {model.result ? (
|
|
78
|
+
* <a href={model.result.url}>Download .{model.result.format}</a>
|
|
79
|
+
* ) : null}
|
|
80
|
+
* </div>
|
|
81
|
+
* )
|
|
82
|
+
* }
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export function createGenerate3DModel<TTransformed = void>(
|
|
86
|
+
handle: Pick<Handle, 'update' | 'signal'>,
|
|
87
|
+
options: Omit<CreateGenerate3DModelOptions, 'onResult'> & {
|
|
88
|
+
onResult?: (result: Model3DResult) => TTransformed
|
|
89
|
+
},
|
|
90
|
+
) {
|
|
91
|
+
const devtools = { ...options.devtools, hookName: 'createGenerate3DModel' }
|
|
92
|
+
return createGeneration<Model3DGenerateInput, Model3DResult, TTransformed>(
|
|
93
|
+
handle,
|
|
94
|
+
// 3D results are never persisted, even if an untyped caller sets it.
|
|
95
|
+
{ ...options, devtools, persistence: false },
|
|
96
|
+
)
|
|
97
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -64,6 +64,11 @@ export type {
|
|
|
64
64
|
CreateGenerateVideoOptions,
|
|
65
65
|
CreateGenerateVideoReturn,
|
|
66
66
|
} from './create-generate-video.ts'
|
|
67
|
+
export { createGenerate3DModel } from './create-generate-3d-model.ts'
|
|
68
|
+
export type {
|
|
69
|
+
CreateGenerate3DModelOptions,
|
|
70
|
+
CreateGenerate3DModelReturn,
|
|
71
|
+
} from './create-generate-3d-model.ts'
|
|
67
72
|
export { createAudioRecorder } from './create-audio-recorder.ts'
|
|
68
73
|
export type { CreateAudioRecorderOptions } from './create-audio-recorder.ts'
|
|
69
74
|
|
|
@@ -137,6 +142,7 @@ export {
|
|
|
137
142
|
type TranscriptionGenerateInput,
|
|
138
143
|
type SummarizeGenerateInput,
|
|
139
144
|
type VideoGenerateInput,
|
|
145
|
+
type Model3DGenerateInput,
|
|
140
146
|
type VideoGenerateResult,
|
|
141
147
|
type VideoStatusInfo,
|
|
142
148
|
} from '@tanstack/ai-client'
|