-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve bundle size with reader API in React server component environ…
…ments (#618)
- Loading branch information
Showing
53 changed files
with
177 additions
and
104 deletions.
There are no files selected for viewing
This file contains 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,5 @@ | ||
--- | ||
"@keystatic/core": patch | ||
--- | ||
|
||
Fixed bundle size increase when using `@keystatic/core/reader` with React server components |
This file contains 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 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
1 change: 1 addition & 0 deletions
1
packages/keystatic/src/component-blocks/blank-for-react-server.tsx
This file contains 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 @@ | ||
export function CloudImagePreview() {} |
2 changes: 0 additions & 2 deletions
2
packages/keystatic/src/component-blocks/cloud-image-preview.tsx
This file contains 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 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 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,32 @@ | ||
import { FieldDataError } from './fields/error'; | ||
import { PropValidationError } from './parse-props'; | ||
|
||
function flattenErrors(error: unknown): unknown[] { | ||
if (error instanceof AggregateError) { | ||
return error.errors.flatMap(flattenErrors); | ||
} | ||
return [error]; | ||
} | ||
|
||
export function formatFormDataError(error: unknown) { | ||
const flatErrors = flattenErrors(error); | ||
|
||
return flatErrors | ||
.map(error => { | ||
if (error instanceof PropValidationError) { | ||
const path = error.path.join('.'); | ||
return `${path}: ${ | ||
error.cause instanceof FieldDataError | ||
? error.cause.message | ||
: `Unexpected error: ${error.cause}` | ||
}`; | ||
} | ||
return `Unexpected error: ${error}`; | ||
}) | ||
.join('\n'); | ||
} | ||
|
||
export function toFormattedFormDataError(error: unknown) { | ||
const formatted = formatFormDataError(error); | ||
return new Error(`Field validation failed:\n` + formatted); | ||
} |
This file contains 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 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 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 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 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,21 @@ | ||
import { FormFieldInputProps } from '../../api'; | ||
import { Checkbox } from '@keystar/ui/checkbox'; | ||
import { Text } from '@keystar/ui/typography'; | ||
|
||
export function CheckboxFieldInput( | ||
props: FormFieldInputProps<boolean> & { | ||
label: string; | ||
description?: string; | ||
} | ||
) { | ||
return ( | ||
<Checkbox | ||
isSelected={props.value} | ||
onChange={props.onChange} | ||
autoFocus={props.autoFocus} | ||
> | ||
<Text>{props.label}</Text> | ||
{props.description && <Text slot="description">{props.description}</Text>} | ||
</Checkbox> | ||
); | ||
} |
This file contains 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 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 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 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 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 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
3 changes: 3 additions & 0 deletions
3
...s/keystatic/src/form/fields/document/DocumentEditor/primitives/blank-for-react-server.tsx
This file contains 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,3 @@ | ||
export function BlockWrapper() {} | ||
export function NotEditable() {} | ||
export function ToolbarSeparator() {} |
1 change: 0 additions & 1 deletion
1
packages/keystatic/src/form/fields/document/DocumentEditor/primitives/index.tsx
This file contains 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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
'use client'; | ||
export { | ||
ActiveBlockPopoverProvider, | ||
BlockPopover, | ||
|
This file contains 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 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 |
---|---|---|
@@ -1,5 +1,3 @@ | ||
'use client'; | ||
|
||
import { Field, FieldProps } from '@keystar/ui/field'; | ||
import { useState } from 'react'; | ||
|
||
|
This file contains 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,30 @@ | ||
// this is used in react-server environments to avoid bundling UI when the reader API is used | ||
// if you added a new field and get an error that there's missing a missing export here, | ||
// you probably just need to add another empty export here | ||
|
||
function empty() { | ||
throw new Error( | ||
"unexpected call to function that shouldn't be called in React server component environment" | ||
); | ||
} | ||
|
||
export let SlugFieldInput = empty, | ||
TextFieldInput = empty, | ||
UrlFieldInput = empty, | ||
SelectFieldInput = empty, | ||
RelationshipInput = empty, | ||
PathReferenceInput = empty, | ||
MultiselectFieldInput = empty, | ||
IntegerFieldInput = empty, | ||
ImageFieldInput = empty, | ||
FileFieldInput = empty, | ||
DatetimeFieldInput = empty, | ||
DateFieldInput = empty, | ||
CloudImageFieldInput = empty, | ||
BlocksFieldInput = empty, | ||
DocumentFieldInput = empty, | ||
CheckboxFieldInput = empty, | ||
createEditorSchema = empty, | ||
getDefaultValue = empty, | ||
parseToEditorState = empty, | ||
serializeFromEditorState = empty; |
This file contains 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 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 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 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 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 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
1 change: 0 additions & 1 deletion
1
packages/keystatic/src/form/fields/markdoc/editor/editor-state.tsx
This file contains 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
1 change: 0 additions & 1 deletion
1
packages/keystatic/src/form/fields/markdoc/editor/markdoc/parse.ts
This file contains 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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
'use client'; | ||
import { Ast, Node as MarkdocNode, ValidateError } from '@markdoc/markdoc'; | ||
import { | ||
Mark, | ||
|
1 change: 0 additions & 1 deletion
1
packages/keystatic/src/form/fields/markdoc/editor/markdoc/serialize.ts
This file contains 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
1 change: 0 additions & 1 deletion
1
packages/keystatic/src/form/fields/markdoc/editor/primitives/index.tsx
This file contains 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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
'use client'; | ||
export { BlockPopover } from './BlockPopover'; | ||
|
||
export * from './toolbar'; |
This file contains 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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
'use client'; | ||
import { css, tokenSchema } from '@keystar/ui/style'; | ||
import { | ||
DOMOutputSpec, | ||
|
Oops, something went wrong.
43f0b61
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
keystatic – ./dev-projects/next-app
keystatic-thinkmill-labs.vercel.app
keystatic-git-main-thinkmill-labs.vercel.app
keystatic.vercel.app
43f0b61
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
keystatic-site – ./docs
keystatic-site.vercel.app
keystatic-site-thinkmill-labs.vercel.app
keystatic.com
keystatic.thinkmill.com
www.keystatic.com
keystatic-site-git-main-thinkmill-labs.vercel.app
keystatic.thinkmill.com.au
43f0b61
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
keystar-ui – ./design-system/docs
keystar-ui.vercel.app
keystar-ui-git-main-thinkmill-labs.vercel.app
keystar-ui-thinkmill-labs.vercel.app
voussoir.vercel.app