-
Notifications
You must be signed in to change notification settings - Fork 0
Website #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Website #10
Changes from 19 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
21ba499
rename prototypey to prototypekit across entire project
tylersayshi 814d692
add interactive playground site with Monaco editor and real-time comp…
tylersayshi a0ae289
add vitest testing setup to site package with component tests
tylersayshi c472d42
migrate site to rolldown bundler
tylersayshi beda016
initial working types
tylersayshi ee61dff
working types
tylersayshi 35e5d72
working json output
tylersayshi 1b1dc63
types working fr
tylersayshi ce4128f
more site readiness
tylersayshi 1f280a0
Revert "more site readiness"
tylersayshi 00b8f30
Revert "rename prototypey to prototypekit across entire project"
tylersayshi 0e12fa9
rename prototypekit back to prototypey
tylersayshi 98c0fbc
restore site readiness changes
tylersayshi 12b6226
fix for playground
tylersayshi 3f8ba0c
formatting and tsc
tylersayshi 7e74463
fix ui tests
tylersayshi 9c27810
tsconfig cleanup
tylersayshi 7de2fb2
remove extra scripts
tylersayshi 9a01054
todo for vite config
tylersayshi 2a836c0
website hover working with public types removed
tylersayshi 305a208
tests passing
tylersayshi 8c94efa
fix act error
tylersayshi 730b9b1
update path
tylersayshi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>prototypey - Type-safe lexicon inference for ATProto</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.tsx"></script> | ||
</body> | ||
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"name": "@prototypey/site", | ||
"version": "0.0.0", | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "tsc && vite build", | ||
"preview": "vite preview", | ||
"test": "vitest" | ||
}, | ||
"dependencies": { | ||
"@monaco-editor/react": "^4.6.0", | ||
"monaco-editor": "^0.52.2", | ||
"prototypey": "workspace:*", | ||
"react": "^18.3.1", | ||
"react-dom": "^18.3.1" | ||
}, | ||
"devDependencies": { | ||
"@testing-library/jest-dom": "^6.9.1", | ||
"@testing-library/react": "^16.1.0", | ||
"@testing-library/user-event": "^14.5.2", | ||
"@types/react": "^18.3.18", | ||
"@types/react-dom": "^18.3.5", | ||
"@vitejs/plugin-react": "^4.3.4", | ||
"jsdom": "^25.0.1", | ||
"typescript": "5.8.3", | ||
"vite": "^6.0.5", | ||
"vitest": "^3.2.4" | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { GetNullable, GetRequired, Infer } from "./infer"; | ||
export { lx } from "./lib"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
import { Prettify } from "./type-utils.js"; | ||
|
||
//#region src/infer.d.ts | ||
type InferType<T> = T extends { | ||
type: "record"; | ||
} | ||
? InferRecord<T> | ||
: T extends { | ||
type: "object"; | ||
} | ||
? InferObject<T> | ||
: T extends { | ||
type: "array"; | ||
} | ||
? InferArray<T> | ||
: T extends { | ||
type: "params"; | ||
} | ||
? InferParams<T> | ||
: T extends { | ||
type: "union"; | ||
} | ||
? InferUnion<T> | ||
: T extends { | ||
type: "token"; | ||
} | ||
? InferToken<T> | ||
: T extends { | ||
type: "ref"; | ||
} | ||
? InferRef<T> | ||
: T extends { | ||
type: "unknown"; | ||
} | ||
? unknown | ||
: T extends { | ||
type: "null"; | ||
} | ||
? null | ||
: T extends { | ||
type: "boolean"; | ||
} | ||
? boolean | ||
: T extends { | ||
type: "integer"; | ||
} | ||
? number | ||
: T extends { | ||
type: "string"; | ||
} | ||
? string | ||
: T extends { | ||
type: "bytes"; | ||
} | ||
? Uint8Array | ||
: T extends { | ||
type: "cid-link"; | ||
} | ||
? string | ||
: T extends { | ||
type: "blob"; | ||
} | ||
? Blob | ||
: never; | ||
type InferToken<T> = T extends { | ||
enum: readonly (infer U)[]; | ||
} | ||
? U | ||
: string; | ||
type GetRequired<T> = T extends { | ||
required: readonly (infer R)[]; | ||
} | ||
? R | ||
: never; | ||
type GetNullable<T> = T extends { | ||
nullable: readonly (infer N)[]; | ||
} | ||
? N | ||
: never; | ||
type InferObject< | ||
T, | ||
Nullable extends string = GetNullable<T> & string, | ||
Required extends string = GetRequired<T> & string, | ||
NullableAndRequired extends string = Required & Nullable & string, | ||
Normal extends string = "properties" extends keyof T | ||
? Exclude<keyof T["properties"], Required | Nullable> & string | ||
: never, | ||
> = Prettify< | ||
T extends { | ||
properties: infer P; | ||
} | ||
? { -readonly [K in Normal]?: InferType<P[K & keyof P]> } & { | ||
-readonly [K in Exclude<Required, NullableAndRequired>]-?: InferType< | ||
P[K & keyof P] | ||
>; | ||
} & { | ||
-readonly [K in Exclude<Nullable, NullableAndRequired>]?: InferType< | ||
P[K & keyof P] | ||
> | null; | ||
} & { | ||
-readonly [K in NullableAndRequired]: InferType<P[K & keyof P]> | null; | ||
} | ||
: {} | ||
>; | ||
type InferArray<T> = T extends { | ||
items: infer Items; | ||
} | ||
? InferType<Items>[] | ||
: never[]; | ||
type InferUnion<T> = T extends { | ||
refs: readonly (infer R)[]; | ||
} | ||
? R extends string | ||
? { | ||
$type: R; | ||
[key: string]: unknown; | ||
} | ||
: never | ||
: never; | ||
type InferRef<T> = T extends { | ||
ref: infer R; | ||
} | ||
? R extends string | ||
? { | ||
$type: R; | ||
[key: string]: unknown; | ||
} | ||
: unknown | ||
: unknown; | ||
type InferParams<T> = InferObject<T>; | ||
type InferRecord<T> = T extends { | ||
record: infer R; | ||
} | ||
? R extends { | ||
type: "object"; | ||
} | ||
? InferObject<R> | ||
: R extends { | ||
type: "union"; | ||
} | ||
? InferUnion<R> | ||
: unknown | ||
: unknown; | ||
/** | ||
* Recursively replaces stub references in a type with their actual definitions. | ||
* Detects circular references and missing references, returning string literal error messages. | ||
*/ | ||
type ReplaceRefsInType<T, Defs, Visited = never> = T extends { | ||
$type: `#${infer DefName}`; | ||
} | ||
? DefName extends keyof Defs | ||
? DefName extends Visited | ||
? `[Circular reference detected: #${DefName}]` | ||
: Prettify< | ||
ReplaceRefsInType<Defs[DefName], Defs, Visited | DefName> & { | ||
$type: T["$type"]; | ||
} | ||
> | ||
: `[Reference not found: #${DefName}]` | ||
: T extends Uint8Array | Blob | ||
? T | ||
: T extends readonly (infer Item)[] | ||
? ReplaceRefsInType<Item, Defs, Visited>[] | ||
: T extends object | ||
? T extends (...args: unknown[]) => unknown | ||
? T | ||
: { [K in keyof T]: ReplaceRefsInType<T[K], Defs, Visited> } | ||
: T; | ||
/** | ||
* Infers the TypeScript type for a lexicon namespace, returning only the 'main' definition | ||
* with all local refs (#user, #post, etc.) resolved to their actual types. | ||
*/ | ||
type Infer< | ||
T extends { | ||
id: string; | ||
defs: Record<string, unknown>; | ||
}, | ||
> = Prettify< | ||
"main" extends keyof T["defs"] | ||
? { | ||
$type: T["id"]; | ||
} & ReplaceRefsInType< | ||
InferType<T["defs"]["main"]>, | ||
{ [K in keyof T["defs"]]: InferType<T["defs"][K]> } | ||
> | ||
: never | ||
>; | ||
//#endregion | ||
export { GetNullable, GetRequired, Infer }; | ||
//# sourceMappingURL=infer.d.ts.map |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.