Skip to content

Commit

Permalink
fix: ParseError on some exactLength expressions (#1222)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssalbdivad authored Dec 5, 2024
1 parent 3ac3fd8 commit 30507ba
Show file tree
Hide file tree
Showing 115 changed files with 13,036 additions and 101 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ tmp
.docusaurus
.astro
.next
.source
.cache-loader
.attest
coverage
Expand Down
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"biome.enabled": false,
"editor.codeActionsOnSave": [
"editor.formatOnSave",
"source.fixAll.eslint",
Expand Down Expand Up @@ -40,7 +41,9 @@
" ": true
},
"search.exclude": {
"**/out": true
"**/out": true,
"**/.next": true,
"**/.source": true
},
"editor.quickSuggestions": {
"strings": "on"
Expand Down
10 changes: 5 additions & 5 deletions ark/attest/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ark/attest",
"version": "0.29.0",
"version": "0.30.0",
"license": "MIT",
"author": {
"name": "David Blass",
Expand Down Expand Up @@ -36,13 +36,13 @@
"test": "ts ../repo/testPackage.ts"
},
"dependencies": {
"arktype": "workspace:*",
"@ark/fs": "workspace:*",
"@ark/util": "workspace:*",
"@typescript/vfs": "1.6.0",
"@prettier/sync": "0.5.2",
"@typescript/analyze-trace": "0.10.1",
"prettier": "3.3.3",
"@prettier/sync": "0.5.2"
"@typescript/vfs": "1.6.0",
"arktype": "workspace:*",
"prettier": "3.4.2"
},
"devDependencies": {
"typescript": "catalog:"
Expand Down
26 changes: 26 additions & 0 deletions ark/docs/fuma/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# my-app

This is a Next.js application generated with
[Create Fumadocs](https://github.com/fuma-nama/fumadocs).

Run development server:

```bash
npm run dev
# or
pnpm dev
# or
yarn dev
```

Open http://localhost:3000 with your browser to see the result.

## Learn More

To learn more about Next.js and Fumadocs, take a look at the following
resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js
features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
- [Fumadocs](https://fumadocs.vercel.app) - learn about Fumadocs
17 changes: 17 additions & 0 deletions ark/docs/fuma/app/(home)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { HomeLayout } from "fumadocs-ui/layouts/home"
import type { ReactNode } from "react"
import { FloatYourBoat } from "../../components/FloatYourBoat.jsx"
import { baseOptions } from "../layout.config.jsx"

export type LayoutProps = {
children: ReactNode
}

export default ({ children }: LayoutProps): React.ReactElement => (
<HomeLayout
{...baseOptions}
nav={{ ...baseOptions.nav, children: <FloatYourBoat /> }}
>
{children}
</HomeLayout>
)
76 changes: 76 additions & 0 deletions ark/docs/fuma/app/(home)/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { ArkCard, ArkCards } from "../../components/ArkCard"
import { CodeBlock } from "../../components/CodeBlock"
import { Hero } from "../../components/Hero"
import { TsIcon } from "../../components/icons/ts"
import { LinkCard } from "../../components/LinkCard"
import { RuntimeBenchmarksGraph } from "../../components/RuntimeBenchmarksGraph"

import {
LightbulbIcon,
MessageCircleWarning,
MessageSquareTextIcon,
RocketIcon,
SearchIcon
} from "lucide-react"

export default () => (
<div className="flex-1 pt-40 container relative pb-20">
<Hero />
<h2 className="text-4xl text-highlight font-semibold mb-3">What awaits</h2>

<ArkCards>
<ArkCard title="Unparalleled DX" icon={<TsIcon height={20} />}>
<p>
Type syntax you already know with safety and completions unlike
anything you&apos;ve ever seen
</p>
<CodeBlock fromFile="unparalleledDx" />
</ArkCard>
<ArkCard title="Faster... everything" icon={<RocketIcon />}>
<p>
100x faster than Zod at runtime with editor performance that will
remind you how autocomplete is supposed to feel
</p>
<RuntimeBenchmarksGraph className="mt-2" />
</ArkCard>
<ArkCard title="Clarity and Concision" icon={<MessageSquareTextIcon />}>
<p>
Definitions are half as long, type errors are twice as readable, and
hovers tell you just what really matters
</p>
<CodeBlock fromFile="clarityAndConcision" />
</ArkCard>
<ArkCard title="Better Errors" icon={<MessageCircleWarning />}>
<p>Deeply customizable messages with great defaults</p>
<CodeBlock fromFile="betterErrors" />
</ArkCard>
<ArkCard title="Deep Introspectability" icon={<SearchIcon />}>
<p>
ArkType uses set theory to understand and expose the relationships
between your types at runtime the way TypeScript does at compile time
</p>
<CodeBlock fromFile="deepIntrospectability" />
</ArkCard>
<ArkCard title="Intrinsic Optimization" icon={<LightbulbIcon />}>
<p>
Every schema is internally normalized and reduced to its purest and
fastest representation
</p>
<CodeBlock fromFile="intrinsicOptimization" />
</ArkCard>
{/* <Card title="Portable" icon="seti:json">
<p>
Most definitions are just objects and strings- take them across the stack or
even outside JS altogether
</p>
</Card> */}
</ArkCards>

<LinkCard
title="Doc up"
description="Everything you need to know from installation to integration"
href="/docs/intro/setup"
className="sm:mt-16 mt-4"
/>
</div>
)
5 changes: 5 additions & 0 deletions ark/docs/fuma/app/api/search/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { createFromSource } from "fumadocs-core/search/server"
import { source } from "../../../lib/source.js"
// it should be cached forever
export const revalidate = false
export const { staticGET: GET } = createFromSource(source)
78 changes: 78 additions & 0 deletions ark/docs/fuma/app/docs-og/[...slug]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { metadataImage } from "../../../lib/metadata.js"
// import { fromPackageRoot } from "@ark/fs"
import { generateOGImage } from "fumadocs-ui/og"

export const GET = metadataImage.createAPI(page =>
generateOGImage({
title: page.data.title === "ArkType" ? "ArkType" : "ArkType Docs",
description:
page.data.title === "ArkType" ? page.data.description : page.data.title,
site: "ArkType",
fonts: [
// fromPackageRoot("src", "assets", "Raleway.ttf"),
// "https://fonts.googleapis.com/css?family=Raleway:300,400,500,700&display=swap"
]
})
)

export const generateStaticParams = (): {
slug: string[]
lang?: string
}[] => metadataImage.generateParams()

// TODO will handle this when moved into arktype repo
// docs: https://fumadocs.vercel.app/docs/ui/open-graph

// import { fromPackageRoot } from "@ark/fs"
// import { OGImageRoute } from "astro-og-canvas"
// import { getCollection } from "astro:content"

// // based on https://hideoo.dev/notes/starlight-og-images/

// // Get all entries from the `docs` content collection.
// const entries = await getCollection("docs")

// let defaultDescription = ""

// // Map the entry array to an object with the page ID as key and the
// // frontmatter data as value.
// const pages = Object.fromEntries(
// entries.map(({ data, id }) => {
// if (id === "index.mdx") defaultDescription = data.description!
// return [id, { data }]
// })
// )

// export const { getStaticPaths, GET } = OGImageRoute({
// // Pass down the documentation pages.
// pages,
// // Define the name of the parameter used in the endpoint path, here `slug`
// // as the file is named `[...slug].ts`.
// param: "slug",
// // Define a function called for each page to customize the generated image.
// getImageOptions: (_path, page: (typeof pages)[number]) => ({
// // Use the page title and description as the image title and description.
// title: page.data.title === "ArkType" ? "ArkType" : "ArkType Docs",
// description:
// page.data.title === "ArkType" ? defaultDescription : page.data.title,
// bgImage: {
// path: fromPackageRoot("src", "assets", "openGraphBackground.png")
// },
// font: {
// title: {
// families: ["Raleway"],
// weight: "Bold",
// size: 100
// },
// description: {
// families: ["Raleway"],
// weight: "SemiBold",
// size: 40
// }
// },
// fonts: [
// fromPackageRoot("src", "assets", "Raleway.ttf"),
// "https://fonts.googleapis.com/css?family=Raleway:300,400,500,700&display=swap"
// ]
// })
// })
57 changes: 57 additions & 0 deletions ark/docs/fuma/app/docs/[[...slug]]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { Popup, PopupContent, PopupTrigger } from "fumadocs-twoslash/ui"
import { CodeBlock, Pre } from "fumadocs-ui/components/codeblock"
import defaultMdxComponents from "fumadocs-ui/mdx"
import {
DocsBody,
DocsDescription,
DocsPage,
DocsTitle
} from "fumadocs-ui/page"
import { notFound } from "next/navigation"
import { source } from "../../../lib/source.js"

export default async (props: { params: Promise<{ slug?: string[] }> }) => {
const params = await props.params
const page = source.getPage(params.slug)
if (!page) notFound()

const MDX = page.data.body

return (
<DocsPage toc={page.data.toc} full={page.data.full ?? false}>
<DocsTitle>{page.data.title}</DocsTitle>
<DocsDescription>{page.data.description}</DocsDescription>
<DocsBody>
<MDX
components={{
...defaultMdxComponents,
Popup,
PopupContent,
PopupTrigger,

pre: ({ ref: _, ...props }) => (
<CodeBlock {...props}>
<Pre>{props.children}</Pre>
</CodeBlock>
)
}}
/>
</DocsBody>
</DocsPage>
)
}

export const generateStaticParams = async () => source.generateParams()

export const generateMetadata = async (props: {
params: Promise<{ slug?: string[] }>
}) => {
const params = await props.params
const page = source.getPage(params.slug)
if (!page) notFound()

return {
title: page.data.title,
description: page.data.description
}
}
10 changes: 10 additions & 0 deletions ark/docs/fuma/app/docs/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { DocsLayout } from "fumadocs-ui/layouts/docs"
import type { ReactNode } from "react"
import { source } from "../../lib/source.js"
import { baseOptions } from "../layout.config.jsx"

export default ({ children }: { children: ReactNode }) => (
<DocsLayout tree={source.pageTree} {...baseOptions}>
{children}
</DocsLayout>
)
Loading

0 comments on commit 30507ba

Please sign in to comment.