diff --git a/package/bin/validate-entry-isolation.js b/package/bin/validate-entry-isolation.js index 1d7dac568d..ac2d9e881f 100644 --- a/package/bin/validate-entry-isolation.js +++ b/package/bin/validate-entry-isolation.js @@ -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', diff --git a/package/package.json b/package/package.json index 34f49998ad..aaa8ae4937 100644 --- a/package/package.json +++ b/package/package.json @@ -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", @@ -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" diff --git a/package/src/ai-components/README.md b/package/src/ai-components/README.md index 88fc5fe548..e6dd92cc19 100644 --- a/package/src/ai-components/README.md +++ b/package/src/ai-components/README.md @@ -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 diff --git a/package/src/ai-components/markdown/components/List.tsx b/package/src/ai-components/markdown/components/List.tsx index ae2644914d..0344e7bbb2 100644 --- a/package/src/ai-components/markdown/components/List.tsx +++ b/package/src/ai-components/markdown/components/List.tsx @@ -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'; diff --git a/package/src/ai-components/markdown/components/Markdown.tsx b/package/src/ai-components/markdown/components/Markdown.tsx index f3d2c6a76f..6ee3b4ce49 100644 --- a/package/src/ai-components/markdown/components/Markdown.tsx +++ b/package/src/ai-components/markdown/components/Markdown.tsx @@ -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'; diff --git a/package/src/ai-components/markdown/components/Table.tsx b/package/src/ai-components/markdown/components/Table.tsx index 9cb4987cdb..8f30ba0c42 100644 --- a/package/src/ai-components/markdown/components/Table.tsx +++ b/package/src/ai-components/markdown/components/Table.tsx @@ -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 { diff --git a/package/src/ai-components/markdown/rules.ts b/package/src/ai-components/markdown/rules.ts index e14548a9e8..5530f22b47 100644 --- a/package/src/ai-components/markdown/rules.ts +++ b/package/src/ai-components/markdown/rules.ts @@ -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, diff --git a/package/src/ai-components/markdown/types.ts b/package/src/ai-components/markdown/types.ts index 4f8ef6109b..ca4d26570c 100644 --- a/package/src/ai-components/markdown/types.ts +++ b/package/src/ai-components/markdown/types.ts @@ -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'; diff --git a/yarn.lock b/yarn.lock index 0554f7123c..2de7264651 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" @@ -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: @@ -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" @@ -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"