@dxos/plugin-transformer 0.8.4-main.f9ba587 → 0.8.4-main.fcc0d83b33

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 (52) hide show
  1. package/dist/lib/browser/index.mjs +23 -34
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/browser/translations.mjs +15 -0
  5. package/dist/lib/browser/translations.mjs.map +7 -0
  6. package/dist/lib/node-esm/index.mjs +23 -34
  7. package/dist/lib/node-esm/index.mjs.map +4 -4
  8. package/dist/lib/node-esm/meta.json +1 -1
  9. package/dist/lib/node-esm/translations.mjs +17 -0
  10. package/dist/lib/node-esm/translations.mjs.map +7 -0
  11. package/dist/types/src/TransformerPlugin.d.ts +2 -1
  12. package/dist/types/src/TransformerPlugin.d.ts.map +1 -1
  13. package/dist/types/src/components/Voice/DebugInfo.d.ts.map +1 -0
  14. package/dist/types/src/components/Voice/Voice.d.ts.map +1 -0
  15. package/dist/types/src/components/Voice/Voice.stories.d.ts +14 -0
  16. package/dist/types/src/components/Voice/Voice.stories.d.ts.map +1 -0
  17. package/dist/types/src/components/Voice/index.d.ts +3 -0
  18. package/dist/types/src/components/Voice/index.d.ts.map +1 -0
  19. package/dist/types/src/components/index.d.ts +2 -0
  20. package/dist/types/src/components/index.d.ts.map +1 -0
  21. package/dist/types/src/hooks/useAudioStream.d.ts.map +1 -1
  22. package/dist/types/src/hooks/usePipeline.d.ts +1 -16
  23. package/dist/types/src/hooks/usePipeline.d.ts.map +1 -1
  24. package/dist/types/src/meta.d.ts +2 -3
  25. package/dist/types/src/meta.d.ts.map +1 -1
  26. package/dist/types/src/testing/node-pipeline.d.ts +1 -1
  27. package/dist/types/src/testing/node-pipeline.d.ts.map +1 -1
  28. package/dist/types/src/testing/pipeline.d.ts.map +1 -1
  29. package/dist/types/src/testing/web-pipeline.d.ts +1 -1
  30. package/dist/types/src/testing/web-pipeline.d.ts.map +1 -1
  31. package/dist/types/src/translations.d.ts +2 -3
  32. package/dist/types/src/translations.d.ts.map +1 -1
  33. package/dist/types/tsconfig.tsbuildinfo +1 -1
  34. package/package.json +52 -42
  35. package/src/TransformerPlugin.tsx +14 -27
  36. package/src/components/{DebugInfo.tsx → Voice/DebugInfo.tsx} +3 -3
  37. package/src/components/{Voice.stories.tsx → Voice/Voice.stories.tsx} +6 -8
  38. package/src/components/{Voice.tsx → Voice/Voice.tsx} +3 -2
  39. package/src/components/Voice/index.ts +6 -0
  40. package/src/{capabilities → components}/index.ts +2 -0
  41. package/src/hooks/useAudioStream.ts +2 -2
  42. package/src/hooks/usePipeline.ts +11 -35
  43. package/src/meta.ts +8 -6
  44. package/src/translations.ts +2 -2
  45. package/dist/types/src/capabilities/index.d.ts +0 -1
  46. package/dist/types/src/capabilities/index.d.ts.map +0 -1
  47. package/dist/types/src/components/DebugInfo.d.ts.map +0 -1
  48. package/dist/types/src/components/Voice.d.ts.map +0 -1
  49. package/dist/types/src/components/Voice.stories.d.ts +0 -8
  50. package/dist/types/src/components/Voice.stories.d.ts.map +0 -1
  51. /package/dist/types/src/components/{DebugInfo.d.ts → Voice/DebugInfo.d.ts} +0 -0
  52. /package/dist/types/src/components/{Voice.d.ts → Voice/Voice.d.ts} +0 -0
package/package.json CHANGED
@@ -1,77 +1,87 @@
1
1
  {
2
2
  "name": "@dxos/plugin-transformer",
3
- "version": "0.8.4-main.f9ba587",
3
+ "version": "0.8.4-main.fcc0d83b33",
4
4
  "description": "Client transformer",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/dxos/dxos"
10
+ },
7
11
  "license": "MIT",
8
12
  "author": "DXOS.org",
