@clidey/dory 1.0.8 → 1.10.0

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 (210) hide show
  1. package/README.md +59 -164
  2. package/bin/chat-server.ts +270 -0
  3. package/bin/dist/analytics-server.d.ts +11 -0
  4. package/bin/dist/analytics-server.d.ts.map +1 -0
  5. package/bin/dist/analytics-server.js +121 -0
  6. package/bin/dist/analytics-server.js.map +1 -0
  7. package/bin/dist/automation.d.ts +35 -0
  8. package/bin/dist/automation.d.ts.map +1 -0
  9. package/bin/dist/automation.js +259 -0
  10. package/bin/dist/automation.js.map +1 -0
  11. package/bin/dist/chat-server.d.ts +8 -0
  12. package/bin/dist/chat-server.d.ts.map +1 -0
  13. package/bin/dist/chat-server.js +322 -0
  14. package/bin/dist/chat-server.js.map +1 -0
  15. package/bin/dist/check.d.ts +16 -0
  16. package/bin/dist/check.d.ts.map +1 -0
  17. package/bin/dist/check.js +247 -0
  18. package/bin/dist/check.js.map +1 -0
  19. package/bin/dist/dependency-overlay.d.ts +7 -0
  20. package/bin/dist/dependency-overlay.d.ts.map +1 -0
  21. package/bin/dist/dependency-overlay.js +137 -0
  22. package/bin/dist/dependency-overlay.js.map +1 -0
  23. package/bin/dist/dory.js +254 -402
  24. package/bin/dist/dory.js.map +1 -1
  25. package/bin/dist/i18n-init.d.ts +6 -0
  26. package/bin/dist/i18n-init.d.ts.map +1 -0
  27. package/bin/dist/i18n-init.js +56 -0
  28. package/bin/dist/i18n-init.js.map +1 -0
  29. package/bin/dist/mcp-http.d.ts +8 -0
  30. package/bin/dist/mcp-http.d.ts.map +1 -0
  31. package/bin/dist/mcp-http.js +72 -0
  32. package/bin/dist/mcp-http.js.map +1 -0
  33. package/bin/dist/mcp.d.ts +2 -0
  34. package/bin/dist/mcp.d.ts.map +1 -0
  35. package/bin/dist/mcp.js +81 -0
  36. package/bin/dist/mcp.js.map +1 -0
  37. package/bin/dist/preview-entry.d.ts +2 -0
  38. package/bin/dist/preview-entry.d.ts.map +1 -0
  39. package/bin/dist/preview-entry.js +6 -0
  40. package/bin/dist/preview-entry.js.map +1 -0
  41. package/bin/dist/preview-server.d.ts +5 -0
  42. package/bin/dist/preview-server.d.ts.map +1 -0
  43. package/bin/dist/preview-server.js +146 -0
  44. package/bin/dist/preview-server.js.map +1 -0
  45. package/bin/dist/preview-static.d.ts +7 -0
  46. package/bin/dist/preview-static.d.ts.map +1 -0
  47. package/bin/dist/preview-static.js +70 -0
  48. package/bin/dist/preview-static.js.map +1 -0
  49. package/bin/dist/project-config.d.ts +22 -0
  50. package/bin/dist/project-config.d.ts.map +1 -0
  51. package/bin/dist/project-config.js +44 -0
  52. package/bin/dist/project-config.js.map +1 -0
  53. package/dist/index.html +57 -0
  54. package/dist/runtime/dory-runtime.css +2 -0
  55. package/dist/runtime/dory-runtime.html +14 -0
  56. package/dist/runtime/dory-runtime.js +5490 -0
  57. package/docs/api-playground-demo.mdx +119 -0
  58. package/docs/api-reference/asyncapi.json +324 -0
  59. package/docs/api-reference/openapi.json +366 -0
  60. package/docs/api-reference/operations/create.mdx +5 -0
  61. package/docs/api-reference/operations/delete.mdx +5 -0
  62. package/docs/api-reference/operations/get.mdx +5 -0
  63. package/docs/api-reference/operations/update.mdx +5 -0
  64. package/docs/api-reference/websocket-operations/receive-chat-message.mdx +5 -0
  65. package/docs/api-reference/websocket-operations/receive-notifications.mdx +5 -0
  66. package/docs/api-reference/websocket-operations/receive-presence-update.mdx +5 -0
  67. package/docs/api-reference/websocket-operations/send-chat-message.mdx +5 -0
  68. package/docs/api-reference/websocket-operations/send-presence-update.mdx +5 -0
  69. package/docs/assets/dory.jpeg +0 -0
  70. package/docs/components/accordion.mdx +145 -0
  71. package/docs/components/callouts.mdx +134 -0
  72. package/docs/components/cards.mdx +153 -0
  73. package/docs/components/code-blocks.mdx +281 -0
  74. package/docs/components/expandable.mdx +189 -0
  75. package/docs/components/icons.mdx +71 -0
  76. package/docs/components/images.mdx +82 -0
  77. package/docs/components/latex.mdx +148 -0
  78. package/docs/components/layout.mdx +178 -0
  79. package/docs/components/lists.mdx +134 -0
  80. package/docs/components/mermaid.mdx +149 -0
  81. package/docs/components/overview.mdx +81 -0
  82. package/docs/components/source.mdx +130 -0
  83. package/docs/components/steps.mdx +122 -0
  84. package/docs/components/tables.mdx +114 -0
  85. package/docs/components/tags.mdx +179 -0
  86. package/docs/components/typography.mdx +185 -0
  87. package/docs/configuration/analytics.mdx +45 -0
  88. package/docs/configuration/chat.mdx +59 -0
  89. package/docs/configuration/dory-json.mdx +278 -0
  90. package/docs/configuration/embed.mdx +73 -0
  91. package/docs/configuration/fonts.mdx +86 -0
  92. package/docs/configuration/internationalization.mdx +61 -0
  93. package/docs/configuration/navigation.mdx +217 -0
  94. package/docs/configuration/theming.mdx +166 -0
  95. package/docs/contributing.mdx +47 -0
  96. package/docs/dory.json +136 -0
  97. package/docs/embed-example.html +176 -0
  98. package/docs/favicon.svg +18 -0
  99. package/docs/features.mdx +440 -0
  100. package/docs/getting-started/automation.mdx +76 -0
  101. package/docs/getting-started/configuration.mdx +95 -0
  102. package/docs/getting-started/custom-components.mdx +60 -0
  103. package/docs/getting-started/installation.mdx +88 -0
  104. package/docs/getting-started/quick-start.mdx +53 -0
  105. package/docs/introduction.mdx +50 -0
  106. package/docs/logo/logo.svg +18 -0
  107. package/docs/playgrounds/api-playground.mdx +122 -0
  108. package/docs/playgrounds/websocket-playground.mdx +98 -0
  109. package/docs/social-card.png +0 -0
  110. package/docs/social-card.svg +17 -0
  111. package/docs/websocket-playground-demo.mdx +135 -0
  112. package/package.json +23 -17
  113. package/scripts/verify-component-examples.mjs +126 -0
  114. package/scripts/verify-runtime-parity.mjs +147 -0
  115. package/src/app.css +22 -1
  116. package/src/assets/fonts/HankenGrotesk.ttf +0 -0
  117. package/src/assets/fonts/OFL.txt +94 -0
  118. package/src/components/chat-assistant.tsx +229 -0
  119. package/src/components/dropdown.tsx +3 -3
  120. package/src/components/error-boundary.tsx +2 -2
  121. package/src/components/hooks.tsx +20 -1
  122. package/src/components/navigation.tsx +82 -51
  123. package/src/components/notification.tsx +2 -3
  124. package/src/components/routes.tsx +17 -19
  125. package/src/components/search-index.test.ts +15 -0
  126. package/src/components/search-index.ts +49 -48
  127. package/src/components/search.tsx +208 -104
  128. package/src/components/store.ts +27 -9
  129. package/src/config/mdx-common.ts +11 -0
  130. package/src/config/mdx.ts +10 -11
  131. package/src/embed/loader.ts +0 -3
  132. package/src/embed/types.ts +0 -2
  133. package/src/embed/widget-iframe.ts +19 -21
  134. package/src/embedded-runtime/config.ts +138 -0
  135. package/src/embedded-runtime/index.tsx +680 -0
  136. package/src/embedded-runtime/runtime.html +14 -0
  137. package/src/entry-server.tsx +46 -124
  138. package/src/main.tsx +17 -5
  139. package/src/mdx/accordion.tsx +3 -3
  140. package/src/mdx/api-playground.tsx +18 -16
  141. package/src/mdx/async-api.tsx +2 -2
  142. package/src/mdx/card.tsx +3 -2
  143. package/src/mdx/code.tsx +11 -9
  144. package/src/mdx/fence.tsx +6 -5
  145. package/src/mdx/icon-grid.tsx +4 -1
  146. package/src/mdx/icon-names.test.ts +15 -0
  147. package/src/mdx/icon-names.ts +60 -0
  148. package/src/mdx/icon-source-variants.ts +102 -0
  149. package/src/mdx/icon.tsx +12 -73
  150. package/src/mdx/latex.test.ts +38 -0
  151. package/src/mdx/latex.tsx +42 -64
  152. package/src/mdx/mdx.tsx +1 -1
  153. package/src/mdx/mermaid.tsx +12 -6
  154. package/src/mdx/open-api.tsx +130 -74
  155. package/src/mdx/preprocess.test.ts +16 -0
  156. package/src/mdx/preprocess.ts +61 -0
  157. package/src/mdx/processor.test.ts +135 -37
  158. package/src/mdx/processor.ts +54 -92
  159. package/src/mdx/source.tsx +5 -4
  160. package/src/mdx/specimen.tsx +57 -43
  161. package/src/mdx/tabs.tsx +32 -21
  162. package/src/mdx/text.tsx +11 -11
  163. package/src/mdx/try-it-panel.tsx +284 -0
  164. package/src/mdx/type-scale.tsx +7 -7
  165. package/src/mdx/websocket-playground.tsx +21 -14
  166. package/src/plugins/analytics-injector.ts +8 -0
  167. package/src/plugins/chat-dev-server.ts +32 -0
  168. package/src/plugins/docs-assets.test.ts +25 -0
  169. package/src/plugins/docs-assets.ts +6 -2
  170. package/src/plugins/frontmatter-dev-server.ts +2 -2
  171. package/src/plugins/frontmatter-generator.ts +1 -1
  172. package/src/plugins/html-files-middleware.test.ts +21 -1
  173. package/src/plugins/html-files-middleware.ts +26 -6
  174. package/src/plugins/html-metadata-injector.ts +24 -4
  175. package/src/plugins/llm-txt-dev-server.ts +2 -2
  176. package/src/plugins/llm-txt-generator.ts +21 -4
  177. package/src/plugins/prerender.ts +47 -20
  178. package/src/plugins/robots-generator.ts +1 -1
  179. package/src/plugins/sanitize.ts +6 -5
  180. package/src/plugins/shared.ts +6 -18
  181. package/src/plugins/sitemap-generator.ts +1 -1
  182. package/src/plugins/social-preview.test.ts +71 -0
  183. package/src/plugins/social-preview.ts +87 -0
  184. package/src/plugins/unified-mdx-plugin.ts +1 -1
  185. package/src/theme.scss +630 -207
  186. package/src/types/config.ts +53 -1
  187. package/src/ui/breadcrumb.tsx +17 -0
  188. package/src/ui/docs-header-view.tsx +32 -0
  189. package/src/ui/docs-navigation-view.tsx +69 -0
  190. package/src/ui/docs-page-frame.tsx +50 -0
  191. package/src/ui/dory-mark.tsx +9 -0
  192. package/src/ui/header.tsx +33 -90
  193. package/src/ui/layout.tsx +99 -153
  194. package/src/ui/mobile-navigation.tsx +10 -8
  195. package/src/ui/page-actions.tsx +67 -0
  196. package/src/ui/page-feedback.tsx +50 -0
  197. package/src/ui/page-footer.tsx +23 -0
  198. package/src/ui/prev-next-link.tsx +15 -69
  199. package/src/ui/prev-next-view.tsx +27 -0
  200. package/src/ui/table-of-content-view.tsx +167 -0
  201. package/src/ui/table-of-content.tsx +25 -183
  202. package/src/utils/analytics.test.ts +36 -0
  203. package/src/utils/analytics.ts +35 -0
  204. package/src/utils/colors.ts +7 -0
  205. package/src/utils/content-scope.test.ts +26 -0
  206. package/src/utils/content-scope.ts +39 -0
  207. package/src/utils/search-content.ts +12 -0
  208. package/src/utils/theme.ts +1 -7
  209. package/vite.config.ssr.ts +4 -4
  210. package/vite.config.ts +22 -16
