@dxos/react-ui-canvas-compute 0.8.4-main.8360d9e660 → 0.8.4-main.8baae0fced

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 (103) hide show
  1. package/LICENSE +102 -5
  2. package/dist/lib/browser/index.mjs +382 -459
  3. package/dist/lib/browser/index.mjs.map +4 -4
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/node-esm/index.mjs +382 -459
  6. package/dist/lib/node-esm/index.mjs.map +4 -4
  7. package/dist/lib/node-esm/meta.json +1 -1
  8. package/dist/types/src/components/DiagnosticOverlay.d.ts.map +1 -1
  9. package/dist/types/src/compute-layout.d.ts.map +1 -1
  10. package/dist/types/src/compute.stories.d.ts +1 -1
  11. package/dist/types/src/compute.stories.d.ts.map +1 -1
  12. package/dist/types/src/graph/controller.d.ts +45 -30
  13. package/dist/types/src/graph/controller.d.ts.map +1 -1
  14. package/dist/types/src/graph/node-defs.d.ts.map +1 -1
  15. package/dist/types/src/hooks/useComputeGraphController.d.ts.map +1 -1
  16. package/dist/types/src/hooks/useComputeNodeState.d.ts +2 -3
  17. package/dist/types/src/hooks/useComputeNodeState.d.ts.map +1 -1
  18. package/dist/types/src/hooks/useGraphMonitor.d.ts.map +1 -1
  19. package/dist/types/src/shapes/Append.d.ts +1 -1
  20. package/dist/types/src/shapes/Append.d.ts.map +1 -1
  21. package/dist/types/src/shapes/Array.d.ts +1 -1
  22. package/dist/types/src/shapes/Array.d.ts.map +1 -1
  23. package/dist/types/src/shapes/Audio.d.ts +1 -1
  24. package/dist/types/src/shapes/Audio.d.ts.map +1 -1
  25. package/dist/types/src/shapes/Beacon.d.ts +1 -1
  26. package/dist/types/src/shapes/Beacon.d.ts.map +1 -1
  27. package/dist/types/src/shapes/Boolean.d.ts +7 -7
  28. package/dist/types/src/shapes/Boolean.d.ts.map +1 -1
  29. package/dist/types/src/shapes/Chat.d.ts +1 -1
  30. package/dist/types/src/shapes/Chat.d.ts.map +1 -1
  31. package/dist/types/src/shapes/Constant.d.ts +1 -1
  32. package/dist/types/src/shapes/Constant.d.ts.map +1 -1
  33. package/dist/types/src/shapes/Database.d.ts +1 -1
  34. package/dist/types/src/shapes/Database.d.ts.map +1 -1
  35. package/dist/types/src/shapes/{Queue.d.ts → Feed.d.ts} +9 -9
  36. package/dist/types/src/shapes/Feed.d.ts.map +1 -0
  37. package/dist/types/src/shapes/Function.d.ts +1 -1
  38. package/dist/types/src/shapes/Function.d.ts.map +1 -1
  39. package/dist/types/src/shapes/Gpt.d.ts +1 -1
  40. package/dist/types/src/shapes/Gpt.d.ts.map +1 -1
  41. package/dist/types/src/shapes/GptRealtime.d.ts +1 -1
  42. package/dist/types/src/shapes/GptRealtime.d.ts.map +1 -1
  43. package/dist/types/src/shapes/Json.d.ts +2 -2
  44. package/dist/types/src/shapes/Json.d.ts.map +1 -1
  45. package/dist/types/src/shapes/Logic.d.ts +2 -2
  46. package/dist/types/src/shapes/Logic.d.ts.map +1 -1
  47. package/dist/types/src/shapes/RNG.d.ts +2 -2
  48. package/dist/types/src/shapes/RNG.d.ts.map +1 -1
  49. package/dist/types/src/shapes/Scope.d.ts +1 -1
  50. package/dist/types/src/shapes/Scope.d.ts.map +1 -1
  51. package/dist/types/src/shapes/Surface.d.ts +1 -1
  52. package/dist/types/src/shapes/Surface.d.ts.map +1 -1
  53. package/dist/types/src/shapes/Switch.d.ts +1 -1
  54. package/dist/types/src/shapes/Switch.d.ts.map +1 -1
  55. package/dist/types/src/shapes/Table.d.ts +1 -1
  56. package/dist/types/src/shapes/Table.d.ts.map +1 -1
  57. package/dist/types/src/shapes/Template.d.ts +2 -2
  58. package/dist/types/src/shapes/Template.d.ts.map +1 -1
  59. package/dist/types/src/shapes/Text.d.ts +1 -1
  60. package/dist/types/src/shapes/Text.d.ts.map +1 -1
  61. package/dist/types/src/shapes/TextToImage.d.ts +1 -1
  62. package/dist/types/src/shapes/TextToImage.d.ts.map +1 -1
  63. package/dist/types/src/shapes/Thread.d.ts +1 -1
  64. package/dist/types/src/shapes/Thread.d.ts.map +1 -1
  65. package/dist/types/src/shapes/Trigger.d.ts +2 -2
  66. package/dist/types/src/shapes/Trigger.d.ts.map +1 -1
  67. package/dist/types/src/shapes/common/Box.d.ts.map +1 -1
  68. package/dist/types/src/shapes/common/FunctionBody.d.ts.map +1 -1
  69. package/dist/types/src/shapes/common/TypeSelect.d.ts +1 -1
  70. package/dist/types/src/shapes/common/TypeSelect.d.ts.map +1 -1
  71. package/dist/types/src/shapes/defs.d.ts +1 -1
  72. package/dist/types/src/shapes/defs.d.ts.map +1 -1
  73. package/dist/types/src/shapes/index.d.ts +2 -2
  74. package/dist/types/src/shapes/index.d.ts.map +1 -1
  75. package/dist/types/src/testing/circuits.d.ts.map +1 -1
  76. package/dist/types/tsconfig.tsbuildinfo +1 -1
  77. package/package.json +47 -48
  78. package/src/compute.stories.tsx +26 -10
  79. package/src/graph/controller.ts +65 -26
  80. package/src/hooks/useComputeNodeState.ts +3 -5
  81. package/src/hooks/useGraphMonitor.ts +3 -3
  82. package/src/registry.ts +2 -2
  83. package/src/shapes/Audio.tsx +0 -1
  84. package/src/shapes/Beacon.tsx +0 -1
  85. package/src/shapes/Boolean.tsx +1 -1
  86. package/src/shapes/Chat.tsx +0 -1
  87. package/src/shapes/Constant.tsx +0 -1
  88. package/src/shapes/{Queue.tsx → Feed.tsx} +13 -14
  89. package/src/shapes/Function.tsx +5 -4
  90. package/src/shapes/Gpt.tsx +0 -1
  91. package/src/shapes/Json.tsx +9 -3
  92. package/src/shapes/RNG.tsx +0 -1
  93. package/src/shapes/Scope.tsx +0 -1
  94. package/src/shapes/Surface.tsx +4 -2
  95. package/src/shapes/Switch.tsx +0 -1
  96. package/src/shapes/Template.tsx +0 -1
  97. package/src/shapes/Text.tsx +0 -1
  98. package/src/shapes/Thread.tsx +1 -5
  99. package/src/shapes/Trigger.tsx +12 -17
  100. package/src/shapes/common/Box.tsx +0 -2
  101. package/src/shapes/index.ts +2 -2
  102. package/src/testing/circuits.ts +2 -2
  103. package/dist/types/src/shapes/Queue.d.ts.map +0 -1
