polen 0.10.0-next.4 → 0.10.0-next.6
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.
- package/README.md +2 -1
- package/build/api/config/load.js +5 -5
- package/build/api/config/load.js.map +1 -1
- package/build/api/config-resolver/resolve.js +2 -2
- package/build/api/config-resolver/resolve.js.map +1 -1
- package/build/api/content/$$.d.ts +5 -0
- package/build/api/content/$$.d.ts.map +1 -0
- package/build/api/content/$$.js +5 -0
- package/build/api/content/$$.js.map +1 -0
- package/build/api/content/$.d.ts +2 -0
- package/build/api/content/$.d.ts.map +1 -0
- package/build/api/content/$.js +2 -0
- package/build/api/content/$.js.map +1 -0
- package/build/api/content/metadata.d.ts +10 -0
- package/build/api/content/metadata.d.ts.map +1 -0
- package/build/api/content/metadata.js +9 -0
- package/build/api/content/metadata.js.map +1 -0
- package/build/api/content/page.d.ts +11 -0
- package/build/api/content/page.d.ts.map +1 -0
- package/build/api/content/page.js +2 -0
- package/build/api/content/page.js.map +1 -0
- package/build/api/content/scan.d.ts +19 -0
- package/build/api/content/scan.d.ts.map +1 -0
- package/build/api/content/scan.js +57 -0
- package/build/api/content/scan.js.map +1 -0
- package/build/{lib/file-router/sidebar/types.d.ts → api/content/sidebar.d.ts} +8 -1
- package/build/api/content/sidebar.d.ts.map +1 -0
- package/build/api/content/sidebar.js +90 -0
- package/build/api/content/sidebar.js.map +1 -0
- package/build/api/schema/data-sources/schema-directory/schema-directory.js +1 -1
- package/build/api/schema/data-sources/schema-directory/schema-directory.js.map +1 -1
- package/build/api/vite/plugins/branding/index.js +4 -4
- package/build/api/vite/plugins/branding/index.js.map +1 -1
- package/build/api/vite/plugins/core.js +4 -4
- package/build/api/vite/plugins/core.js.map +1 -1
- package/build/api/vite/plugins/pages.d.ts +6 -8
- package/build/api/vite/plugins/pages.d.ts.map +1 -1
- package/build/api/vite/plugins/pages.js +99 -155
- package/build/api/vite/plugins/pages.js.map +1 -1
- package/build/api/vite/plugins/serve.js +5 -5
- package/build/api/vite/plugins/serve.js.map +1 -1
- package/build/cli/_/self-contained-mode.js +5 -5
- package/build/cli/_/self-contained-mode.js.map +1 -1
- package/build/exports/components.d.ts +2 -0
- package/build/exports/components.d.ts.map +1 -0
- package/build/exports/components.js +2 -0
- package/build/exports/components.js.map +1 -0
- package/build/lib/demos/config-schema.d.ts +14 -14
- package/build/lib/file-router/file-router.d.ts +0 -2
- package/build/lib/file-router/file-router.d.ts.map +1 -1
- package/build/lib/file-router/file-router.js +0 -2
- package/build/lib/file-router/file-router.js.map +1 -1
- package/build/lib/file-router/route.d.ts +2 -0
- package/build/lib/file-router/route.d.ts.map +1 -1
- package/build/lib/file-router/route.js.map +1 -1
- package/build/lib/file-router/scan.d.ts.map +1 -1
- package/build/lib/file-router/scan.js +16 -12
- package/build/lib/file-router/scan.js.map +1 -1
- package/build/singletons/debug.d.ts +1 -1
- package/build/singletons/debug.d.ts.map +1 -1
- package/build/singletons/debug.js +1 -1
- package/build/singletons/debug.js.map +1 -1
- package/build/template/components/ThemeToggle.d.ts +3 -0
- package/build/template/components/ThemeToggle.d.ts.map +1 -0
- package/build/template/components/ThemeToggle.jsx +10 -0
- package/build/template/components/ThemeToggle.jsx.map +1 -0
- package/build/template/components/content/$$.d.ts +2 -0
- package/build/template/components/content/$$.d.ts.map +1 -0
- package/build/template/components/content/$$.js +2 -0
- package/build/template/components/content/$$.js.map +1 -0
- package/build/template/components/sidebar/Sidebar.d.ts +2 -2
- package/build/template/components/sidebar/Sidebar.d.ts.map +1 -1
- package/build/template/components/sidebar/SidebarItem.d.ts +3 -3
- package/build/template/components/sidebar/SidebarItem.d.ts.map +1 -1
- package/build/template/components/sidebar/SidebarItem.jsx +1 -1
- package/build/template/components/sidebar/SidebarItem.jsx.map +1 -1
- package/build/template/contexts/ThemeContext.d.ts +12 -0
- package/build/template/contexts/ThemeContext.d.ts.map +1 -0
- package/build/template/contexts/ThemeContext.jsx +41 -0
- package/build/template/contexts/ThemeContext.jsx.map +1 -0
- package/build/template/routes/root.d.ts.map +1 -1
- package/build/template/routes/root.jsx +15 -9
- package/build/template/routes/root.jsx.map +1 -1
- package/package.json +10 -3
- package/src/api/config/load.ts +5 -5
- package/src/api/config-resolver/resolve.ts +2 -2
- package/src/api/content/$$.ts +4 -0
- package/src/api/content/$.test.ts +72 -0
- package/src/api/content/$.ts +1 -0
- package/src/api/content/metadata.ts +11 -0
- package/src/api/content/page.ts +12 -0
- package/src/api/content/scan.ts +82 -0
- package/src/api/content/sidebar.ts +136 -0
- package/src/api/schema/data-sources/schema-directory/schema-directory.ts +1 -1
- package/src/api/vite/plugins/branding/index.ts +4 -4
- package/src/api/vite/plugins/core.ts +4 -4
- package/src/api/vite/plugins/pages.ts +117 -171
- package/src/api/vite/plugins/serve.ts +5 -5
- package/src/cli/_/self-contained-mode.ts +5 -5
- package/src/exports/components.ts +1 -0
- package/src/lib/deployment/$$.ts +1 -1
- package/src/lib/deployment/$.test.ts +3 -3
- package/src/lib/deployment/$.ts +1 -1
- package/src/lib/file-router/file-router.ts +0 -2
- package/src/lib/file-router/linter.test.ts +2 -0
- package/src/lib/file-router/route.ts +2 -0
- package/src/lib/file-router/scan.ts +19 -13
- package/src/lib/task/$.test.ts +3 -3
- package/src/singletons/debug.ts +1 -1
- package/src/template/components/ThemeToggle.tsx +21 -0
- package/src/template/components/content/$$.ts +1 -0
- package/src/template/components/sidebar/Sidebar.tsx +2 -2
- package/src/template/components/sidebar/SidebarItem.tsx +8 -8
- package/src/template/contexts/ThemeContext.tsx +60 -0
- package/src/template/routes/root.tsx +15 -9
- package/build/lib/file-router/scan-tree.d.ts +0 -20
- package/build/lib/file-router/scan-tree.d.ts.map +0 -1
- package/build/lib/file-router/scan-tree.js +0 -158
- package/build/lib/file-router/scan-tree.js.map +0 -1
- package/build/lib/file-router/sidebar/index.d.ts +0 -3
- package/build/lib/file-router/sidebar/index.d.ts.map +0 -1
- package/build/lib/file-router/sidebar/index.js +0 -4
- package/build/lib/file-router/sidebar/index.js.map +0 -1
- package/build/lib/file-router/sidebar/sidebar-tree.d.ts +0 -9
- package/build/lib/file-router/sidebar/sidebar-tree.d.ts.map +0 -1
- package/build/lib/file-router/sidebar/sidebar-tree.js +0 -85
- package/build/lib/file-router/sidebar/sidebar-tree.js.map +0 -1
- package/build/lib/file-router/sidebar/types.d.ts.map +0 -1
- package/build/lib/file-router/sidebar/types.js +0 -2
- package/build/lib/file-router/sidebar/types.js.map +0 -1
- package/build/lib/tree/index.d.ts +0 -3
- package/build/lib/tree/index.d.ts.map +0 -1
- package/build/lib/tree/index.js +0 -2
- package/build/lib/tree/index.js.map +0 -1
- package/build/lib/tree/tree.d.ts +0 -62
- package/build/lib/tree/tree.d.ts.map +0 -1
- package/build/lib/tree/tree.js +0 -134
- package/build/lib/tree/tree.js.map +0 -1
- package/src/lib/file-router/scan-tree.test.ts +0 -189
- package/src/lib/file-router/scan-tree.ts +0 -205
- package/src/lib/file-router/sidebar/index.ts +0 -3
- package/src/lib/file-router/sidebar/sidebar-tree.test.ts +0 -123
- package/src/lib/file-router/sidebar/sidebar-tree.ts +0 -110
- package/src/lib/file-router/sidebar/types.ts +0 -19
- package/src/lib/tree/index.ts +0 -2
- package/src/lib/tree/tree.test.ts +0 -117
- package/src/lib/tree/tree.ts +0 -183
@@ -0,0 +1,21 @@
|
|
1
|
+
import type { React } from '#dep/react/index'
|
2
|
+
import { MoonIcon, SunIcon } from '@radix-ui/react-icons'
|
3
|
+
import { IconButton } from '@radix-ui/themes'
|
4
|
+
import { useTheme } from '../contexts/ThemeContext.tsx'
|
5
|
+
|
6
|
+
export const ThemeToggle: React.FC = () => {
|
7
|
+
const { appearance, toggleTheme } = useTheme()
|
8
|
+
|
9
|
+
return (
|
10
|
+
<IconButton
|
11
|
+
size="2"
|
12
|
+
variant="ghost"
|
13
|
+
color="gray"
|
14
|
+
onClick={toggleTheme}
|
15
|
+
aria-label={`Switch to ${appearance === 'light' ? 'dark' : 'light'} theme`}
|
16
|
+
style={{ cursor: 'pointer' }}
|
17
|
+
>
|
18
|
+
{appearance === 'light' ? <MoonIcon width="18" height="18" /> : <SunIcon width="18" height="18" />}
|
19
|
+
</IconButton>
|
20
|
+
)
|
21
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export { Callout, Tabs } from '@radix-ui/themes'
|
@@ -1,10 +1,10 @@
|
|
1
|
-
import type {
|
1
|
+
import type { Content } from '#api/content/$'
|
2
2
|
import { Box } from '@radix-ui/themes'
|
3
3
|
import type { BoxOwnProps, LayoutProps, MarginProps } from '@radix-ui/themes/props'
|
4
4
|
import { Items } from './SidebarItem.tsx'
|
5
5
|
|
6
6
|
interface SidebarProps extends LayoutProps, MarginProps, BoxOwnProps {
|
7
|
-
data:
|
7
|
+
data: Content.Item[]
|
8
8
|
style?: React.CSSProperties
|
9
9
|
}
|
10
10
|
|
@@ -1,11 +1,11 @@
|
|
1
|
+
import type { Content } from '#api/content/$'
|
1
2
|
import type { React } from '#dep/react/index'
|
2
|
-
import type { FileRouter } from '#lib/file-router/index'
|
3
3
|
import { Texts } from '#template/components/Texts/index'
|
4
|
-
import { Box, Flex
|
4
|
+
import { Box, Flex } from '@radix-ui/themes'
|
5
5
|
import { useLocation } from 'react-router'
|
6
6
|
import { getPathActiveReport, Link } from '../Link.tsx'
|
7
7
|
|
8
|
-
export const Items: React.FC<{ items:
|
8
|
+
export const Items: React.FC<{ items: Content.Item[] }> = ({ items }) => {
|
9
9
|
return (
|
10
10
|
<Flex direction='column' gap='2px'>
|
11
11
|
{items.map((item) => (
|
@@ -26,7 +26,7 @@ export const Items: React.FC<{ items: FileRouter.Sidebar.Item[] }> = ({ items })
|
|
26
26
|
//
|
27
27
|
//
|
28
28
|
|
29
|
-
export const Item: React.FC<{ item:
|
29
|
+
export const Item: React.FC<{ item: Content.Item }> = ({ item }) => {
|
30
30
|
if (item.type === `ItemLink`) {
|
31
31
|
return <SBLink link={item} />
|
32
32
|
}
|
@@ -47,7 +47,7 @@ export const Item: React.FC<{ item: FileRouter.Sidebar.Item }> = ({ item }) => {
|
|
47
47
|
//
|
48
48
|
|
49
49
|
const SBLink: React.FC<{
|
50
|
-
link:
|
50
|
+
link: Content.ItemLink | Content.ItemSection
|
51
51
|
}> = ({ link }) => {
|
52
52
|
const location = useLocation()
|
53
53
|
const currentPathExp = location.pathname
|
@@ -81,7 +81,7 @@ const SBLink: React.FC<{
|
|
81
81
|
//
|
82
82
|
|
83
83
|
const Section: React.FC<{
|
84
|
-
section:
|
84
|
+
section: Content.ItemSection
|
85
85
|
}> = ({ section }) => {
|
86
86
|
return (
|
87
87
|
<Box mt='8'>
|
@@ -104,7 +104,7 @@ const Section: React.FC<{
|
|
104
104
|
//
|
105
105
|
|
106
106
|
const LinkedSection: React.FC<{
|
107
|
-
section:
|
107
|
+
section: Content.ItemSection
|
108
108
|
}> = ({ section }) => {
|
109
109
|
return (
|
110
110
|
<Box>
|
@@ -133,7 +133,7 @@ const LinkedSection: React.FC<{
|
|
133
133
|
)
|
134
134
|
}
|
135
135
|
|
136
|
-
const SectionLink: React.FC<{ link:
|
136
|
+
const SectionLink: React.FC<{ link: Content.ItemLink }> = ({ link }) => {
|
137
137
|
const location = useLocation()
|
138
138
|
const active = getPathActiveReport(link.pathExp, location.pathname)
|
139
139
|
|
@@ -0,0 +1,60 @@
|
|
1
|
+
import type { React } from '#dep/react/index'
|
2
|
+
import { createContext, useContext, useEffect, useState } from 'react'
|
3
|
+
|
4
|
+
type ThemeAppearance = 'light' | 'dark'
|
5
|
+
|
6
|
+
interface ThemeContextValue {
|
7
|
+
appearance: ThemeAppearance
|
8
|
+
toggleTheme: () => void
|
9
|
+
}
|
10
|
+
|
11
|
+
const ThemeContext = createContext<ThemeContextValue | undefined>(undefined)
|
12
|
+
|
13
|
+
const THEME_STORAGE_KEY = 'polen-theme-preference'
|
14
|
+
|
15
|
+
export const ThemeProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
16
|
+
const [appearance, setAppearance] = useState<ThemeAppearance>(() => {
|
17
|
+
// Check if we're in the browser
|
18
|
+
if (typeof window === 'undefined') {
|
19
|
+
return 'light'
|
20
|
+
}
|
21
|
+
|
22
|
+
// Check localStorage first
|
23
|
+
const stored = localStorage.getItem(THEME_STORAGE_KEY)
|
24
|
+
if (stored === 'light' || stored === 'dark') {
|
25
|
+
return stored
|
26
|
+
}
|
27
|
+
|
28
|
+
// Check system preference
|
29
|
+
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
30
|
+
return 'dark'
|
31
|
+
}
|
32
|
+
|
33
|
+
return 'light'
|
34
|
+
})
|
35
|
+
|
36
|
+
useEffect(() => {
|
37
|
+
// Persist to localStorage
|
38
|
+
if (typeof window !== 'undefined') {
|
39
|
+
localStorage.setItem(THEME_STORAGE_KEY, appearance)
|
40
|
+
}
|
41
|
+
}, [appearance])
|
42
|
+
|
43
|
+
const toggleTheme = () => {
|
44
|
+
setAppearance(prev => prev === 'light' ? 'dark' : 'light')
|
45
|
+
}
|
46
|
+
|
47
|
+
return (
|
48
|
+
<ThemeContext.Provider value={{ appearance, toggleTheme }}>
|
49
|
+
{children}
|
50
|
+
</ThemeContext.Provider>
|
51
|
+
)
|
52
|
+
}
|
53
|
+
|
54
|
+
export const useTheme = () => {
|
55
|
+
const context = useContext(ThemeContext)
|
56
|
+
if (!context) {
|
57
|
+
throw new Error('useTheme must be used within a ThemeProvider')
|
58
|
+
}
|
59
|
+
return context
|
60
|
+
}
|
@@ -13,13 +13,15 @@ import projectDataNavbar from 'virtual:polen/project/data/navbar.jsonsuper'
|
|
13
13
|
import projectDataPages from 'virtual:polen/project/data/pages.jsonsuper'
|
14
14
|
import { pages } from 'virtual:polen/project/pages.jsx'
|
15
15
|
import { templateVariables } from 'virtual:polen/template/variables'
|
16
|
-
import { Link } from '../components/Link.
|
17
|
-
import { Logo } from '../components/Logo.
|
18
|
-
import { Sidebar } from '../components/sidebar/Sidebar.
|
16
|
+
import { Link } from '../components/Link.tsx'
|
17
|
+
import { Logo } from '../components/Logo.tsx'
|
18
|
+
import { Sidebar } from '../components/sidebar/Sidebar.tsx'
|
19
|
+
import { ThemeToggle } from '../components/ThemeToggle.tsx'
|
20
|
+
import { ThemeProvider, useTheme } from '../contexts/ThemeContext.tsx'
|
19
21
|
import entryClientUrl from '../entry.client.jsx?url'
|
20
|
-
import { changelog } from './changelog.
|
21
|
-
import { index } from './index.
|
22
|
-
import { reference } from './reference.
|
22
|
+
import { changelog } from './changelog.tsx'
|
23
|
+
import { index } from './index.tsx'
|
24
|
+
import { reference } from './reference.tsx'
|
23
25
|
|
24
26
|
// todo: not needed anymore because not using hono dev vite plugin right?
|
25
27
|
const reactRefreshPreamble = `
|
@@ -45,7 +47,9 @@ export const Component = () => {
|
|
45
47
|
{/* <meta name='theme-color' content='#000000' /> */}
|
46
48
|
</head>
|
47
49
|
<body style={{ margin: 0 }}>
|
48
|
-
<
|
50
|
+
<ThemeProvider>
|
51
|
+
<Layout />
|
52
|
+
</ThemeProvider>
|
49
53
|
<ScrollRestoration />
|
50
54
|
{import.meta.env.DEV && <script type='module' src={entryClientUrl}></script>}
|
51
55
|
</body>
|
@@ -55,6 +59,7 @@ export const Component = () => {
|
|
55
59
|
|
56
60
|
const Layout = () => {
|
57
61
|
const location = useLocation()
|
62
|
+
const { appearance } = useTheme()
|
58
63
|
|
59
64
|
// Determine if we should show sidebar based on current path
|
60
65
|
const getCurrentNavPathExp = (): string | null => {
|
@@ -88,18 +93,19 @@ const Layout = () => {
|
|
88
93
|
>
|
89
94
|
<Logo src={logoSrc} title={templateVariables.title} height={30} showTitle={true} />
|
90
95
|
</LinkReactRouter>
|
91
|
-
<Flex direction='row' gap='4'>
|
96
|
+
<Flex direction='row' gap='4' style={{ flex: 1 }}>
|
92
97
|
{projectDataNavbar.map((item, key) => (
|
93
98
|
<Link key={key} color='gray' to={item.pathExp}>
|
94
99
|
{item.title}
|
95
100
|
</Link>
|
96
101
|
))}
|
97
102
|
</Flex>
|
103
|
+
<ThemeToggle />
|
98
104
|
</Flex>
|
99
105
|
)
|
100
106
|
|
101
107
|
return (
|
102
|
-
<Theme asChild>
|
108
|
+
<Theme asChild appearance={appearance}>
|
103
109
|
<Grid
|
104
110
|
width={{ initial: 'var(--container-4)' }}
|
105
111
|
areas="'header header header header header header header header' 'sidebar sidebar . content content content content content'"
|
@@ -1,20 +0,0 @@
|
|
1
|
-
import { type TreeNode } from '#lib/tree/index';
|
2
|
-
import type { Diagnostic } from './linter.ts';
|
3
|
-
import type { Route } from './route.ts';
|
4
|
-
export type RouteTreeNodeType = 'directory' | 'file';
|
5
|
-
export interface RouteTreeNodeValue {
|
6
|
-
name: string;
|
7
|
-
order?: number;
|
8
|
-
type: RouteTreeNodeType;
|
9
|
-
route?: Route;
|
10
|
-
}
|
11
|
-
export type RouteTreeNode = TreeNode<RouteTreeNodeValue>;
|
12
|
-
export interface ScanTreeResult {
|
13
|
-
routeTree: RouteTreeNode;
|
14
|
-
diagnostics: Diagnostic[];
|
15
|
-
}
|
16
|
-
export declare const scanTree: (parameters: {
|
17
|
-
dir: string;
|
18
|
-
glob?: string;
|
19
|
-
}) => Promise<ScanTreeResult>;
|
20
|
-
//# sourceMappingURL=scan-tree.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"scan-tree.d.ts","sourceRoot":"","sources":["../../../src/lib/file-router/scan-tree.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAErD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,KAAK,EAAa,MAAM,YAAY,CAAA;AAMlD,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,MAAM,CAAA;AAEpD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,iBAAiB,CAAA;IACvB,KAAK,CAAC,EAAE,KAAK,CAAA;CACd;AAED,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC,kBAAkB,CAAC,CAAA;AAExD,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,aAAa,CAAA;IACxB,WAAW,EAAE,UAAU,EAAE,CAAA;CAC1B;AAkID,eAAO,MAAM,QAAQ,GAAU,YAAY;IACzC,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,KAAG,OAAO,CAAC,cAAc,CAoBzB,CAAA"}
|
@@ -1,158 +0,0 @@
|
|
1
|
-
import { TinyGlobby } from '#dep/tiny-globby/index';
|
2
|
-
import { Tree } from '#lib/tree/index';
|
3
|
-
import { Path, Str } from '@wollybeard/kit';
|
4
|
-
//
|
5
|
-
// Constants
|
6
|
-
//
|
7
|
-
const conventions = {
|
8
|
-
index: {
|
9
|
-
name: `index`,
|
10
|
-
},
|
11
|
-
numberedPrefix: {
|
12
|
-
pattern: Str.pattern(/^(?<order>\d+)[_-](?<name>.+)$/),
|
13
|
-
},
|
14
|
-
};
|
15
|
-
//
|
16
|
-
// Helpers
|
17
|
-
//
|
18
|
-
const parseSegment = (segment) => {
|
19
|
-
const match = Str.match(segment, conventions.numberedPrefix.pattern);
|
20
|
-
if (match) {
|
21
|
-
return {
|
22
|
-
name: match.groups.name,
|
23
|
-
order: parseInt(match.groups.order, 10),
|
24
|
-
};
|
25
|
-
}
|
26
|
-
return { name: segment };
|
27
|
-
};
|
28
|
-
const buildRouteTreeFromPaths = async (paths, rootDir) => {
|
29
|
-
// Root node (represents the pages directory itself)
|
30
|
-
const root = Tree.node({
|
31
|
-
name: 'root',
|
32
|
-
type: 'directory',
|
33
|
-
});
|
34
|
-
// Process each file path
|
35
|
-
for (const filePath of paths) {
|
36
|
-
const relativePath = Path.relative(rootDir, filePath);
|
37
|
-
// Split the path into segments
|
38
|
-
const segments = relativePath.split(Path.sep).filter(s => s.length > 0);
|
39
|
-
if (segments.length === 0)
|
40
|
-
continue; // Skip root directory
|
41
|
-
// Navigate/create path in tree
|
42
|
-
let currentNode = root;
|
43
|
-
for (let i = 0; i < segments.length; i++) {
|
44
|
-
const segment = segments[i];
|
45
|
-
const isLast = i === segments.length - 1;
|
46
|
-
// Parse segment for ordering
|
47
|
-
let segmentName = segment;
|
48
|
-
// Strip extension for files
|
49
|
-
if (isLast && (segment.endsWith('.md') || segment.endsWith('.mdx'))) {
|
50
|
-
segmentName = segment.replace(/\.(md|mdx)$/, '');
|
51
|
-
}
|
52
|
-
const parsed = parseSegment(segmentName);
|
53
|
-
// Find existing child
|
54
|
-
const existingChildIndex = currentNode.children.findIndex(child => child.value.name === parsed.name);
|
55
|
-
let childNode = existingChildIndex >= 0 ? currentNode.children[existingChildIndex] : undefined;
|
56
|
-
if (!childNode) {
|
57
|
-
// Create new node
|
58
|
-
if (isLast) {
|
59
|
-
// This is a file
|
60
|
-
const route = filePathToRoute(filePath, rootDir);
|
61
|
-
childNode = Tree.node({
|
62
|
-
name: parsed.name,
|
63
|
-
order: parsed.order,
|
64
|
-
type: 'file',
|
65
|
-
route,
|
66
|
-
});
|
67
|
-
}
|
68
|
-
else {
|
69
|
-
// This is a directory (implicit from file path)
|
70
|
-
childNode = Tree.node({
|
71
|
-
name: parsed.name,
|
72
|
-
order: parsed.order,
|
73
|
-
type: 'directory',
|
74
|
-
});
|
75
|
-
}
|
76
|
-
currentNode.children.push(childNode);
|
77
|
-
}
|
78
|
-
else if (isLast && childNode.value.type === 'file') {
|
79
|
-
// Handle collision for files with same name
|
80
|
-
// If new file has higher or equal order, replace the existing one (last wins for ties)
|
81
|
-
if (parsed.order !== undefined
|
82
|
-
&& (childNode.value.order === undefined || parsed.order >= childNode.value.order)) {
|
83
|
-
const route = filePathToRoute(filePath, rootDir);
|
84
|
-
const newNode = Tree.node({
|
85
|
-
name: parsed.name,
|
86
|
-
order: parsed.order,
|
87
|
-
type: 'file',
|
88
|
-
route,
|
89
|
-
});
|
90
|
-
currentNode.children[existingChildIndex] = newNode;
|
91
|
-
childNode = newNode;
|
92
|
-
}
|
93
|
-
// Otherwise keep the existing node (when existing has higher order)
|
94
|
-
}
|
95
|
-
currentNode = childNode;
|
96
|
-
}
|
97
|
-
}
|
98
|
-
// Sort the tree
|
99
|
-
return sortRouteTree(root);
|
100
|
-
};
|
101
|
-
const sortRouteTree = (tree) => {
|
102
|
-
return Tree.sort(tree, (a, b) => {
|
103
|
-
// If both have orders, sort by order
|
104
|
-
if (a.order !== undefined && b.order !== undefined) {
|
105
|
-
return a.order - b.order;
|
106
|
-
}
|
107
|
-
// If only one has order, it comes first
|
108
|
-
if (a.order !== undefined)
|
109
|
-
return -1;
|
110
|
-
if (b.order !== undefined)
|
111
|
-
return 1;
|
112
|
-
// Otherwise sort alphabetically
|
113
|
-
return a.name.localeCompare(b.name);
|
114
|
-
});
|
115
|
-
};
|
116
|
-
//
|
117
|
-
// Main scan function
|
118
|
-
//
|
119
|
-
export const scanTree = async (parameters) => {
|
120
|
-
const { dir, glob = `**/*` } = parameters;
|
121
|
-
// Get all files
|
122
|
-
const filePaths = await TinyGlobby.glob(glob, {
|
123
|
-
absolute: true,
|
124
|
-
cwd: dir,
|
125
|
-
onlyFiles: true,
|
126
|
-
});
|
127
|
-
// Build tree structure (directories will be created implicitly)
|
128
|
-
const routeTree = await buildRouteTreeFromPaths(filePaths, dir);
|
129
|
-
// TODO: Implement tree-based linting
|
130
|
-
const diagnostics = [];
|
131
|
-
return {
|
132
|
-
routeTree,
|
133
|
-
diagnostics,
|
134
|
-
};
|
135
|
-
};
|
136
|
-
// Reuse existing route creation logic
|
137
|
-
const filePathToRoute = (filePathExpression, rootDir) => {
|
138
|
-
const file = {
|
139
|
-
path: {
|
140
|
-
absolute: Path.parse(filePathExpression),
|
141
|
-
relative: Path.parse(Path.relative(rootDir, filePathExpression)),
|
142
|
-
},
|
143
|
-
};
|
144
|
-
const dirPath = Str.split(Str.removeSurrounding(file.path.relative.dir, Path.sep), Path.sep);
|
145
|
-
// Parse numbered prefix from filename
|
146
|
-
const prefixMatch = file.path.relative.name.match(conventions.numberedPrefix.pattern);
|
147
|
-
const order = prefixMatch?.groups?.[`order`] ? parseInt(prefixMatch.groups[`order`], 10) : undefined;
|
148
|
-
const nameWithoutPrefix = prefixMatch?.groups?.[`name`] ?? file.path.relative.name;
|
149
|
-
const logical = {
|
150
|
-
path: nameWithoutPrefix === conventions.index.name ? dirPath : dirPath.concat(nameWithoutPrefix),
|
151
|
-
order,
|
152
|
-
};
|
153
|
-
return {
|
154
|
-
logical,
|
155
|
-
file,
|
156
|
-
};
|
157
|
-
};
|
158
|
-
//# sourceMappingURL=scan-tree.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"scan-tree.js","sourceRoot":"","sources":["../../../src/lib/file-router/scan-tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,IAAI,EAAiB,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAwB3C,EAAE;AACF,YAAY;AACZ,EAAE;AAEF,MAAM,WAAW,GAAG;IAClB,KAAK,EAAE;QACL,IAAI,EAAE,OAAO;KACd;IACD,cAAc,EAAE;QACd,OAAO,EAAE,GAAG,CAAC,OAAO,CAAgC,gCAAgC,CAAC;KACtF;CACF,CAAA;AAED,EAAE;AACF,UAAU;AACV,EAAE;AAEF,MAAM,YAAY,GAAG,CAAC,OAAe,EAAoC,EAAE;IACzE,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,WAAW,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;IACpE,IAAI,KAAK,EAAE,CAAC;QACV,OAAO;YACL,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI;YACvB,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC;SACxC,CAAA;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AC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IACpG,MAAM,iBAAiB,GAAG,WAAW,EAAE,MAAM,EAAE,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAA;IAElF,MAAM,OAAO,GAAG;QACd,IAAI,EAAE,iBAAiB,KAAK,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC;QAChG,KAAK;KACN,CAAA;IAED,OAAO;QACL,OAAO;QACP,IAAI;KACL,CAAA;AACH,CAAC,CAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/file-router/sidebar/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,mBAAmB,CAAA;AAEhD,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/file-router/sidebar/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,mBAAmB,CAAA;AAChD,8DAA8D;AAC9D,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAA"}
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import * as FileRouter from '../file-router.ts';
|
2
|
-
import type { RouteTreeNode } from '../scan-tree.ts';
|
3
|
-
import type { Sidebar } from './types.ts';
|
4
|
-
export * from './types.ts';
|
5
|
-
/**
|
6
|
-
* Build sidebar from tree structure
|
7
|
-
*/
|
8
|
-
export declare const buildFromTree: (routeTree: RouteTreeNode, basePath: FileRouter.Path) => Sidebar;
|
9
|
-
//# sourceMappingURL=sidebar-tree.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"sidebar-tree.d.ts","sourceRoot":"","sources":["../../../../src/lib/file-router/sidebar/sidebar-tree.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,KAAK,EAAyB,OAAO,EAAE,MAAM,YAAY,CAAA;AAEhE,cAAc,YAAY,CAAA;AAE1B;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,WAAW,aAAa,EAAE,UAAU,UAAU,CAAC,IAAI,KAAG,OAcnF,CAAA"}
|
@@ -1,85 +0,0 @@
|
|
1
|
-
import { Tree } from '#lib/tree/index';
|
2
|
-
import { Str } from '@wollybeard/kit';
|
3
|
-
import * as FileRouter from "../file-router.js";
|
4
|
-
export * from "./types.js";
|
5
|
-
/**
|
6
|
-
* Build sidebar from tree structure
|
7
|
-
*/
|
8
|
-
export const buildFromTree = (routeTree, basePath) => {
|
9
|
-
const links = [];
|
10
|
-
const sections = [];
|
11
|
-
// Process only the children of the root node
|
12
|
-
for (const child of routeTree.children) {
|
13
|
-
processNode(child, basePath, [], links, sections);
|
14
|
-
}
|
15
|
-
const items = [...links, ...sections];
|
16
|
-
return {
|
17
|
-
items,
|
18
|
-
};
|
19
|
-
};
|
20
|
-
const processNode = (node, basePath, parentPath, links, sections) => {
|
21
|
-
const currentPath = [...parentPath, node.value.name];
|
22
|
-
if (node.value.type === 'directory') {
|
23
|
-
// This is a directory - create a section
|
24
|
-
const sectionPath = [...basePath, ...currentPath];
|
25
|
-
const sectionPathExp = FileRouter.pathToExpression(sectionPath);
|
26
|
-
const sectionTitle = Str.titlizeSlug(node.value.name);
|
27
|
-
const section = {
|
28
|
-
type: `ItemSection`,
|
29
|
-
title: sectionTitle,
|
30
|
-
pathExp: sectionPathExp.startsWith('/') ? sectionPathExp.slice(1) : sectionPathExp,
|
31
|
-
isLinkToo: false,
|
32
|
-
links: [],
|
33
|
-
};
|
34
|
-
// Check if this directory has an index file
|
35
|
-
const indexChild = node.children.find(child => child.value.type === 'file' && child.value.name === 'index');
|
36
|
-
if (indexChild) {
|
37
|
-
section.isLinkToo = true;
|
38
|
-
}
|
39
|
-
// Process all non-index children as links for this section
|
40
|
-
for (const child of node.children) {
|
41
|
-
if (child.value.type === 'file' && child.value.name !== 'index' && child.value.route) {
|
42
|
-
// Pass the parent path of the route, not the section path
|
43
|
-
const routeParentPath = child.value.route.logical.path.slice(0, -1);
|
44
|
-
section.links.push(routeToItemLink(child.value.route, routeParentPath));
|
45
|
-
}
|
46
|
-
else if (child.value.type === 'directory') {
|
47
|
-
// Recursively process subdirectories
|
48
|
-
// Note: This creates nested sections which the original implementation doesn't support
|
49
|
-
// For now, we'll just add the files from subdirectories to the parent section
|
50
|
-
collectFilesFromDirectory(child, child.value.route?.logical.path || [], section.links);
|
51
|
-
}
|
52
|
-
}
|
53
|
-
sections.push(section);
|
54
|
-
}
|
55
|
-
else if (node.value.type === 'file' && node.value.route) {
|
56
|
-
// This is a top-level file - add as nav
|
57
|
-
if (node.value.name !== 'index') {
|
58
|
-
links.push(routeToItemLink(node.value.route, basePath));
|
59
|
-
}
|
60
|
-
}
|
61
|
-
};
|
62
|
-
const collectFilesFromDirectory = (node, basePath, links) => {
|
63
|
-
Tree.visit(node, (n) => {
|
64
|
-
if (n.value.type === 'file' && n.value.route && n.value.name !== 'index') {
|
65
|
-
// Use the route's parent path for relative title generation
|
66
|
-
const routeParentPath = n.value.route.logical.path.slice(0, -1);
|
67
|
-
links.push(routeToItemLink(n.value.route, routeParentPath));
|
68
|
-
}
|
69
|
-
});
|
70
|
-
};
|
71
|
-
const routeToItemLink = (route, basePath) => {
|
72
|
-
const pagePathExp = FileRouter.routeToPathExpression(route);
|
73
|
-
const pageRelative = FileRouter.makeRelativeUnsafe(route, basePath);
|
74
|
-
const pageRelativePathExp = FileRouter.routeToPathExpression(pageRelative);
|
75
|
-
// Remove leading slash for title generation
|
76
|
-
const titlePath = pageRelativePathExp.startsWith('/') ? pageRelativePathExp.slice(1) : pageRelativePathExp;
|
77
|
-
// Use only the last segment for the title
|
78
|
-
const titleSegment = pageRelative.logical.path[pageRelative.logical.path.length - 1] || titlePath;
|
79
|
-
return {
|
80
|
-
type: `ItemLink`,
|
81
|
-
pathExp: pagePathExp.startsWith('/') ? pagePathExp.slice(1) : pagePathExp,
|
82
|
-
title: Str.titlizeSlug(titleSegment),
|
83
|
-
};
|
84
|
-
};
|
85
|
-
//# sourceMappingURL=sidebar-tree.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"sidebar-tree.js","sourceRoot":"","sources":["../../../../src/lib/file-router/sidebar/sidebar-tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AACrC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAA;AAI/C,cAAc,YAAY,CAAA;AAE1B;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,SAAwB,EAAE,QAAyB,EAAW,EAAE;IAC5F,MAAM,KAAK,GAAe,EAAE,CAAA;IAC5B,MAAM,QAAQ,GAAkB,EAAE,CAAA;IAElC,6CAA6C;IAC7C,KAAK,MAAM,KAAK,IAAI,SAAS,CAAC,QAAQ,EAAE,CAAC;QACvC,WAAW,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAA;IACnD,CAAC;IAED,MAAM,KAAK,GAAG,CAAC,GAAG,KAAK,EAAE,GAAG,QAAQ,CAAC,CAAA;IAErC,OAAO;QACL,KAAK;KACN,CAAA;AACH,CAAC,CAAA;AAED,MAAM,WAAW,GAAG,CAClB,IAAmB,EACnB,QAAyB,EACzB,UAAoB,EACpB,KAAiB,EACjB,QAAuB,EACjB,EAAE;IACR,MAAM,WAAW,GAAG,CAAC,GAAG,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAEpD,I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GAAG,WAAW,CAAA;AAEzC,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,UAAU,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,aAAa,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE,QAAQ,EAAE,CAAA;CAClB"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/lib/file-router/sidebar/types.ts"],"names":[],"mappings":""}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/tree/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA"}
|
package/build/lib/tree/index.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/tree/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA"}
|
package/build/lib/tree/tree.d.ts
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Generic tree data structure and utilities
|
3
|
-
*/
|
4
|
-
export interface TreeNode<T> {
|
5
|
-
value: T;
|
6
|
-
children: TreeNode<T>[];
|
7
|
-
}
|
8
|
-
export type TreeVisitor<T, R = void> = (node: TreeNode<T>, depth: number, path: T[]) => R;
|
9
|
-
export type TreeMapper<T, U> = (value: T, depth: number, path: T[]) => U;
|
10
|
-
export type TreePredicate<T> = (value: T, depth: number, path: T[]) => boolean;
|
11
|
-
/**
|
12
|
-
* Create a new tree node
|
13
|
-
*/
|
14
|
-
export declare const node: <T>(value: T, children?: TreeNode<T>[]) => TreeNode<T>;
|
15
|
-
/**
|
16
|
-
* Map over a tree, transforming each node's value
|
17
|
-
*/
|
18
|
-
export declare const map: <T, U>(tree: TreeNode<T>, mapper: TreeMapper<T, U>, depth?: number, path?: T[]) => TreeNode<U>;
|
19
|
-
/**
|
20
|
-
* Visit each node in the tree (depth-first)
|
21
|
-
*/
|
22
|
-
export declare const visit: <T>(tree: TreeNode<T>, visitor: TreeVisitor<T>, depth?: number, path?: T[]) => void;
|
23
|
-
/**
|
24
|
-
* Find a node in the tree
|
25
|
-
*/
|
26
|
-
export declare const find: <T>(tree: TreeNode<T>, predicate: TreePredicate<T>, depth?: number, path?: T[]) => TreeNode<T> | undefined;
|
27
|
-
/**
|
28
|
-
* Filter tree nodes (keeps structure, removes non-matching nodes)
|
29
|
-
*/
|
30
|
-
export declare const filter: <T>(tree: TreeNode<T>, predicate: TreePredicate<T>, depth?: number, path?: T[]) => TreeNode<T> | undefined;
|
31
|
-
/**
|
32
|
-
* Sort a tree's children at each level
|
33
|
-
*/
|
34
|
-
export declare const sort: <T>(tree: TreeNode<T>, compareFn: (a: T, b: T) => number) => TreeNode<T>;
|
35
|
-
/**
|
36
|
-
* Flatten a tree into an array (depth-first)
|
37
|
-
*/
|
38
|
-
export declare const flatten: <T>(tree: TreeNode<T>) => T[];
|
39
|
-
/**
|
40
|
-
* Get the depth of the tree
|
41
|
-
*/
|
42
|
-
export declare const depth: <T>(tree: TreeNode<T>) => number;
|
43
|
-
/**
|
44
|
-
* Count total nodes in the tree
|
45
|
-
*/
|
46
|
-
export declare const count: <T>(tree: TreeNode<T>) => number;
|
47
|
-
/**
|
48
|
-
* Check if a node is a leaf (has no children)
|
49
|
-
*/
|
50
|
-
export declare const isLeaf: <T>(node: TreeNode<T>) => boolean;
|
51
|
-
/**
|
52
|
-
* Get all leaf nodes
|
53
|
-
*/
|
54
|
-
export declare const leaves: <T>(tree: TreeNode<T>) => TreeNode<T>[];
|
55
|
-
/**
|
56
|
-
* Build a tree from a flat list with parent references
|
57
|
-
*/
|
58
|
-
export declare const fromList: <T extends {
|
59
|
-
id: string;
|
60
|
-
parentId?: string;
|
61
|
-
}>(items: T[], rootId?: string) => TreeNode<T>[];
|
62
|
-
//# sourceMappingURL=tree.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../../src/lib/tree/tree.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,QAAQ,CAAC,CAAC;IACzB,KAAK,EAAE,CAAC,CAAA;IACR,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAA;CACxB;AAED,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,CAAA;AAEzF,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,CAAA;AAExE,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,OAAO,CAAA;AAE9E;;GAEG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,EAAE,OAAO,CAAC,EAAE,WAAU,QAAQ,CAAC,CAAC,CAAC,EAAO,KAAG,QAAQ,CAAC,CAAC,CAGzE,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,GAAG,GAAI,CAAC,EAAE,CAAC,EACtB,MAAM,QAAQ,CAAC,CAAC,CAAC,EACjB,QAAQ,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,EACxB,cAAS,EACT,OAAM,CAAC,E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