@@ -0,0 +1,135 @@
1
+ ---
2
+ title: 'WebSocket Playground Demo'
3
+ description: 'Interactive WebSocket playground for testing real-time connections'
4
+ ---
5
+
6
+ # WebSocket Playground Demo
7
+
8
+ This page demonstrates the WebSocket playground component with various configuration options and real-time connection testing capabilities.
9
+
10
+ ## Basic WebSocket Connection
11
+
12
+ <WebSocketPlayground
13
+ url="/ws/chat"
14
+ title="Basic Chat WebSocket"
15
+ description="Connect to a WebSocket server and send/receive messages in real-time"
16
+ servers={[
17
+ {
18
+ url: "wss://echo.websocket.org",
19
+ description: "WebSocket Echo Server"
20
+ },
21
+ {
22
+ url: "wss://ws.postman-echo.com/raw",
23
+ description: "Postman Echo WebSocket"
24
+ }
25
+ ]}
26
+ />
27
+
28
+ ## WebSocket with Subprotocols
29
+
30
+ <WebSocketPlayground
31
+ url="/ws/protocol"
32
+ title="WebSocket with Subprotocols"
33
+ description="WebSocket connection with custom subprotocols for specialized communication"
34
+ subprotocols={["chat", "v1.0"]}
35
+ servers={[
36
+ {
37
+ url: "wss://echo.websocket.org",
38
+ description: "Echo Server with Subprotocols"
39
+ }
40
+ ]}
41
+ />
42
+
43
+ ## WebSocket with Authentication
44
+
45
+ <WebSocketPlayground
46
+ url="/ws/secure"
47
+ title="Authenticated WebSocket"
48
+ description="WebSocket connection with authentication headers"
49
+ authType="bearer"
50
+ headers={{
51
+ "User-Agent": "Dory WebSocket Client",
52
+ "X-Client-Version": "1.0.0"
53
+ }}
54
+ servers={[
55
+ {
56
+ url: "wss://echo.websocket.org",
57
+ description: "Secure Echo Server"
58
+ }
59
+ ]}
60
+ />
61
+
62
+ ## Real-time Chat Example
63
+
64
+ <WebSocketPlayground
65
+ url="/chat"
66
+ title="Real-time Chat"
67
+ description="Connect to a chat server and participate in real-time conversations"
68
+ subprotocols={["chat.v1", "json"]}
69
+ headers={{
70
+ "X-Client-Type": "web",
71
+ "X-Protocol-Version": "1.0"
72
+ }}
73
+ servers={[
74
+ {
75
+ url: "wss://echo.websocket.org",
76
+ description: "Chat Echo Server"
77
+ }
78
+ ]}
79
+ />
80
+
81
+ ## Testing Instructions
82
+
83
+ 1. **Connect**: Click the "Connect" button to establish a WebSocket connection
84
+ 2. **Send Messages**: Type messages in the input field and click "Send" or press Enter
85
+ 3. **View Messages**: All sent and received messages appear in the message history with timestamps
86
+ 4. **Configuration**: Use the tabs to configure headers, subprotocols, and authentication
87
+ 5. **Server Selection**: Choose different servers from the dropdown to test various endpoints
88
+
89
+ ## Features
90
+
91
+ - **Real-time Connection**: Live WebSocket connection with status indicators
92
+ - **Message History**: View all sent/received messages with timestamps
93
+ - **Custom Headers**: Add authentication and custom headers
94
+ - **Subprotocols**: Configure WebSocket subprotocols
95
+ - **Multiple Servers**: Easy switching between different WebSocket endpoints
96
+ - **Error Handling**: Clear error messages for connection issues
97
+ - **Binary Support**: Handles both text and binary messages
98
+
99
+ ## Message Types
100
+
101
+ The playground supports different message types:
102
+ - **Sent**: Messages you send (blue background)
103
+ - **Received**: Messages from the server (green background)
104
+ - **Error**: Connection or sending errors (red background)
105
+ - **System**: Connection status updates (gray background)
106
+
107
+ ## Example Messages
108
+
109
+ Try sending these JSON messages to test structured data:
110
+
111
+ ```json
112
+ {
113
+ "type": "chat",
114
+ "message": "Hello, WebSocket!",
115
+ "userId": "user123",
116
+ "timestamp": "2024-01-15T10:30:00Z"
117
+ }
118
+ ```
119
+
120
+ ```json
121
+ {
122
+ "type": "presence",
123
+ "status": "online",
124
+ "userId": "user123"
125
+ }
126
+ ```
127
+
128
+ ```json
129
+ {
130
+ "type": "notification",
131
+ "title": "Test Notification",
132
+ "message": "This is a test notification",
133
+ "level": "info"
134
+ }
135
+ ```
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@clidey/dory",
3
3
  "private": false,