9
13
  "sideEffects": true,
10
14
  "type": "module",
15
+ "imports": {
16
+ "#components": "./src/components/index.ts",
17
+ "#hooks": "./src/hooks/index.ts",
18
+ "#meta": "./src/meta.ts",
19
+ "#translations": "./src/translations.ts",
20
+ "#types": "./src/types/index.ts"
21
+ },
11
22
  "exports": {
12
23
  ".": {
24
+ "source": "./src/index.ts",
13
25
  "types": "./dist/types/src/index.d.ts",
14
26
  "browser": "./dist/lib/browser/index.mjs",
15
27
  "node": "./dist/lib/node-esm/index.mjs"
16
28
  },
29
+ "./translations": {
30
+ "source": "./src/translations.ts",
31
+ "types": "./dist/types/src/translations.d.ts",
32
+ "browser": "./dist/lib/browser/translations.mjs",
33
+ "node": "./dist/lib/node-esm/translations.mjs"
34
+ },
17
35
  "./types": {
36
+ "source": "./src/types/index.ts",
18
37
  "types": "./dist/types/src/types/index.d.ts",
19
38
  "browser": "./dist/lib/browser/types/index.mjs",
20
39
  "node": "./dist/lib/node-esm/types/index.mjs"
21
40
  }
22
41
  },
23
42
  "types": "dist/types/src/index.d.ts",
24
- "typesVersions": {
25
- "*": {
26
- "types": [
27
- "dist/types/src/types/index.d.ts"
28
- ]
29
- }
30
- },
31
43
  "files": [
32
44
  "dist",
33
45
  "src"
34
46
  ],
35
47
  "dependencies": {
36
- "@huggingface/transformers": "^3.3.3",
37
- "@preact-signals/safe-react": "^0.9.0",
38
- "@preact/signals-core": "^1.9.0",
39
- "date-fns": "^3.3.1",
40
- "effect": "3.16.13",
41
- "@dxos/app-framework": "0.8.4-main.f9ba587",
42
- "@dxos/async": "0.8.4-main.f9ba587",
43
- "@dxos/echo": "0.8.4-main.f9ba587",
44
- "@dxos/display-name": "0.8.4-main.f9ba587",
45
- "@dxos/echo-schema": "0.8.4-main.f9ba587",
46
- "@dxos/invariant": "0.8.4-main.f9ba587",
47
- "@dxos/live-object": "0.8.4-main.f9ba587",
48
- "@dxos/log": "0.8.4-main.f9ba587",
49
- "@dxos/plugin-client": "0.8.4-main.f9ba587",
50
- "@dxos/plugin-graph": "0.8.4-main.f9ba587",
51
- "@dxos/plugin-space": "0.8.4-main.f9ba587",
52
- "@dxos/react-client": "0.8.4-main.f9ba587",
53
- "@dxos/react-ui-attention": "0.8.4-main.f9ba587",
54
- "@dxos/react-ui-stack": "0.8.4-main.f9ba587",
55
- "@dxos/util": "0.8.4-main.f9ba587"
48
+ "@huggingface/transformers": "^3.8.1",
49
+ "date-fns": "^3.6.0",
50
+ "effect": "3.20.0",
51
+ "@dxos/app-framework": "0.8.4-main.fcc0d83b33",
52
+ "@dxos/app-toolkit": "0.8.4-main.fcc0d83b33",
53
+ "@dxos/async": "0.8.4-main.fcc0d83b33",
54
+ "@dxos/display-name": "0.8.4-main.fcc0d83b33",
55
+ "@dxos/log": "0.8.4-main.fcc0d83b33",
56
+ "@dxos/invariant": "0.8.4-main.fcc0d83b33",
57
+ "@dxos/echo": "0.8.4-main.fcc0d83b33",
58
+ "@dxos/operation": "0.8.4-main.fcc0d83b33",
59
+ "@dxos/plugin-graph": "0.8.4-main.fcc0d83b33",
60
+ "@dxos/plugin-space": "0.8.4-main.fcc0d83b33",
61
+ "@dxos/plugin-client": "0.8.4-main.fcc0d83b33",
62
+ "@dxos/react-client": "0.8.4-main.fcc0d83b33",
63
+ "@dxos/react-ui-attention": "0.8.4-main.fcc0d83b33",
64
+ "@dxos/react-ui-stack": "0.8.4-main.fcc0d83b33",
65
+ "@dxos/util": "0.8.4-main.fcc0d83b33"
56
66
  },
