diff --git a/apps/nextra/utils/generated/localeMap.ts b/apps/nextra/utils/generated/localeMap.ts index bb02ae892..b6324779d 100644 --- a/apps/nextra/utils/generated/localeMap.ts +++ b/apps/nextra/utils/generated/localeMap.ts @@ -454,6 +454,9 @@ export const localeMap = { "/build/smart-contracts/book/constants": { "en": true }, + "/build/smart-contracts/bookums": { + "en": true + }, "/build/smart-contracts/book/equality": { "en": true }, @@ -481,6 +484,9 @@ export const localeMap = { "/build/smart-contracts/book/modules-and-scripts": { "en": true }, + "/build/smart-contracts/book/move-2.0": { + "en": true + }, "/build/smart-contracts/book/move-tutorial": { "en": true }, diff --git a/packages/aptos-nextra-components/package.json b/packages/aptos-nextra-components/package.json index 48b2b1ce5..06d42c796 100644 --- a/packages/aptos-nextra-components/package.json +++ b/packages/aptos-nextra-components/package.json @@ -20,11 +20,18 @@ "build:watch": "tsup --watch", "lint:fix": "eslint --ext .ts,.tsx --quiet --fix --ignore-path ./.gitignore", "lint:format": "prettier --loglevel warn --write \"./**/*.{ts,tsx,css,md,json}\" ", - "lint": "pnpm lint:format && pnpm lint:fix " + "lint": "pnpm lint:format && pnpm lint:fix ", + "test": "vitest" }, "dependencies": { "clsx": "2.1.0", - "tailwind-merge": "^2.2.2" + "mdast-util-from-markdown": "^2.0.1", + "mdast-util-to-markdown": "^2.1.0", + "remark-parse": "^11.0.0", + "remark-stringify": "^11.0.0", + "tailwind-merge": "^2.2.2", + "unified": "^11.0.5", + "unist-util-visit": "^5.0.0" }, "devDependencies": { "@types/node": "^20.11.17", @@ -39,7 +46,8 @@ "react-dom": "^18.2.0", "rimraf": "6.0.1", "tsup": "8.2.2", - "typescript": "5.5.3" + "typescript": "5.5.3", + "vitest": "1.3.0" }, "peerDependencies": { "nextra-theme-docs": "3.0.0-alpha.24", diff --git a/packages/aptos-nextra-components/src/utils/mdast/examples/account.md b/packages/aptos-nextra-components/src/utils/mdast/examples/account.md new file mode 100644 index 000000000..c11985a39 --- /dev/null +++ b/packages/aptos-nextra-components/src/utils/mdast/examples/account.md @@ -0,0 +1,105 @@ + + + + +## Struct `KeyRotation` + + + +
#[event]
+struct KeyRotation has drop, store
+
+
+
+
+account: address
+old_authentication_key: vector<u8>
+new_authentication_key: vector<u8>
+struct Account has store, key
+
+
+
+
+authentication_key: vector<u8>
+sequence_number: u64
+guid_creation_num: u64
+coin_register_events: event::EventHandle<account::CoinRegisterEvent>
+key_rotation_events: event::EventHandle<account::KeyRotationEvent>
+rotation_capability_offer: account::CapabilityOffer<account::RotationCapability>
+signer_capability_offer: account::CapabilityOffer<account::SignerCapability>
+)
+ const codeblockRegex = /]*>([\s\S]*?)<\/code><\/pre>/;
+ const codeblockMatch = codeblockRegex.exec(node.value);
+
+ if (codeblockMatch) {
+ // Extract the content between and
+ const codeContent = codeblockMatch[1]
+ .replace(/<[^>]+>/g, '') // Remove all HTML tags
+ .replace(/</g, '<') // Decode escaped characters
+ .replace(/>/g, '>')
+ .replace(/&/g, '&')
+ .trim();
+
+ // Create a new 'code' node
+ const codeNode: Code = {
+ type: 'code',
+ lang: 'move', // You can adjust or detect the language dynamically
+ meta: null,
+ value: codeContent,
+ position: node.position, // Preserve the original position
+ };
+
+ // Replace the current 'html' node with the new 'code' node
+ if (parent && index !== undefined) {
+ parent.children[index] = codeNode;
+ return;
+ }
+ }
+ });
+}
+
+export const astToMarkdown = (tree: Root) => {
+ return toMarkdown(tree)
+}
\ No newline at end of file
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index a9e3bb698..ae3746ead 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -50,10 +50,10 @@ importers:
version: 1.0.2(@types/react@18.3.3)(react@18.2.0)
'@scalar/api-reference-react':
specifier: ^0.2.5
- version: 0.2.5(nanoid@5.0.7)(postcss@8.4.38)(react@18.2.0)(typescript@5.5.4)(unified@11.0.4)(vue-sonner@1.1.2)(vue@3.4.27)(yjs@13.6.15)
+ version: 0.2.5(nanoid@5.0.7)(postcss@8.4.38)(react@18.2.0)(typescript@5.5.4)(unified@11.0.5)(vue-sonner@1.1.2)(vue@3.4.27)(yjs@13.6.15)
'@scalar/nextjs-api-reference':
specifier: ^0.3.62
- version: 0.3.62(nanoid@5.0.7)(next@14.2.3)(postcss@8.4.38)(react@18.2.0)(typescript@5.5.4)(unified@11.0.4)(vue-sonner@1.1.2)(vue@3.4.27)(yjs@13.6.15)
+ version: 0.3.62(nanoid@5.0.7)(next@14.2.3)(postcss@8.4.38)(react@18.2.0)(typescript@5.5.4)(unified@11.0.5)(vue-sonner@1.1.2)(vue@3.4.27)(yjs@13.6.15)
'@vercel/og':
specifier: ^0.5.0
version: 0.5.20
@@ -159,9 +159,27 @@ importers:
clsx:
specifier: 2.1.0
version: 2.1.0
+ mdast-util-from-markdown:
+ specifier: ^2.0.1
+ version: 2.0.1
+ mdast-util-to-markdown:
+ specifier: ^2.1.0
+ version: 2.1.0
+ remark-parse:
+ specifier: ^11.0.0
+ version: 11.0.0
+ remark-stringify:
+ specifier: ^11.0.0
+ version: 11.0.0
tailwind-merge:
specifier: ^2.2.2
version: 2.3.0
+ unified:
+ specifier: ^11.0.5
+ version: 11.0.5
+ unist-util-visit:
+ specifier: ^5.0.0
+ version: 5.0.0
devDependencies:
'@types/node':
specifier: ^20.11.17
@@ -202,6 +220,9 @@ importers:
typescript:
specifier: 5.5.3
version: 5.5.3
+ vitest:
+ specifier: 1.3.0
+ version: 1.3.0(@types/node@20.13.0)
packages/aptos-nextra-config:
devDependencies:
@@ -262,7 +283,7 @@ importers:
version: 4.9.5
vitest:
specifier: 1.3.0
- version: 1.3.0
+ version: 1.3.0(@types/node@20.13.0)
packages/typescript-config: {}
@@ -3131,13 +3152,13 @@ packages:
- yjs
dev: false
- /@scalar/api-reference-react@0.2.5(nanoid@5.0.7)(postcss@8.4.38)(react@18.2.0)(typescript@5.5.4)(unified@11.0.4)(vue-sonner@1.1.2)(vue@3.4.27)(yjs@13.6.15):
+ /@scalar/api-reference-react@0.2.5(nanoid@5.0.7)(postcss@8.4.38)(react@18.2.0)(typescript@5.5.4)(unified@11.0.5)(vue-sonner@1.1.2)(vue@3.4.27)(yjs@13.6.15):
resolution: {integrity: sha512-+S8jJ+ZTNWtjze9tawRQVrsFfAw0BQQm2nAV4PsDQNJ2OsmLcWoWgg8D2FIEdxatz8zEcBoB8QRdjLN00P7uJg==}
engines: {node: '>=18'}
peerDependencies:
react: ^18.0.0
dependencies:
- '@scalar/api-reference': 1.23.5(nanoid@5.0.7)(postcss@8.4.38)(typescript@5.5.4)(unified@11.0.4)(vue-sonner@1.1.2)(vue@3.4.27)(yjs@13.6.15)
+ '@scalar/api-reference': 1.23.5(nanoid@5.0.7)(postcss@8.4.38)(typescript@5.5.4)(unified@11.0.5)(vue-sonner@1.1.2)(vue@3.4.27)(yjs@13.6.15)
react: 18.2.0
transitivePeerDependencies:
- '@jest/globals'
@@ -3163,7 +3184,7 @@ packages:
- yjs
dev: false
- /@scalar/api-reference@1.23.5(nanoid@5.0.7)(postcss@8.4.38)(typescript@5.5.4)(unified@11.0.4)(vue-sonner@1.1.2)(vue@3.4.27)(yjs@13.6.15):
+ /@scalar/api-reference@1.23.5(nanoid@5.0.7)(postcss@8.4.38)(typescript@5.5.4)(unified@11.0.5)(vue-sonner@1.1.2)(vue@3.4.27)(yjs@13.6.15):
resolution: {integrity: sha512-dpFT2HbnAapjw78w2zoKiO3zk0B6QvWdyG1kYUgQ7RWuU2kCJEVgg2gW8p0IbyvmeJ9RDFxMs7cwJVOCS8g4tQ==}
engines: {node: '>=18'}
peerDependencies:
@@ -3200,7 +3221,7 @@ packages:
remark-rehype: 11.1.0
remark-stringify: 11.0.0
unhead: 1.9.12
- unified: 11.0.4
+ unified: 11.0.5
vue: 3.4.27(typescript@5.5.4)
transitivePeerDependencies:
- '@jest/globals'
@@ -3252,14 +3273,14 @@ packages:
- vitest
dev: false
- /@scalar/nextjs-api-reference@0.3.62(nanoid@5.0.7)(next@14.2.3)(postcss@8.4.38)(react@18.2.0)(typescript@5.5.4)(unified@11.0.4)(vue-sonner@1.1.2)(vue@3.4.27)(yjs@13.6.15):
+ /@scalar/nextjs-api-reference@0.3.62(nanoid@5.0.7)(next@14.2.3)(postcss@8.4.38)(react@18.2.0)(typescript@5.5.4)(unified@11.0.5)(vue-sonner@1.1.2)(vue@3.4.27)(yjs@13.6.15):
resolution: {integrity: sha512-DDzOjhZGMK8zzUJxhIIpkxGvaTfq5A6VAHsfSbuahXS9FX9X2yOgx4zzDnUg0+p8lkg7L5N3vr6erHQN0D4lBA==}
engines: {node: '>=18'}
peerDependencies:
next: ^13 || ^14
react: ^18
dependencies:
- '@scalar/api-reference': 1.23.5(nanoid@5.0.7)(postcss@8.4.38)(typescript@5.5.4)(unified@11.0.4)(vue-sonner@1.1.2)(vue@3.4.27)(yjs@13.6.15)
+ '@scalar/api-reference': 1.23.5(nanoid@5.0.7)(postcss@8.4.38)(typescript@5.5.4)(unified@11.0.5)(vue-sonner@1.1.2)(vue@3.4.27)(yjs@13.6.15)
next: 14.2.3(react-dom@18.2.0)(react@18.2.0)
react: 18.2.0
transitivePeerDependencies:
@@ -3440,6 +3461,15 @@ packages:
/@shikijs/core@1.6.1:
resolution: {integrity: sha512-CqYyepN4SnBopaoXYwng4NO8riB5ask/LTCkhOFq+GNGtr2X+aKeD767eYdqYukeixEUvv4bXdyTYVaogj7KBw==}
+ /@shikijs/twoslash@1.6.1(typescript@5.5.3):
+ resolution: {integrity: sha512-VluGZXQ97sDFyxneOzsPkEHK06A6C1SRDh+kSM9AZAkzHorZaGxF4awgA3rh2K0oZnR94NZzfhq8GtERm38EEQ==}
+ dependencies:
+ '@shikijs/core': 1.6.1
+ twoslash: 0.2.6(typescript@5.5.3)
+ transitivePeerDependencies:
+ - supports-color
+ - typescript
+
/@shikijs/twoslash@1.6.1(typescript@5.5.4):
resolution: {integrity: sha512-VluGZXQ97sDFyxneOzsPkEHK06A6C1SRDh+kSM9AZAkzHorZaGxF4awgA3rh2K0oZnR94NZzfhq8GtERm38EEQ==}
dependencies:
@@ -3448,6 +3478,7 @@ packages:
transitivePeerDependencies:
- supports-color
- typescript
+ dev: false
/@shuding/opentype.js@1.4.0-beta.0:
resolution: {integrity: sha512-3NgmNyH3l/Hv6EvsWJbsvpcpUba6R8IREQ83nH83cyakCw7uM1arZKNfHwv1Wz6jgqrF/j4x5ELvR6PnK9nTcA==}
@@ -9099,12 +9130,61 @@ packages:
intersection-observer: 0.12.2
next: 14.2.3(react-dom@18.2.0)(react@18.2.0)
next-themes: 0.3.0(react-dom@18.2.0)(react@18.2.0)
- nextra: 3.0.0-alpha.24(@types/react@18.3.3)(next@14.2.3)(react-dom@18.2.0)(react@18.2.0)(typescript@5.5.4)
+ nextra: 3.0.0-alpha.24(@types/react@18.3.3)(next@14.2.3)(react-dom@18.2.0)(react@18.2.0)(typescript@5.5.3)
react: 18.2.0
react-dom: 18.2.0(react@18.2.0)
scroll-into-view-if-needed: 3.1.0
zod: 3.23.8
+ /nextra@3.0.0-alpha.24(@types/react@18.3.3)(next@14.2.3)(react-dom@18.2.0)(react@18.2.0)(typescript@5.5.3):
+ resolution: {integrity: sha512-KScl/DQG68JBGy6gfOFNdVcrlc24YvcegGnYwUXvpCoHx2YcBUSp6FE7LeaX/C/mI4PPIMmTJuEWIjGH9DXeCQ==}
+ engines: {node: '>=18'}
+ peerDependencies:
+ next: '>=13'
+ react: '>=16.13.1'
+ react-dom: '>=16.13.1'
+ dependencies:
+ '@headlessui/react': 1.7.19(react-dom@18.2.0)(react@18.2.0)
+ '@mdx-js/mdx': 3.0.1
+ '@mdx-js/react': 3.0.1(@types/react@18.3.3)(react@18.2.0)
+ '@napi-rs/simple-git': 0.1.16
+ '@shikijs/twoslash': 1.6.1(typescript@5.5.3)
+ '@theguild/remark-mermaid': 0.0.5(react@18.2.0)
+ '@theguild/remark-npm2yarn': 0.3.0
+ better-react-mathjax: 2.0.3(react@18.2.0)
+ clsx: 2.1.0
+ estree-util-to-js: 2.0.0
+ estree-util-value-to-estree: 3.1.1
+ github-slugger: 2.0.0
+ graceful-fs: 4.2.11
+ gray-matter: 4.0.3
+ hast-util-to-estree: 3.1.0
+ katex: 0.16.10
+ next: 14.2.3(react-dom@18.2.0)(react@18.2.0)
+ p-limit: 4.0.0
+ react: 18.2.0
+ react-dom: 18.2.0(react@18.2.0)
+ rehype-katex: 7.0.0
+ rehype-pretty-code: 0.13.0(shiki@1.6.1)
+ rehype-raw: 7.0.0
+ remark-frontmatter: 5.0.0
+ remark-gfm: 4.0.0
+ remark-math: 6.0.0
+ remark-reading-time: 2.0.1
+ remark-smartypants: 2.1.0
+ shiki: 1.6.1
+ slash: 5.1.0
+ title: 3.5.3
+ unist-util-remove: 4.0.0
+ unist-util-visit: 5.0.0
+ yaml: 2.4.2
+ zod: 3.23.8
+ zod-validation-error: 1.5.0(zod@3.23.8)
+ transitivePeerDependencies:
+ - '@types/react'
+ - supports-color
+ - typescript
+
/nextra@3.0.0-alpha.24(@types/react@18.3.3)(next@14.2.3)(react-dom@18.2.0)(react@18.2.0)(typescript@5.5.4):
resolution: {integrity: sha512-KScl/DQG68JBGy6gfOFNdVcrlc24YvcegGnYwUXvpCoHx2YcBUSp6FE7LeaX/C/mI4PPIMmTJuEWIjGH9DXeCQ==}
engines: {node: '>=18'}
@@ -9153,6 +9233,7 @@ packages:
- '@types/react'
- supports-color
- typescript
+ dev: false
/nlcst-to-string@3.1.1:
resolution: {integrity: sha512-63mVyqaqt0cmn2VcI2aH6kxe1rLAmSROqHMA0i4qqg1tidkfExgpb0FGMikMCn86mw5dFtBtEANfmSSK7TjNHw==}
@@ -10076,7 +10157,7 @@ packages:
'@types/mdast': 4.0.4
mdast-util-from-markdown: 2.0.1
micromark-util-types: 2.0.0
- unified: 11.0.4
+ unified: 11.0.5
transitivePeerDependencies:
- supports-color
@@ -10110,7 +10191,7 @@ packages:
dependencies:
'@types/mdast': 4.0.4
mdast-util-to-markdown: 2.1.0
- unified: 11.0.4
+ unified: 11.0.5
/require-from-string@2.0.2:
resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==}
@@ -11157,6 +11238,17 @@ packages:
/twoslash-protocol@0.2.6:
resolution: {integrity: sha512-8NbJlYeRdBcCTQ7ui7pdRPC1NL16aOnoYNz06oBW+W0qWNuiQXHgE8UeNvbA038aDd6ZPuuD5WedsBIESocB4g==}
+ /twoslash@0.2.6(typescript@5.5.3):
+ resolution: {integrity: sha512-DcAKIyXMB6xNs+SOw/oF8GvUr/cfJSqznngVXYbAUIVfTW3M8vWSEoCaz/RgSD+M6vwtK8DJ4/FmYBF5MN8BGw==}
+ peerDependencies:
+ typescript: '*'
+ dependencies:
+ '@typescript/vfs': 1.5.0
+ twoslash-protocol: 0.2.6
+ typescript: 5.5.3
+ transitivePeerDependencies:
+ - supports-color
+
/twoslash@0.2.6(typescript@5.5.4):
resolution: {integrity: sha512-DcAKIyXMB6xNs+SOw/oF8GvUr/cfJSqznngVXYbAUIVfTW3M8vWSEoCaz/RgSD+M6vwtK8DJ4/FmYBF5MN8BGw==}
peerDependencies:
@@ -11167,6 +11259,7 @@ packages:
typescript: 5.5.4
transitivePeerDependencies:
- supports-color
+ dev: false
/type-check@0.4.0:
resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==}
@@ -11263,7 +11356,6 @@ packages:
resolution: {integrity: sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==}
engines: {node: '>=14.17'}
hasBin: true
- dev: true
/typescript@5.5.4:
resolution: {integrity: sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==}
@@ -11331,6 +11423,17 @@ packages:
trough: 2.2.0
vfile: 6.0.1
+ /unified@11.0.5:
+ resolution: {integrity: sha512-xKvGhPWw3k84Qjh8bI3ZeJjqnyadK+GEFtazSfZv/rKeTkTjOJho6mFqh2SM96iIcZokxiOpg78GazTSg8+KHA==}
+ dependencies:
+ '@types/unist': 3.0.2
+ bail: 2.0.2
+ devlop: 1.1.0
+ extend: 3.0.2
+ is-plain-obj: 4.1.0
+ trough: 2.2.0
+ vfile: 6.0.1
+
/unist-util-find-after@5.0.0:
resolution: {integrity: sha512-amQa0Ep2m6hE2g72AugUItjbuM8X8cGQnFoHk0pGfrFeT9GZhzN5SW8nRsiGKK7Aif4CrACPENkA6P/Lw6fHGQ==}
dependencies:
@@ -11557,7 +11660,7 @@ packages:
unist-util-stringify-position: 4.0.0
vfile-message: 4.0.2
- /vite-node@1.3.0:
+ /vite-node@1.3.0(@types/node@20.13.0):
resolution: {integrity: sha512-D/oiDVBw75XMnjAXne/4feCkCEwcbr2SU1bjAhCcfI5Bq3VoOHji8/wCPAfUkDIeohJ5nSZ39fNxM3dNZ6OBOA==}
engines: {node: ^18.0.0 || >=20.0.0}
hasBin: true
@@ -11613,7 +11716,7 @@ packages:
optionalDependencies:
fsevents: 2.3.3
- /vitest@1.3.0:
+ /vitest@1.3.0(@types/node@20.13.0):
resolution: {integrity: sha512-V9qb276J1jjSx9xb75T2VoYXdO1UKi+qfflY7V7w93jzX7oA/+RtYE6TcifxksxsZvygSSMwu2Uw6di7yqDMwg==}
engines: {node: ^18.0.0 || >=20.0.0}
hasBin: true
@@ -11638,6 +11741,7 @@ packages:
jsdom:
optional: true
dependencies:
+ '@types/node': 20.13.0
'@vitest/expect': 1.3.0
'@vitest/runner': 1.3.0
'@vitest/snapshot': 1.3.0
@@ -11656,7 +11760,7 @@ packages:
tinybench: 2.8.0
tinypool: 0.8.4
vite: 5.2.12(@types/node@20.13.0)
- vite-node: 1.3.0
+ vite-node: 1.3.0(@types/node@20.13.0)
why-is-node-running: 2.2.2
transitivePeerDependencies:
- less