4
- "version": "1.0.8",
4
+ "version": "1.10.0",
5
5
  "type": "module",
6
6
  "description": "A CLI tool for building and previewing documentation sites",
7
7
  "keywords": [
@@ -16,6 +16,11 @@
16
16
  },
17
17
  "files": [
18
18
  "bin/dist",
19
+ "dist/runtime",
20
+ "bin/chat-server.ts",
21
+ "docs",
22
+ "!docs/dist",
23
+ "!docs/dist-ssr",
19
24
  "src",
20
25
  "scripts",
21
26
  "index.html",
@@ -36,7 +41,9 @@
36
41
  },
37
42
  "scripts": {
38
43
  "dev": "vite",
39
- "build": "npm run build:cli && tsc -b",
44
+ "build": "pnpm run build:cli && tsc -b && pnpm run build:docs && pnpm run build:runtime",
45
+ "build:runtime": "vite build -c vite.config.runtime.ts && cp src/embedded-runtime/runtime.html dist/runtime/dory-runtime.html",
46
+ "build:server": "vite build -c vite.config.server.ts",
40
47
  "build:cli": "tsc -p tsconfig.bin.json",
41
48
  "build:docs": "vite build && vite build --config vite.config.ssr.ts && node scripts/render-routes.mjs",
42
49
  "build:embed": "npm run build:embed:loader && npm run build:embed:widget",
@@ -44,46 +51,45 @@
44
51
  "build:embed:widget": "vite build -c vite.config.embed-widget.ts",
45
52
  "preview": "vite preview",
46
53
  "test": "node scripts/check-trigger-children.mjs src && vitest run",
54
+ "test:runtime-parity": "pnpm run build && node scripts/verify-runtime-parity.mjs",
47
55
  "lint:triggers": "node scripts/check-trigger-children.mjs src",
48
56
  "publish": "npm run build && npm publish --access public --no-git-checks",
49
57
  "prepublishOnly": "echo 'Skipping prepublishOnly - build handled by publish script'"
50
58
  },