57
67
  "devDependencies": {
58
- "@types/react": "~18.2.0",
59
- "@types/react-dom": "~18.2.0",
68
+ "@types/react": "~19.2.7",
69
+ "@types/react-dom": "~19.2.3",
60
70
  "@xenova/transformers": "^2.17.2",
61
- "react": "~18.2.0",
62
- "react-dom": "~18.2.0",
63
- "vite": "5.4.7",
64
- "@dxos/random": "0.8.4-main.f9ba587",
65
- "@dxos/react-ui": "0.8.4-main.f9ba587",
66
- "@dxos/react-ui-theme": "0.8.4-main.f9ba587",
67
- "@dxos/storybook-utils": "0.8.4-main.f9ba587"
71
+ "react": "~19.2.3",
72
+ "react-dom": "~19.2.3",
73
+ "vite": "^8.0.10",
74
+ "@dxos/random": "0.8.4-main.fcc0d83b33",
75
+ "@dxos/storybook-utils": "0.8.4-main.fcc0d83b33",
76
+ "@dxos/react-ui": "0.8.4-main.fcc0d83b33",
77
+ "@dxos/ui-theme": "0.8.4-main.fcc0d83b33"
68
78
  },
69
79
  "peerDependencies": {
70
- "effect": "^3.13.3",
71
- "react": "~18.2.0",
72
- "react-dom": "~18.2.0",
73
- "@dxos/react-ui": "0.8.4-main.f9ba587",
74
- "@dxos/react-ui-theme": "0.8.4-main.f9ba587"
80
+ "effect": "3.20.0",
81
+ "react": "~19.2.3",
82
+ "react-dom": "~19.2.3",
83
+ "@dxos/react-ui": "0.8.4-main.fcc0d83b33",
84
+ "@dxos/ui-theme": "0.8.4-main.fcc0d83b33"
75
85
  },
76
86
  "publishConfig": {
77
87
  "access": "public"
@@ -2,33 +2,20 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Capabilities, contributes, defineModule, definePlugin, Events } from '@dxos/app-framework';
6
- import { ClientCapabilities, ClientEvents } from '@dxos/plugin-client';
5
+ import { Plugin } from '@dxos/app-framework';
6
+ import { AppPlugin } from '@dxos/app-toolkit';
7
7
 
8
8
  // import { IntentResolver } from './capabilities';
9
- import { meta } from './meta';
10
- import { translations } from './translations';
9
+ import { meta } from '#meta';
10
+ import { translations } from '#translations';
11
11
 
