Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package/bin/validate-entry-isolation.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const WRAPPERS = ['native-package', 'expo-package'].map((name) => path.join(PACK
// Third-party packages only the AI components may use. (`lodash` and `@stream-io/state-store` are
// not among them: the main entry point imports both too.)
const AI_ONLY_PACKAGES = [
'@khanacademy/simple-markdown',
'@legendapp/list',
'@shopify/react-native-skia',
'react-native-keyboard-controller',
Expand Down
2 changes: 1 addition & 1 deletion package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
"dependencies": {
"@a2ui/web_core": "~0.15.0",
"@gorhom/bottom-sheet": "^5.2.14",
"@khanacademy/simple-markdown": "^2.1.0",
"@legendapp/list": "^3.7.1",
"@stream-io/i18n": "^1.1.0",
"@stream-io/state-store": "^1.2.0",
Expand All @@ -88,6 +87,7 @@
"react-native-markdown-package": "1.8.2",
"react-native-url-polyfill": "^2.0.0",
"react-syntax-highlighter": "^16.1.0",
"simple-markdown": "^0.7.3",
"stream-chat": "^10.0.1",
"use-sync-external-store": "^1.7.0",
"zod": "^4.1.12"
Expand Down
16 changes: 8 additions & 8 deletions package/src/ai-components/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,14 @@ The `StreamingMessageView` is a component that can render markdown content effic

Under the hood, it implements a letter-by-letter typewriter animation with a character queue, similar to ChatGPT.

| Name | Type | Required | Description |
| ------------------------ | -------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `text` | `string` | yes | The text we want to pass as markdown. |
| `paragraphNumberOfLines` | `number` | no | The `numberOfLines` applied to markdown `Paragraph` and `Text` components. Particularly useful if we want to display the same message, but in a "cut" fashion (for example when replying to someone). |
| `rules` | [`MarkdownRules`](./markdown/types.ts) | no | An object of `MarkdownRules` that is then going to be deeply merged with our default rules, based on the [`SimpleMarkdown` parsing engine](https://github.com/Khan/perseus/tree/main/packages/simple-markdown#adding-a-simple-extension). Can be used to add custom rules or change existing rules. You can disable a rule by passing `{ [ruleName]: { match: () => null }}`. |
| `onLink` | `(url: string) => void` | no | A function that is going to be invoked whenever a link is pressed within markdown parsed text. |
| `letterInterval` | `number` | no | The milliseconds between steps, for a fixed pace. Without it and `renderingLetterCount`, the text keeps up with what arrives: each new part is typed out within about 0.4 seconds. |
| `renderingLetterCount` | `number` | no | The letters typed each step, for a fixed pace. Defaults to `2` when `letterInterval` is given. |
| Name | Type | Required | Description |
| ------------------------ | -------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `text` | `string` | yes | The text we want to pass as markdown. |
| `paragraphNumberOfLines` | `number` | no | The `numberOfLines` applied to markdown `Paragraph` and `Text` components. Particularly useful if we want to display the same message, but in a "cut" fashion (for example when replying to someone). |
| `rules` | [`MarkdownRules`](./markdown/types.ts) | no | An object of `MarkdownRules` that is then going to be deeply merged with our default rules, based on the [`SimpleMarkdown` parsing engine](https://github.com/Khan/simple-markdown#adding-a-simple-extension). Can be used to add custom rules or change existing rules. You can disable a rule by passing `{ [ruleName]: { match: () => null }}`. |
| `onLink` | `(url: string) => void` | no | A function that is going to be invoked whenever a link is pressed within markdown parsed text. |
| `letterInterval` | `number` | no | The milliseconds between steps, for a fixed pace. Without it and `renderingLetterCount`, the text keeps up with what arrives: each new part is typed out within about 0.4 seconds. |
| `renderingLetterCount` | `number` | no | The letters typed each step, for a fixed pace. Defaults to `2` when `letterInterval` is given. |

#### Example

Expand Down
2 changes: 1 addition & 1 deletion package/src/ai-components/markdown/components/List.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { PropsWithChildren } from 'react';
import { Text, type TextProps, View, type ViewProps } from 'react-native';

import type { SingleASTNode } from '@khanacademy/simple-markdown';
import type { SingleASTNode } from 'simple-markdown';

import type { BulletProps, MarkdownComponentProps, RuleRenderFunction } from '../types';

Expand Down
8 changes: 4 additions & 4 deletions package/src/ai-components/markdown/components/Markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import React, { type PropsWithChildren, useMemo } from 'react';

import { View } from 'react-native';

import isArray from 'lodash/isArray';
import isEqual from 'lodash/isEqual';
import merge from 'lodash/merge';
import SimpleMarkdown, {
type OutputRules,
type ParserRules,
type ReactOutputRule,
} from '@khanacademy/simple-markdown';
import isArray from 'lodash/isArray';
import isEqual from 'lodash/isEqual';
import merge from 'lodash/merge';
} from 'simple-markdown';

import { useTheme } from '../../contexts';
import { getLocalRules } from '../rules';
Expand Down
2 changes: 1 addition & 1 deletion package/src/ai-components/markdown/components/Table.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useCallback, useMemo } from 'react';
import { Text, View } from 'react-native';

import type { SingleASTNode } from '@khanacademy/simple-markdown';
import type { SingleASTNode } from 'simple-markdown';

import { MarkdownReactiveScrollView } from '../../components';
import type {
Expand Down
4 changes: 2 additions & 2 deletions package/src/ai-components/markdown/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import type {
Parser,
ReactOutputRule,
SingleASTNode,
} from '@khanacademy/simple-markdown';
import SimpleMarkdown from '@khanacademy/simple-markdown';
} from 'simple-markdown';
import SimpleMarkdown from 'simple-markdown';

import {
renderAutolink,
Expand Down
11 changes: 3 additions & 8 deletions package/src/ai-components/markdown/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,9 @@ import type {
ViewStyle,
} from 'react-native';

import type SimpleMarkdown from '@khanacademy/simple-markdown';
import type { Output } from '@khanacademy/simple-markdown';
import type {
ParserRule,
ReactOutputRule,
SingleASTNode,
State,
} from '@khanacademy/simple-markdown';
import type SimpleMarkdown from 'simple-markdown';
import type { Output } from 'simple-markdown';
import type { ParserRule, ReactOutputRule, SingleASTNode, State } from 'simple-markdown';

import type { DeepPartial } from '../contexts';

Expand Down
23 changes: 2 additions & 21 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3873,25 +3873,6 @@ __metadata:
languageName: node
linkType: hard

"@khanacademy/perseus-utils@npm:2.1.5":
version: 2.1.5
resolution: "@khanacademy/perseus-utils@npm:2.1.5"
checksum: 10c0/d6d511f546024f2e2468a27cb57883706ac599b3855bb02abb8d46fbd67be12956a2571dc95bea1cf6c432f4c5246c1f0d241d47729a5053a2d4522e6619ae5f
languageName: node
linkType: hard

"@khanacademy/simple-markdown@npm:^2.1.0":
version: 2.2.3
resolution: "@khanacademy/simple-markdown@npm:2.2.3"
dependencies:
"@khanacademy/perseus-utils": "npm:2.1.5"
peerDependencies:
react: ^18.2.0
react-dom: ^18.2.0
checksum: 10c0/cdcee61e95f6e01df298d265edb882a76248694cc24cdd1d55f335083ac4d3508579f3d90710e316e8c7926baff1a69187063d6ffaa62528f5162763c98103bd
languageName: node
linkType: hard

"@legendapp/list@npm:^3.7.1":
version: 3.7.1
resolution: "@legendapp/list@npm:3.7.1"
Expand Down Expand Up @@ -19160,7 +19141,7 @@ __metadata:
languageName: node
linkType: hard

"simple-markdown@npm:^0.7.1":
"simple-markdown@npm:^0.7.1, simple-markdown@npm:^0.7.3":
version: 0.7.3
resolution: "simple-markdown@npm:0.7.3"
dependencies:
Expand Down Expand Up @@ -19573,7 +19554,6 @@ __metadata:
"@babel/core": "npm:^7.29.0"
"@babel/runtime": "npm:^7.29.2"
"@gorhom/bottom-sheet": "npm:^5.2.14"
"@khanacademy/simple-markdown": "npm:^2.1.0"
"@legendapp/list": "npm:^3.7.1"
"@op-engineering/op-sqlite": "npm:^18.2.5"
"@react-native-community/netinfo": "npm:^12.0.1"
Expand Down Expand Up @@ -19629,6 +19609,7 @@ __metadata:
react-syntax-highlighter: "npm:^16.1.0"
react-test-renderer: "npm:19.3.0"
rimraf: "npm:^6.0.1"
simple-markdown: "npm:^0.7.3"
stream-chat: "npm:^10.0.1"
typescript: "npm:6.0.3"
use-sync-external-store: "npm:^1.7.0"
Expand Down
Loading