51
59
  "dependencies": {
52
60
  "@algolia/autocomplete-core": "1.19.12",
53
- "@clidey/ux": "1.5.1",
54
- "@fortawesome/fontawesome-svg-core": "7.3.1",
55
- "@fortawesome/free-brands-svg-icons": "7.3.1",
56
- "@fortawesome/free-regular-svg-icons": "7.3.1",
57
- "@fortawesome/free-solid-svg-icons": "7.3.1",
58
- "@fortawesome/react-fontawesome": "3.5.0",
61
+ "@clidey/ux": "1.6.4",
59
62
  "@headlessui/react": "2.2.10",
60
- "@heroicons/react": "2.2.0",
61
63
  "@mdx-js/mdx": "3.1.1",
62
64
  "@mdx-js/preact": "3.1.1",
63
65
  "@mdx-js/rollup": "3.1.1",
66
+ "@modelcontextprotocol/node": "2.1.2",
67
+ "@modelcontextprotocol/server": "2.4.0",
64
68
  "@preact/preset-vite": "2.10.6",
69
+ "@resvg/resvg-js": "2.6.2",
65
70
  "@tailwindcss/vite": "4.3.3",
66
71
  "classnames": "2.5.1",
67
72
  "flexsearch": "0.8.212",
68
73
  "gray-matter": "4.0.3",
69
74
  "katex": "0.19.0",
70
- "lucide-react": "1.57.0",
71
- "mermaid": "11.16.1",
72
- "motion": "12.42.2",
73
- "preact": "10.29.8",
75
+ "mermaid": "12.2.0",
76
+ "motion": "14.5.0",
77
+ "playwright-core": "1.64.1",
78
+ "preact": "11.0.1",
74
79
  "preact-render-to-string": "6.8.1",
75
80
  "prism-react-renderer": "2.4.1",
76
- "react-highlight-words": "0.21.0",
81
+ "react-highlight-words": "1.0.0",
77
82
  "rehype-slug": "6.0.0",
78
83
  "remark-gfm": "4.0.1",
79
- "sass-embedded": "1.105.1",
84
+ "sass-embedded": "1.106.0",
80
85
  "sirv": "3.0.2",
81
86
  "tailwindcss": "4.3.3",
82
87
  "tsx": "4.23.15",
83
88
  "typescript": "7.0.2",
84
89
  "unist-util-visit": "5.1.0",
85
- "vite": "8.3.4",
86
- "wouter-preact": "3.13.0"
90
+ "vite": "8.3.5",
91
+ "wouter-preact": "3.13.0",
92
+ "zod": "4.6.7"
87
93
  },
88
94
  "packageManager": "pnpm@12.13.0+sha512.1e55719bf26e809dce5c5084fdebaa64efb3da9038ae5d68a9f8a68311f1a45841c8c3b76a37298c3b66f6bcc80409a9b7f33c78a7168a3e90fb65a5d8235ae4",