12
- export const TransformerPlugin = () =>
13
- definePlugin(meta, [
14
- defineModule({
15
- id: `${meta.id}/module/translations`,
16
- activatesOn: Events.SetupTranslations,
17
- activate: () => contributes(Capabilities.Translations, translations),
18
- }),
19
- defineModule({
20
- id: `${meta.id}/module/metadata`,
21
- activatesOn: Events.SetupMetadata,
22
- activate: () => [],
23
- }),
24
- defineModule({
25
- id: `${meta.id}/module/schema`,
26
- activatesOn: ClientEvents.SetupSchema,
27
- activate: () => contributes(ClientCapabilities.Schema, []),
28
- }),
29
- // defineModule({
30
- // id: `${meta.id}/module/intent-resolver`,
31
- // activatesOn: Events.SetupIntentResolver,
32
- // activate: IntentResolver,
33
- // }),
34
- ]);
12
+ export const TransformerPlugin = Plugin.define(meta).pipe(
13
+ AppPlugin.addSchemaModule({ schema: [], id: 'schema' }),
14
+ AppPlugin.addTranslationsModule({ translations }),
15
+ // Plugin.addModule({
16
+ // id: 'intent-resolver',
17
+ // activatesOn: Events.SetupIntentResolver,
18
+ // activate: IntentResolver,
19
+ // }),
20
+ Plugin.make,
21
+ );
@@ -45,9 +45,9 @@ export const DebugInfo: FC<Partial<DebugInfoProps>> = ({
45
45
  <div className='mb-2 text-green-600'>
46
46
  <strong>Status:</strong> Microphone is active
47
47
  {debug && audioLevel && (
48
- <div className='mt-2 w-48 h-5 bg-gray-200 rounded relative'>
48
+ <div className='mt-2 w-48 h-5 bg-gray-200 rounded-sm relative'>
49
49
  <div
50
- className='h-full bg-green-500 transition-all duration-100 rounded'
50
+ className='h-full bg-green-500 transition-all duration-100 rounded-sm'
51
51
  style={{ width: `${(audioLevel / 255) * 100}%` }}
52
52
  />
53
53
  </div>
@@ -67,7 +67,7 @@ export const DebugInfo: FC<Partial<DebugInfoProps>> = ({
67
67
  {transcription && (
68
68
  <div className='mt-4'>
69
69
  <strong>Transcription:</strong>
70
- <p className='mt-2 p-4 bg-gray-100 rounded whitespace-pre-wrap'>{transcription}</p>
70
+ <p className='mt-2 p-4 bg-gray-100 rounded-sm whitespace-pre-wrap'>{transcription}</p>
71
71
  </div>
72
72
  )}
73
73
  </div>
@@ -2,22 +2,20 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import '@dxos-theme';
5
+ import { type Meta, type StoryObj } from '@storybook/react-vite';
6
6
 
7
- import type { Meta, StoryObj } from '@storybook/react-vite';
8
-
9
- import { withLayout, withTheme } from '@dxos/storybook-utils';
7
+ import { withTheme } from '@dxos/react-ui/testing';
10
8
 
11
9
  import { Voice } from './Voice';
12
10
 
13
- const meta: Meta<typeof Voice> = {
14
- title: 'plugins/plugin-transformer/Voice',
11
+ const meta = {
12
+ title: 'plugins/plugin-transformer/components/Voice',
15
13
  component: Voice,
16
- decorators: [withTheme, withLayout()],
14
+ decorators: [withTheme()],
17
15
  parameters: {
18
16
  layout: 'centered',
19
17
  },
20
- };
18
+ } satisfies Meta<typeof Voice>;
21
19
 
22
20
  export default meta;
23
21
 
@@ -2,12 +2,13 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import React, { useState, useCallback, useEffect } from 'react';
5
+ import React, { useCallback, useEffect, useState } from 'react';
6
6
 
7
7
  import { log } from '@dxos/log';
8
8
 
9
+ import { useAudioStream, usePipeline } from '#hooks';
10
+
9
11
  import { DebugInfo } from './DebugInfo';
10
- import { useAudioStream, usePipeline } from '../hooks';
11
12
 
12
13
  export type VoiceProps = {
13
14
  active?: boolean;
@@ -0,0 +1,6 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ export * from './DebugInfo';
6
+ export * from './Voice';
@@ -1,3 +1,5 @@
1
1
  //
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
+
5
+ export * from './Voice';
@@ -2,7 +2,7 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { useState, useRef, useEffect, useCallback } from 'react';
5
+ import { useCallback, useEffect, useRef, useState } from 'react';
6
6
 
7
7
  import { log } from '@dxos/log';
8
8
 
@@ -28,7 +28,7 @@ export const useAudioStream = ({ active, debug, onAudioData }: AudioStreamConfig
28
28
  // TODO(burdon): Convert to class.
29
29
  const audioContextRef = useRef<AudioContext | null>(null);
30
30
  const analyserRef = useRef<AnalyserNode | null>(null);
31
- const animationFrameRef = useRef<number>();
31
+ const animationFrameRef = useRef<number>(undefined);
32
32
  const workletNodeRef = useRef<AudioWorkletNode | null>(null);
33
33
  const isProcessingRef = useRef(false);
34
34
  const mediaStreamRef = useRef<MediaStream | null>(null);
@@ -2,31 +2,12 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { type Pipeline, pipeline, env } from '@xenova/transformers';
6
- import { useState, useRef, useEffect } from 'react';
5
+ import { type Pipeline, env, pipeline } from '@xenova/transformers';
6
+ import { useEffect, useRef, useState } from 'react';
7
7
 
8
8
  import { invariant } from '@dxos/invariant';
9
9
  import { log } from '@dxos/log';
10
10
 
11
- // Add WebGPU types.
12
- declare global {
13
- interface Navigator {
14
- gpu?: {
15
- requestAdapter(): Promise<GPUAdapter | null>;
16
- };
17
- }
18
-
19
- interface GPUAdapter {
20
- requestAdapterInfo(): Promise<GPUAdapterInfo>;
21
- }
22
-
23
- interface GPUAdapterInfo {
24
- vendor: string;
25
- architecture: string;
26
- description: string;
27
- }
28
- }
29
-
30
11
  // Configure cache and runtime settings.
31
12
  env.cacheDir = './.cache';
32
13
  env.allowLocalModels = true;
@@ -87,20 +68,15 @@ export const usePipeline = ({ active, model, debug }: PipelineConfig) => {
87
68
  throw new Error('No GPU adapter found');
88
69
  }
89
70
 
90
- // Try to get adapter info if available.
91
- try {
92
- const adapterInfo = await adapter.requestAdapterInfo();
93
- if (adapterInfo) {
94
- setState((prev) => ({
95
- ...prev,
96
- gpuInfo: `${adapterInfo.description || 'GPU'} (${adapterInfo.vendor || 'Unknown'})`,
97
- }));
98
- } else {
99
- setState((prev) => ({ ...prev, gpuInfo: 'GPU Available (details unknown)' }));
100
- }
101
- } catch (err) {
102
- log.warn('could not get GPU info', { err });
103
- setState((prev) => ({ ...prev, gpuInfo: 'GPU Available (details unavailable)' }));
71
+ // Get adapter info from the info property (modern WebGPU API).
72
+ const adapterInfo = adapter.info;
73
+ if (adapterInfo) {
74
+ setState((prev) => ({
75
+ ...prev,
76
+ gpuInfo: `${adapterInfo.description || 'GPU'} (${adapterInfo.vendor || 'Unknown'})`,
77
+ }));
78
+ } else {
79
+ setState((prev) => ({ ...prev, gpuInfo: 'GPU Available (details unknown)' }));
104
80
  }
105
81
  } catch (err) {
106
82
  log.warn('WebGPU initialization failed', { err });
package/src/meta.ts CHANGED
@@ -2,14 +2,16 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { type PluginMeta } from '@dxos/app-framework';
5
+ import { type Plugin } from '@dxos/app-framework';
6
+ import { trim } from '@dxos/util';
6
7
 
7
- export const TRANSFORMER_PLUGIN = 'dxos.org/plugin/transformer';
8
-
9
- export const meta: PluginMeta = {
10
- id: TRANSFORMER_PLUGIN,
8
+ export const meta: Plugin.Meta = {
9
+ id: 'org.dxos.plugin.transformer',
11
10
  name: 'Transformer',
12
- description: 'Run local transformers.',
11
+ description: trim`
12
+ Execute local machine learning transformers and AI models directly in your browser.
13
+ Run embeddings, classifications, and other ML tasks without server dependencies.
14
+ `,
13
15
  icon: 'ph--cpu--regular',
14
16
  source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-transformer',
15
17
  tags: ['labs'],
@@ -4,13 +4,13 @@
4
4
 
5
5
  import { type Resource } from '@dxos/react-ui';
6
6
 
7
- import { meta } from './meta';
7
+ import { meta } from '#meta';
8
8
 
9
9
  export const translations = [
10
10
  {
11
11
  'en-US': {
12
12
  [meta.id]: {
13
- 'plugin name': 'Transformers',
13
+ 'plugin.name': 'Transformers',
14
14
  },
15
15
  },
16
16
  },
@@ -1 +0,0 @@
1
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/index.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"DebugInfo.d.ts","sourceRoot":"","sources":["../../../../src/components/DebugInfo.tsx"],"names":[],"mappings":"AAIA,OAAc,EAAE,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,OAAO,CAAC;IACxB,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3B,cAAc,EAAE,OAAO,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,CA4DjD,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Voice.d.ts","sourceRoot":"","sources":["../../../../src/components/Voice.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAOhE,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,KAAK,GAAI,0BAAkD,UAAU,sBA4FjF,CAAC"}
@@ -1,8 +0,0 @@
1
- import '@dxos-theme';
2
- import type { Meta, StoryObj } from '@storybook/react-vite';
3
- import { Voice } from './Voice';
4
- declare const meta: Meta<typeof Voice>;
5
- export default meta;
6
- type Story = StoryObj<typeof Voice>;
7
- export declare const Default: Story;
8
- //# sourceMappingURL=Voice.stories.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Voice.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/Voice.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAI5D,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,KAAK,CAO5B,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,KAAK,CAAC,CAAC;AAEpC,eAAO,MAAM,OAAO,EAAE,KAMrB,CAAC"}