Skip to content

Commit a3dd995

Browse files
committed
First working graph
1 parent 83fb33b commit a3dd995

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+657
-71
lines changed

__tests__/html/renderActivity.profiling.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
></script>
1212
<script crossorigin="anonymous" src="/test-harness.js"></script>
1313
<script crossorigin="anonymous" src="/test-page-object.js"></script>
14-
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
14+
<!-- <script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script> -->
15+
<script crossorigin="anonymous" src="https://cdn.jsdelivr.net/npm/botframework-webchat@main/dist/webchat-es5.js"></script>
1516
<script src="https://cdn.jsdelivr.net/npm/d3@7"></script>
1617
<style>
1718
body {

package-lock.json

Lines changed: 44 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"./packages/test/dev-server",
2121
"./packages/test/harness",
2222
"./packages/test/web-server",
23+
"./packages/core-graph",
2324
"./packages/core",
2425
"./packages/react-hooks",
2526
"./packages/react-valibot",
@@ -79,6 +80,7 @@
7980
"precommit:eslint:bundle": "cd packages && cd bundle && npm run precommit:eslint",
8081
"precommit:eslint:component": "cd packages && cd component && npm run precommit:eslint",
8182
"precommit:eslint:core": "cd packages && cd core && npm run precommit:eslint",
83+
"precommit:eslint:core-graph": "cd packages && cd core-graph && npm run precommit:eslint",
8284
"precommit:eslint:debug-theme": "cd packages && cd debug-theme && npm run precommit:eslint",
8385
"precommit:eslint:directlinespeech": "cd packages && cd directlinespeech && npm run precommit:eslint",
8486
"precommit:eslint:fluent-theme": "cd packages && cd fluent-theme && npm run precommit:eslint",
@@ -114,6 +116,7 @@
114116
"precommit:typecheck:bundle": "cd packages && cd bundle && npm run precommit:typecheck",
115117
"precommit:typecheck:component": "cd packages && cd component && npm run precommit:typecheck",
116118
"precommit:typecheck:core": "cd packages && cd core && npm run precommit:typecheck",
119+
"precommit:typecheck:core-graph": "cd packages && cd core-graph && npm run precommit:typecheck",
117120
"precommit:typecheck:debug-theme": "cd packages && cd debug-theme && npm run precommit:typecheck",
118121
"precommit:typecheck:fluent-theme": "cd packages && cd fluent-theme && npm run precommit:typecheck",
119122
"precommit:typecheck:react-hooks": "cd packages && cd react-hooks && npm run precommit:typecheck",
@@ -141,6 +144,7 @@
141144
"start:bundle": "cd packages && cd bundle && npm start",
142145
"start:component": "cd packages && cd component && npm start",
143146
"start:core": "cd packages && cd core && npm start",
147+
"start:core-graph": "cd packages && cd core-graph && npm start",
144148
"start:debug-theme": "cd packages && cd debug-theme && npm start",
145149
"start:directlinespeech": "cd packages && cd directlinespeech && npm start",
146150
"start:fluent-theme": "cd packages && cd fluent-theme && npm start",

packages/api-graph/package.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,22 @@
5151
"start": "../../scripts/npm/notify-build.sh \"src\""
5252
},
5353
"pinDependencies": {},
54-
"localDependencies": {},
54+
"localDependencies": {
55+
"@msinternal/botframework-webchat-react-valibot": "development",
56+
"botframework-webchat-core": "development"
57+
},
5558
"devDependencies": {
59+
"@msinternal/botframework-webchat-react-hooks": "0.0.0-0",
5660
"@msinternal/botframework-webchat-react-valibot": "0.0.0-0",
5761
"@testduet/given-when-then": "^0.1.1-main.28754e6",
62+
"@types/use-sync-external-store": "^1.5.0",
63+
"botframework-webchat-core": "0.0.0-0",
5864
"type-fest": "^4.41.0",
5965
"typescript": "^5.7.3"
6066
},
6167
"peerDependencies": {
62-
"react": ">= 16.8.6"
68+
"react": ">= 16.8.6",
69+
"use-ref-from": "0.1.0"
6370
},
6471
"dependencies": {
6572
"valibot": "1.1.0"

packages/api-graph/src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
export { default as useNodeObject } from './private/useNodeObject';
1+
// export { default as useNodeObject } from './private/useNodeObject';
2+
export { default as GraphProvider } from './private/GraphProvider';
3+
export { default as useOrderedActivities } from './private/useOrderedActivities';

packages/api-graph/src/private/GraphContext.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
1+
import type { WebChatActivity } from 'botframework-webchat-core';
2+
import { identifier, slantNode, type Identifier, type SlantNode } from 'botframework-webchat-core/graph';
13
import { createContext, useContext } from 'react';
2-
import { custom, function_, map, object, pipe, readonly, safeParse, string, type InferOutput } from 'valibot';
3-
4-
import { expandedFlatNodeObjectSchema } from './schemas/expandArray';
5-
import type { FlattenNodeObjectInput } from './schemas/flattenNodeObject';
4+
import { array, custom, map, object, pipe, readonly, tuple } from 'valibot';
65

76
const graphContextSchema = pipe(
87
object({
9-
graph: pipe(map(string(), expandedFlatNodeObjectSchema), readonly()),
10-
mergeNode: custom<(node: FlattenNodeObjectInput) => void>(value => safeParse(function_(), value).success)
8+
// TODO: Maybe should use `freeze()` instead.
9+
nodeMap: pipe(map(identifier(), slantNode()), readonly()),
10+
// TODO: Maybe should use `freeze()` instead.
11+
orderedActivitiesState: pipe(tuple([pipe(array(custom<WebChatActivity>(() => true)), readonly())]), readonly())
1112
}),
1213
readonly()
1314
);
1415

15-
type GraphContextType = InferOutput<typeof graphContextSchema>;
16+
// type GraphContextType = InferOutput<typeof graphContextSchema>;
17+
18+
type GraphContextType = {
19+
readonly nodeMap: ReadonlyMap<Identifier, SlantNode>;
20+
readonly orderedActivitiesState: readonly [readonly WebChatActivity[]];
21+
};
1622

1723
const GraphContext = createContext<GraphContextType>(
1824
new Proxy({} as GraphContextType, {

0 commit comments

Comments
 (0)