89
95
  "devDependencies": {
@@ -0,0 +1,126 @@
1
+ import assert from 'node:assert/strict';
2
+ import {mkdir, readFile, writeFile} from 'node:fs/promises';
3
+ import {dirname, join, resolve} from 'node:path';
4
+ import {fileURLToPath} from 'node:url';
5
+ import {chromium} from 'playwright-core';
6
+ import {preview} from 'vite';
7
+
8
+ const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
9
+ const config = JSON.parse(await readFile(join(root, 'docs/dory.json'), 'utf8'));
10
+ const routes = config.navigation.tabs.flatMap(tab => tab.groups.flatMap(group => group.pages))
11
+ .map(page => typeof page === 'string' ? page : page.page).filter(page => page.startsWith('components/'));
12
+ const output = join(root, '.dory/component-review');
13
+ await mkdir(output, {recursive: true});
14
+ const report = {pages: 0, previews: 0, errors: [], screenshots: []};
15
+ let server;
16
+ let browser;
17
+ try {
18
+ let base = process.argv[2];
19
+ if (!base) {
20
+ server = await preview({root, preview: {host: '127.0.0.1', port: 3189, strictPort: true}});
21
+ base = server.resolvedUrls.local[0];
22
+ }
23
+ if (!base.endsWith('/')) base += '/';
24
+ browser = await chromium.launch({channel: 'chrome', headless: true, ...(process.env.DORY_CHROME_PATH ? {executablePath: process.env.DORY_CHROME_PATH} : {})});
25
+ // A missing lazy math asset must leave a readable equation and an error, not
26
+ // a blank spinner. This context has its own cache so the request is real.
27
+ const unavailable = await browser.newContext({viewport: {width: 390, height: 844}});
28
+ const failedMath = await unavailable.newPage();
29
+ await failedMath.route(/\/assets\/katex-[^/]+\.js$/, route => route.abort());
30
+ await failedMath.goto(new URL('components/latex/', base).href, {waitUntil: 'domcontentloaded'});
31
+ await failedMath.getByRole('alert').filter({hasText: 'The equation could not be rendered.'}).first().waitFor();
32
+ assert.ok((await failedMath.locator('[data-latex-fallback]').first().innerText()).trim(), 'Failed math retains readable content');
33
+ assert.equal(await failedMath.locator('.dory-latex .animate-spin').count(), 0, 'Failed math does not spin forever');
34
+ await unavailable.close();
35
+ report.mathFailureFallback = true;
36
+ for (const scenario of [
37
+ {name: 'desktop-dark', viewport: {width: 1440, height: 1000}, colorScheme: 'dark'},
38
+ {name: 'mobile-light', viewport: {width: 390, height: 844}, colorScheme: 'light'},
39
+ ]) {
40
+ const context = await browser.newContext({viewport: scenario.viewport, colorScheme: scenario.colorScheme});
41
+ const page = await context.newPage();
42
+ page.on('pageerror', error => report.errors.push(`${scenario.name}: ${error.message}`));
43
+ for (const route of routes) {
44
+ const label = `${scenario.name} ${route}`;
45
+ try {
46
+ const response = await page.goto(new URL(route + '/', base).href, {waitUntil: 'domcontentloaded'});
47
+ assert.equal(response.status(), 200, `${label}: HTTP status`);
48
+ await page.locator('article').waitFor();
49
+ await page.evaluate(() => document.fonts.ready);
50
+ assert.equal(await page.getByText('This page failed to render', {exact: true}).count(), 0, `${label}: render boundary`);
51
+ const previews = page.locator('[data-dory-preview]:visible');
52
+ assert.equal(await previews.count(), await page.locator('.dory-specimen:visible').count(), `${label}: every example has a visible preview`);
53
+ for (let index = 0; index < await previews.count(); index++) {
54
+ const panel = previews.nth(index);
55
+ const padding = await panel.evaluate(element => {
56
+ const style = getComputedStyle(element);
57
+ return [style.paddingTop, style.paddingRight, style.paddingBottom, style.paddingLeft].map(parseFloat);
58
+ });
59
+ const expected = await panel.getAttribute('data-padding');
60
+ assert.ok(padding.every(value => expected === 'none' ? value === 0 : value >= 16), `${label} preview ${index + 1}: missing inset (${padding})`);
61
+ const clipped = await panel.evaluate(element => {
62
+ const box = element.getBoundingClientRect();
63
+ const style = getComputedStyle(element);
64
+ const left = box.left + parseFloat(style.paddingLeft);
65
+ const right = box.right - parseFloat(style.paddingRight);
66
+ return [...element.querySelectorAll('.dory-latex, .dory-expandable, .dory-accordion, .dory-table, .dory-card, .dory-callout')]
67
+ .filter(child => child.getBoundingClientRect().width > 0)
68
+ .filter(child => { const bounds = child.getBoundingClientRect(); return bounds.left < left - 1 || bounds.right > right + 1; })
69
+ .map(child => child.className);
70
+ });
71
+ assert.deepEqual(clipped, [], `${label} preview ${index + 1}: content clipped by frame`);
72
+ report.previews++;
73
+ }
74
+ if (route === 'components/latex') {
75
+ await page.waitForFunction(() => {
76
+ const formulas = [...document.querySelectorAll('.dory-latex, .dory-latex-inline')];
77
+ return formulas.length > 0 && formulas.every(element => element.querySelector('.katex'));
78
+ }, undefined, {timeout: 15000});
79
+ assert.equal(await page.locator('[data-latex-fallback]').count(), 0, `${label}: math still loading`);
80
+ assert.equal(await page.locator('.katex-error').count(), 0, `${label}: invalid formula`);
81
+ }
82
+ if (route === 'components/typography') {
83
+ assert.equal(await page.locator('.dory-type-scale > div').count(), 4, `${label}: heading samples`);
84
+ assert.equal(await page.locator('.dory-type-scale').evaluate(element => element.scrollWidth > element.clientWidth + 1), false, `${label}: heading sample overflows`);
85
+ }
86
+ if (route === 'components/expandable') {
87
+ const specimen = page.locator('.dory-specimen').first();
88
+ const inner = specimen.locator('.dory-expandable').first();
89
+ const outerBounds = await specimen.boundingBox();
90
+ const innerBounds = await inner.boundingBox();
91
+ assert.ok(innerBounds.x - outerBounds.x >= 16, `${label}: nested border touches frame`);
92
+ await inner.getByRole('button', {name: 'Response Body', exact: true}).click();
93
+ await inner.locator('[data-state="open"]').first().waitFor();
94
+ }
95
+ const specimen = page.locator('.dory-specimen').first();
96
+ if (await specimen.count()) {
97
+ const codeTab = specimen.getByRole('tab', {name: 'Code', exact: true}).first();
98
+ if (await codeTab.count()) {
99
+ await codeTab.click();
100
+ await page.waitForFunction(element => element.getAttribute('aria-selected') === 'true', await codeTab.elementHandle());
101
+ assert.ok(await specimen.locator('[role="tabpanel"]:visible code').count(), `${label}: source panel missing`);
102
+ await specimen.getByRole('tab', {name: 'Preview', exact: true}).first().click();
103
+ }
104
+ if (['components/typography', 'components/expandable', 'components/latex', 'components/callouts'].includes(route)) {
105
+ const file = `${scenario.name}-${route.split('/')[1]}.png`;
106
+ await specimen.screenshot({path: join(output, file)});
107
+ report.screenshots.push(file);
108
+ }
109
+ }
110
+ assert.equal(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth + 1), true, `${label}: page overflows horizontally`);
111
+ report.pages++;
112
+ console.log(`PASS ${label}`);
113
+ } catch (error) {
114
+ report.errors.push(error.message);
115
+ console.error(`FAIL ${error.message}`);
116
+ }
117
+ }
118
+ await context.close();
119
+ }
120
+ } finally {
121
+ await browser?.close();
122
+ await new Promise(resolve => server ? server.httpServer.close(resolve) : resolve());
123
+ await writeFile(join(output, 'report.json'), JSON.stringify(report, null, 2) + '\n');
124
+ }
125
+ console.log(JSON.stringify(report, null, 2));
126
+ if (report.errors.length) process.exitCode = 1;
@@ -0,0 +1,147 @@
1
+ import { readFileSync, readdirSync } from 'node:fs';
2
+ import { join, relative, resolve } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { chromium } from 'playwright-core';
5
+ import { preview } from 'vite';
6
+
7
+ const root = resolve(fileURLToPath(new URL('..', import.meta.url)));
8
+ const docsRoot = join(root, 'docs');
9
+ const pagePath = 'getting-started/automation';
10
+
11
+ function docsFiles(directory = docsRoot) {
12
+ return readdirSync(directory, { withFileTypes: true }).flatMap(entry => {
13
+ const file = join(directory, entry.name);
14
+ if (entry.isDirectory()) return docsFiles(file);
15
+ return entry.name.endsWith('.mdx')
16
+ ? [{ path: `docs/${relative(docsRoot, file).replaceAll('\\', '/')}`, content: readFileSync(file, 'utf8') }]
17
+ : [];
18
+ });
19
+ }
20
+
21
+ const config = JSON.parse(readFileSync(join(docsRoot, 'dory.json'), 'utf8'));
22
+ const basePath = String(config.basePath || '').replace(/\/$/, '');
23
+ const logo = readFileSync(join(docsRoot, 'logo/logo.svg')).toString('base64');
24
+ config.logo = {
25
+ light: `data:image/svg+xml;base64,${logo}`,
26
+ dark: `data:image/svg+xml;base64,${logo}`,
27
+ };
28
+
29
+ function visualMetrics() {
30
+ const measure = selector => {
31
+ const element = document.querySelector(selector);
32
+ if (!element) return null;
33
+ const rect = element.getBoundingClientRect();
34
+ const style = getComputedStyle(element);
35
+ return {
36
+ text: element.textContent?.trim().replace(/\s+/g, ' ').slice(0, 120) ?? '',
37
+ x: rect.x, y: rect.y, width: rect.width, height: rect.height,
38
+ font: style.fontFamily, fontSize: style.fontSize, lineHeight: style.lineHeight,
39
+ weight: style.fontWeight, color: style.color, background: style.backgroundColor,
40
+ padding: style.padding,
41
+ };
42
+ };
43
+ const article = measure('.dory-article');
44
+ const headings = [...document.querySelectorAll('.dory-article h1')].map(element => {
45
+ const rect = element.getBoundingClientRect();
46
+ const style = getComputedStyle(element);
47
+ return { text: element.textContent?.trim().replace(/\s+/g, ' ') ?? '', y: rect.y, fontSize: style.fontSize, lineHeight: style.lineHeight };
48
+ });
49
+ return {
50
+ html: measure('html'), header: measure('.dory-topbar'), main: measure('.dory-main'), article,
51
+ breadcrumb: measure('.dory-breadcrumb'), activeNav: measure('.dory-sidebar-link.active'),
52
+ topNav: measure('header nav[aria-label]'), firstTab: measure('.dory-topbar-tab'),
53
+ headerSearch: measure('.dory-topbar-search'), sidebarSearch: measure('#dory-embedded-search'),
54
+ pageActions: measure('.dory-page-actions'), firstSection: measure('.dory-article h2'),
55
+ firstParagraph: measure('.dory-article p'), toc: measure('.dory-toc-list'), headings,
56
+ topTabs: [...document.querySelectorAll('.dory-topbar-tab')].map(element => element.textContent?.trim()),
57
+ };
58
+ }
59
+
60
+ const differences = [];
61
+ function equal(label, expected, actual) {
62
+ if (expected !== actual) differences.push(`${label}: full site ${JSON.stringify(expected)}, embed ${JSON.stringify(actual)}`);
63
+ }
64
+ function near(label, expected, actual, tolerance = 3) {
65
+ if (typeof expected !== 'number' || typeof actual !== 'number' || Math.abs(expected - actual) > tolerance)
66
+ differences.push(`${label}: full site ${Math.round(expected ?? NaN)}px, embed ${Math.round(actual ?? NaN)}px`);
67
+ }
68
+ function compare(full, embed, theme) {
69
+ for (const key of ['html', 'header', 'main', 'article', 'firstSection', 'firstParagraph']) {
70
+ for (const field of ['background', 'color', 'font', 'fontSize', 'lineHeight']) {
71
+ equal(`${theme} ${key}.${field}`, full[key]?.[field], embed[key]?.[field]);
72
+ }
73
+ }
74
+ for (const key of ['header', 'main', 'article', 'breadcrumb', 'activeNav', 'topNav', 'firstTab', 'firstSection', 'firstParagraph']) {
75
+ for (const field of ['x', 'width']) near(`${theme} ${key}.${field}`, full[key]?.[field], embed[key]?.[field]);
76
+ }
77
+ equal(`${theme} first tab color`, full.firstTab?.color, embed.firstTab?.color);
78
+ equal(`${theme} breadcrumb`, full.breadcrumb?.text, embed.breadcrumb?.text);
79
+ equal(`${theme} top tabs`, full.topTabs.join('|'), embed.topTabs.join('|'));
80
+ equal(`${theme} page actions present`, Boolean(full.pageActions), Boolean(embed.pageActions));
81
+ equal(`${theme} topbar search present`, Boolean(full.headerSearch), Boolean(embed.headerSearch));
82
+ equal(`${theme} sidebar search present`, Boolean(full.sidebarSearch), Boolean(embed.sidebarSearch));
83
+ equal(`${theme} hero count`, full.headings.length, embed.headings.length);
84
+ for (let index = 0; index < full.headings.length; index++) {
85
+ equal(`${theme} hero ${index + 1} text`, full.headings[index]?.text, embed.headings[index]?.text);
86
+ equal(`${theme} hero ${index + 1} font size`, full.headings[index]?.fontSize, embed.headings[index]?.fontSize);
87
+ near(`${theme} hero ${index + 1} offset`, full.headings[index]?.y - full.article.y, embed.headings[index]?.y - embed.article.y);
88
+ }
89
+ for (const key of ['firstSection', 'firstParagraph', 'activeNav'])
90
+ near(`${theme} ${key} vertical offset`, full[key]?.y - full.article.y, embed[key]?.y - embed.article.y);
91
+ }
92
+
93
+ const server = process.env.DORY_PARITY_ORIGIN ? null : await preview({
94
+ root,
95
+ preview: { host: '127.0.0.1', port: 0 },
96
+ });
97
+ const port = server?.httpServer.address()?.port;
98
+ const origin = process.env.DORY_PARITY_ORIGIN ?? `http://127.0.0.1:${port}`;
99
+ let browser;
100
+ try {
101
+ browser = await chromium.launch({ channel: 'chrome', headless: true });
102
+ for (const theme of ['light', 'dark']) {
103
+ const full = await browser.newPage({ viewport: { width: 2048, height: 1200 } });
104
+ await full.goto(`${origin}${basePath}/${pagePath}`, { waitUntil: 'networkidle' });
105
+ if (theme === 'dark') await full.locator('html').evaluate(element => { element.classList.remove('light'); element.classList.add('dark'); });
106
+ await full.evaluate(() => document.fonts.ready);
107
+ const fullMetrics = await full.evaluate(visualMetrics);
108
+
109
+ const embed = await browser.newPage({ viewport: { width: 2048, height: 1200 } });
110
+ await embed.goto(`${origin}${basePath}/runtime/dory-runtime.html`, { waitUntil: 'networkidle' });
111
+ await embed.evaluate(({ files, config, theme, pagePath }) => {
112
+ window.postMessage({ __dory_docs: true, type: 'load', files, path: `docs/${pagePath}.mdx`, theme, locale: 'en_US', config }, '*');
113
+ }, { files: docsFiles(), config, theme, pagePath });
114
+ await embed.getByRole('heading', { name: 'CLI and MCP automation' }).waitFor();
115
+ await embed.evaluate(() => document.fonts.ready);
116
+ const embedMetrics = await embed.evaluate(visualMetrics);
117
+ compare(fullMetrics, embedMetrics, theme);
118
+ if (differences.length || process.env.DORY_PARITY_SCREENSHOTS === '1') {
119
+ await full.screenshot({ path: `/tmp/dory-parity-full-${theme}.png` });
120
+ await embed.screenshot({ path: `/tmp/dory-parity-embed-${theme}.png` });
121
+ }
122
+ await embed.evaluate(({ files, config, theme }) => {
123
+ window.postMessage({ __dory_docs: true, type: 'load', files, path: 'docs/components/accordion.mdx', theme, locale: 'en_US', config }, '*');
124
+ }, { files: docsFiles(), config, theme });
125
+ await embed.getByRole('heading', { name: 'Accordion', exact: true }).first().waitFor();
126
+ const specimen = embed.locator('.dory-specimen').first();
127
+ await specimen.getByRole('tab', { name: 'Code' }).click();
128
+ await specimen.locator('pre').first().waitFor();
129
+ await specimen.getByRole('tab', { name: 'Preview' }).click();
130
+ await embed.evaluate(({ files, config, theme }) => {
131
+ window.postMessage({ __dory_docs: true, type: 'load', files, path: 'docs/components/icons.mdx', theme, locale: 'en_US', config }, '*');
132
+ }, { files: docsFiles(), config, theme });
133
+ await embed.locator('button[title^="Copy <Icon"]').first().waitFor();
134
+ await full.close();
135
+ await embed.close();
136
+ }
137
+ if (differences.length) {
138
+ console.error(`Dory embedded runtime differs from the full docs site:\n${differences.map(item => `- ${item}`).join('\n')}`);
139
+ console.error('Screenshots: /tmp/dory-parity-{full,embed}-{light,dark}.png');
140
+ process.exitCode = 1;
141
+ } else {
142
+ console.log('Dory full site and embedded runtime visual parity passed in light and dark mode.');
143
+ }
144
+ } finally {
145
+ await browser?.close();
146
+ await new Promise(resolve => server?.httpServer.close(resolve) ?? resolve());
147
+ }
package/src/app.css CHANGED
@@ -1,5 +1,26 @@
1
- @import "tailwindcss";
1
+ /* UX supplies the shared reset. Dory adds its own generated utilities. */
2
+ @layer theme, base, components, utilities;
3
+ @import "tailwindcss/theme.css" layer(theme);
4
+ @import "tailwindcss/utilities.css" layer(utilities);
5
+
6
+ /* Emit UX variants alongside Dory’s utilities so responsive rules stay ordered. */
7
+ @source "../node_modules/@clidey/ux/dist";
2
8
 