@@ -10,7 +10,6 @@ import { Icon, type IconProps } from '@dxos/react-ui';
10
10
  import { type ShapeComponentProps, type ShapeDef, createAnchorMap } from '@dxos/react-ui-canvas-editor';
11
11
 
12
12
  import { useComputeNodeState } from '../hooks';
13
-
14
13
  import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
15
14
 
16
15
  export const RandomShape = Schema.extend(
@@ -10,7 +10,6 @@ import { type ShapeComponentProps, type ShapeDef, createAnchorMap } from '@dxos/
10
10
  import { Chaos, shaderPresets, useAudioStream } from '@dxos/react-ui-sfx';
11
11
 
12
12
  import { useComputeNodeState } from '../hooks';
13
-
14
13
  import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
15
14
 
16
15
  export const ScopeShape = Schema.extend(
@@ -6,13 +6,13 @@ import * as Schema from 'effect/Schema';
6
6
  import React from 'react';
7
7
 
8
8
  import { Surface } from '@dxos/app-framework/ui';
9
+ import { AppSurface } from '@dxos/app-toolkit/ui';
9
10
  import { DEFAULT_INPUT } from '@dxos/conductor';
10
11
  import { Card } from '@dxos/react-ui';
11
12
  import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
12
13
  import { createAnchorMap } from '@dxos/react-ui-canvas-editor';
13
14
 
14
15
  import { useComputeNodeState } from '../hooks';
15
-
16
16
  import { Box, type BoxActionHandler } from './common';
17
17
  import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
18
18
 
@@ -48,7 +48,9 @@ export const SurfaceComponent = ({ shape }: ShapeComponentProps<SurfaceShape>) =
48
48
  // TODO(burdon): Subject property?
49
49
  return (
50
50
  <Box shape={shape} onAction={handleAction}>
51
- <Card.Root>{value !== null && <Surface.Surface role='card--content' data={{ value }} limit={1} />}</Card.Root>
51
+ <Card.Root>
52
+ {value !== null && <Surface.Surface type={AppSurface.Card} data={{ subject: value }} limit={1} />}
53
+ </Card.Root>
52
54
  </Box>
53
55
  );
54
56
  };
@@ -10,7 +10,6 @@ import { Input } from '@dxos/react-ui';
10
10
  import { type ShapeComponentProps, type ShapeDef, createAnchorMap } from '@dxos/react-ui-canvas-editor';
11
11
 
12
12
  import { useComputeNodeState } from '../hooks';
13
-
14
13
  import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
15
14
 
16
15
  export const SwitchShape = Schema.extend(
@@ -17,7 +17,6 @@ import {
17
17
  } from '@dxos/react-ui-canvas-editor';
18
18
 
19
19
  import { useComputeNodeState } from '../hooks';
20
-
21
20
  import { Box, TypeSelect, createFunctionAnchors } from './common';
22
21
  import { ComputeShape, type CreateShapeProps, createShape } from './defs';
23
22
 
@@ -10,7 +10,6 @@ import { type ShapeComponentProps, type ShapeDef, TextBox } from '@dxos/react-ui
10
10
  import { createAnchorMap } from '@dxos/react-ui-canvas-editor';
11
11
 
12
12
  import { useComputeNodeState } from '../hooks';
13
-
14
13
  import { Box, type BoxActionHandler } from './common';
15
14
  import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
16
15
 
@@ -55,11 +55,7 @@ export const ThreadComponent = ({ shape }: ShapeComponentProps<ThreadShape>) =>
55
55
 
56
56
  export const ThreadItem = ({ classNames, item }: ThemedClassName<{ item: any }>) => {
57
57
  if (typeof item !== 'object') {
58
- return (
59
- <div role='none' className={mx(classNames)}>
60
- {item}
61
- </div>
62
- );
58
+ return <div className={mx(classNames)}>{item}</div>;
63
59
  }
64
60
 
65
61
  // TODO(burdon): Hack; introspect type.
@@ -5,12 +5,12 @@
5
5
  import * as Schema from 'effect/Schema';
6
6
  import React, { useEffect } from 'react';
7
7
 
8
+ import { Trigger, TriggerEvent } from '@dxos/compute';
8
9
  import { VoidInput } from '@dxos/conductor';
9
10
  import { Filter, Obj, Query, Ref } from '@dxos/echo';
10
11
  import { type Mutable } from '@dxos/echo/internal';
11
- import { Trigger, TriggerEvent } from '@dxos/functions';
12
12
  import { DXN, SpaceId } from '@dxos/keys';
13
- import { useSpace } from '@dxos/react-client/echo';
13
+ import { useSpaces } from '@dxos/react-client/echo';
14
14
  import { Select, type SelectRootProps } from '@dxos/react-ui';
15
15
  import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
16
16
 
@@ -48,13 +48,13 @@ export const createTrigger = (props: CreateTriggerProps): TriggerShape => {
48
48
  export type TriggerComponentProps = ShapeComponentProps<TriggerShape>;
49
49
 
50
50
  export const TriggerComponent = ({ shape }: TriggerComponentProps) => {
51
- const space = useSpace();
51
+ const [space] = useSpaces();
52
52
  const functionTrigger = shape.functionTrigger?.target;
53
53
 
54
54
  useEffect(() => {
55
55
  if (functionTrigger && !functionTrigger.spec) {
56
- Obj.change(functionTrigger, (t) => {
57
- t.spec = createTriggerSpec({ triggerKind: 'email', spaceId: space?.id }) as Mutable<Trigger.Spec>;
56
+ Obj.update(functionTrigger, (functionTrigger) => {
57
+ functionTrigger.spec = createTriggerSpec({ triggerKind: 'email', spaceId: space?.id }) as Mutable<Trigger.Spec>;
58
58
  });
59
59
  }
60
60
  }, [functionTrigger, functionTrigger?.spec]);
@@ -65,8 +65,8 @@ export const TriggerComponent = ({ shape }: TriggerComponentProps) => {
65
65
 
66
66
  const setKind = (kind: Trigger.Kind) => {
67
67
  if (functionTrigger?.spec?.kind !== kind) {
68
- Obj.change(functionTrigger!, (t) => {
69
- t.spec = createTriggerSpec({ triggerKind: kind, spaceId: space?.id }) as Mutable<Trigger.Spec>;
68
+ Obj.update(functionTrigger!, (obj) => {
69
+ obj.spec = createTriggerSpec({ triggerKind: kind, spaceId: space?.id }) as Mutable<Trigger.Spec>;
70
70
  });
71
71
  }
72
72
  };
@@ -114,21 +114,16 @@ const createTriggerSpec = (props: { triggerKind?: Trigger.Kind; spaceId?: SpaceI
114
114
  const kind = props.triggerKind ?? 'email';
115
115
  switch (kind) {
116
116
  case 'timer':
117
- return { kind: 'timer', cron: '*/10 * * * * *' } satisfies Trigger.TimerSpec;
117
+ return Trigger.specTimer('*/10 * * * * *');
118
118
  case 'webhook':
119
- return { kind: 'webhook', method: 'POST' } satisfies Trigger.WebhookSpec;
119
+ return Trigger.specWebhook({ method: 'POST' });
120
120
  case 'subscription':
121
- return {
122
- kind: 'subscription',
123
- query: {
124
- ast: Query.select(Filter.nothing()).ast,
125
- },
126
- } satisfies Trigger.SubscriptionSpec;
121
+ return Trigger.specSubscription(Query.select(Filter.nothing()));
127
122
  case 'email':
128
- return { kind: 'email' } satisfies Trigger.EmailSpec;
123
+ return Trigger.specEmail();
129
124
  case 'queue': {
130
125
  const dxn = new DXN(DXN.kind.QUEUE, ['data', props.spaceId ?? SpaceId.random(), Obj.ID.random()]).toString();
131
- return { kind: 'queue', queue: dxn } satisfies Trigger.QueueSpec;
126
+ return Trigger.specQueue(dxn);
132
127
  }
133
128
  }
134
129
  };
@@ -39,7 +39,6 @@ export const Box = forwardRef<HTMLDivElement, BoxProps>(
39
39
  classNames='p-1 text-green-500'
40
40
  variant='ghost'
41
41
  icon='ph--play--regular'
42
- size={4}
43
42
  label='run'
44
43
  iconOnly
45
44
  onDoubleClick={(ev) => ev.stopPropagation()}
@@ -57,7 +56,6 @@ export const Box = forwardRef<HTMLDivElement, BoxProps>(
57
56
  classNames='p-1'
58
57
  variant='ghost'
59
58
  icon={open ? 'ph--caret-up--regular' : 'ph--caret-down--regular'}
60
- size={4}
61
59
  label={open ? 'close' : 'open'}
62
60
  iconOnly
63
61
  onClick={(ev) => {
@@ -13,11 +13,12 @@ export * from './Boolean';
13
13
  export * from './Chat';
14
14
  export * from './Constant';
15
15
  export * from './Database';
16
+ export * from './Feed';
16
17
  export * from './Function';
17
18
  export * from './Gpt';
19
+ export * from './GptRealtime';
18
20
  export * from './Json';
19
21
  export * from './Logic';
20
- export * from './Queue';
21
22
  export * from './RNG';
22
23
  export * from './Scope';
23
24
  export * from './Surface';
@@ -28,4 +29,3 @@ export * from './Text';
28
29
  export * from './Thread';
29
30
  export * from './TextToImage';
30
31
  export * from './Trigger';
31
- export * from './GptRealtime';
@@ -24,7 +24,7 @@ import {
24
24
  createJsonTransform,
25
25
  createNot,
26
26
  createOr,
27
- createQueue,
27
+ createFeed,
28
28
  createRandom,
29
29
  createScope,
30
30
  createSurface,
@@ -241,7 +241,7 @@ export const createGptCircuit = (options: {
241
241
  }),
242
242
  );
243
243
 
244
- const thread = model.createNode(createQueue(position({ x: -3, y: 3, width: 14, height: 10 })));
244
+ const thread = model.createNode(createFeed(position({ x: -3, y: 3, width: 14, height: 10 })));
245
245
  const append = model.createNode(createAppend(position({ x: 10, y: 6 })));
246
246
 
247
247
  builder
@@ -1 +0,0 @@
1
- {"version":3,"file":"Queue.d.ts","sourceRoot":"","sources":["../../../../src/shapes/Queue.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAmB,MAAM,OAAO,CAAC;AAGxC,OAAO,EAAc,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,KAAK,mBAAmB,EAAE,KAAK,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAOvF,OAAO,EAAgB,KAAK,gBAAgB,EAAe,MAAM,QAAQ,CAAC;AAE1E,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;GAKtB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,UAAU,CAAC,CAAC;AAE/D,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;AAE5D,eAAO,MAAM,WAAW,GAAI,OAAO,gBAAgB;;;;;;;;;;;;;;;;;;;CAK/C,CAAC;AAEL,eAAO,MAAM,cAAc,GAAI,WAAW,mBAAmB,CAAC,UAAU,CAAC,sBAqBxE,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,sBAAsB,eAAe,CAAC;IAAE,IAAI,EAAE,GAAG,CAAA;CAAE,CAAC,sBAe7E,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,UAAU,CAQ3C,CAAC"}