3
9
  @custom-variant dark (&:where(.dark, .dark *));
4
10
 
11
+ .mermaid-wrapper .mermaid svg {
12
+ display: block;
13
+ max-width: 100%;
14
+ height: auto;
15
+ margin-inline: auto;
16
+ }
17
+
18
+ @media (max-width: 480px) {
19
+ /* Keep the UX 404 illustration inside its narrow stage. Its animation sets left inline. */
20
+ .ux-not-found-character {
21
+ left: clamp(80px, 24vw, 100px) !important;
22
+ scale: .6;
23
+ }
24
+ }
25
+
5
26
 
@@ -0,0 +1,94 @@
1
+ Copyright 2021 The Hanken Grotesk Project Authors (https://github.com/marcologous/hanken-grotesk)
2
+
3
+
4
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
5
+ This license is copied below, and is also available with a FAQ at:
6
+ http://scripts.sil.org/OFL
7
+
8
+
9
+ -----------------------------------------------------------
10
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
11
+ -----------------------------------------------------------
12
+
13
+ PREAMBLE
14
+ The goals of the Open Font License (OFL) are to stimulate worldwide
15
+ development of collaborative font projects, to support the font creation
16
+ efforts of academic and linguistic communities, and to provide a free and
17
+ open framework in which fonts may be shared and improved in partnership
18
+ with others.
19
+
20
+ The OFL allows the licensed fonts to be used, studied, modified and
21
+ redistributed freely as long as they are not sold by themselves. The
22
+ fonts, including any derivative works, can be bundled, embedded,
23
+ redistributed and/or sold with any software provided that any reserved
24
+ names are not used by derivative works. The fonts and derivatives,
25
+ however, cannot be released under any other type of license. The
26
+ requirement for fonts to remain under this license does not apply
27
+ to any document created using the fonts or their derivatives.
28
+
29
+ DEFINITIONS
30
+ "Font Software" refers to the set of files released by the Copyright
31
+ Holder(s) under this license and clearly marked as such. This may
32
+ include source files, build scripts and documentation.
33
+
34
+ "Reserved Font Name" refers to any names specified as such after the
35
+ copyright statement(s).
36
+
37
+ "Original Version" refers to the collection of Font Software components as
38
+ distributed by the Copyright Holder(s).
39
+
40
+ "Modified Version" refers to any derivative made by adding to, deleting,
41
+ or substituting -- in part or in whole -- any of the components of the
42
+ Original Version, by changing formats or by porting the Font Software to a
43
+ new environment.
44
+
45
+ "Author" refers to any designer, engineer, programmer, technical
46
+ writer or other person who contributed to the Font Software.
47
+
48
+ PERMISSION & CONDITIONS
49
+ Permission is hereby granted, free of charge, to any person obtaining
50
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
51
+ redistribute, and sell modified and unmodified copies of the Font
52
+ Software, subject to the following conditions:
53
+
54
+ 1) Neither the Font Software nor any of its individual components,
55
+ in Original or Modified Versions, may be sold by itself.
56
+
57
+ 2) Original or Modified Versions of the Font Software may be bundled,
58
+ redistributed and/or sold with any software, provided that each copy
59
+ contains the above copyright notice and this license. These can be
60
+ included either as stand-alone text files, human-readable headers or
61
+ in the appropriate machine-readable metadata fields within text or
62
+ binary files as long as those fields can be easily viewed by the user.
63
+
64
+ 3) No Modified Version of the Font Software may use the Reserved Font
65
+ Name(s) unless explicit written permission is granted by the corresponding
66
+ Copyright Holder. This restriction only applies to the primary font name as
67
+ presented to the users.
68
+
69
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
70
+ Software shall not be used to promote, endorse or advertise any
71
+ Modified Version, except to acknowledge the contribution(s) of the
72
+ Copyright Holder(s) and the Author(s) or with their explicit written
73
+ permission.
74
+
75
+ 5) The Font Software, modified or unmodified, in part or in whole,
76
+ must be distributed entirely under this license, and must not be
77
+ distributed under any other license. The requirement for fonts to
78
+ remain under this license does not apply to any document created
79
+ using the Font Software.
80
+
81
+ TERMINATION
82
+ This license becomes null and void if any of the above conditions are
83
+ not met.
84
+
85
+ DISCLAIMER
86
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
87
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
88
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
89
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
90
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
91
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
92
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
93
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
94
+ OTHER DEALINGS IN THE FONT SOFTWARE.