Skip to content

Commit

Permalink
Update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
steida committed May 3, 2024
1 parent 66c8587 commit e499e71
Show file tree
Hide file tree
Showing 15 changed files with 6,174 additions and 4,975 deletions.
10 changes: 5 additions & 5 deletions components/Carousel.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as S from "@effect/schema/Schema";
import { StyleXStyles, create, props } from "@stylexjs/stylex";
import { Number, ReadonlyArray } from "effect";
import { Array, Number } from "effect";
import {
ReactNode,
forwardRef,
Expand All @@ -16,8 +16,8 @@ import {
NativeSyntheticEvent,
ScrollView,
} from "react-native";
import { RNfW } from "../lib/Types";
import { Temporal } from "temporal-polyfill";
import { RNfW } from "../lib/Types";

// TODO: Accessibility.
// https://www.w3.org/WAI/ARIA/apg/patterns/carousel/
Expand All @@ -30,7 +30,7 @@ export interface CarouselRef {
isCentered: () => boolean;
}

export const CarouselOffset = S.number.pipe(S.int(), S.brand("CarouselOffset"));
export const CarouselOffset = S.Number.pipe(S.int(), S.brand("CarouselOffset"));
export type CarouselOffset = S.Schema.Type<typeof CarouselOffset>;

export const decodeSyncCarouselOffset = S.decodeSync(CarouselOffset);
Expand Down Expand Up @@ -176,10 +176,10 @@ export const Carousel = forwardRef<CarouselRef, CarouselProps>(
[diffOffset, infinityOffset, onSnap],
);

const offsetsRef = useRef<ReadonlyArray<number>>([]);
const offsetsRef = useRef<Array<number>>([]);
const getOffsets = () => {
if (offsetsRef.current.length === 0)
offsetsRef.current = ReadonlyArray.makeBy(
offsetsRef.current = Array.makeBy(
totalSnapCountRef.current,
(i) => i - snapCountRef.current,
);
Expand Down
4 changes: 2 additions & 2 deletions components/DatePopover.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { create } from "@stylexjs/stylex";
import { ReadonlyArray } from "effect";
import { Array } from "effect";
import { FC, memo, useCallback, useContext, useRef, useState } from "react";
import { Temporal } from "temporal-polyfill";
import { colors, consts, spacing } from "../lib/Tokens.stylex";
Expand Down Expand Up @@ -102,7 +102,7 @@ const Dates = memo<{

return (
<WeekGrid forMonth>
{ReadonlyArray.makeBy(offsetDate.daysInMonth, (i) => {
{Array.makeBy(offsetDate.daysInMonth, (i) => {
const day = offsetDate.with({ day: i + 1 });
const isSelected = day.equals(date);
return (
Expand Down
2 changes: 1 addition & 1 deletion components/Day.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const Layout: FC = () => (
<RouterQuery schema={DayProps} render={(props) => <Day {...props} />} />
);

const DayProps = S.struct({ date: S.optional(PlainDateFromUrlString) });
const DayProps = S.Struct({ date: S.optional(PlainDateFromUrlString) });
type DayProps = S.Schema.Type<typeof DayProps>;

const Day: FC<DayProps> = ({ date: _date }) => {
Expand Down
4 changes: 2 additions & 2 deletions components/DayHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { create, keyframes, props } from "@stylexjs/stylex";
import { ReadonlyArray, identity } from "effect";
import { Array, identity } from "effect";
import { memo, useCallback, useContext, useLayoutEffect, useRef } from "react";
import { Temporal } from "temporal-polyfill";
import { atDistance, colors, spacing, transitions } from "../lib/Tokens.stylex";
Expand Down Expand Up @@ -58,7 +58,7 @@ const Dates = memo<{
const today = useContext(NowContext).plainDateISO();
const intl = useContext(IntlContext);
const startOfWeek = intl.startOfWeek(date).add({ weeks: offset });
const days = ReadonlyArray.makeBy(7, identity).map((n) =>
const days = Array.makeBy(7, identity).map((n) =>
startOfWeek.add({ days: n }),
);

Expand Down
8 changes: 4 additions & 4 deletions components/DayNotes.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ExtractRow, NotNull, cast, useQuery } from "@evolu/react";
import { create, props } from "@stylexjs/stylex";
import { ReadonlyArray, pipe } from "effect";
import { Array, pipe } from "effect";
import { FC, memo, useMemo, useState } from "react";
import { Temporal } from "temporal-polyfill";
import { evolu } from "../lib/Db";
Expand Down Expand Up @@ -80,10 +80,10 @@ export const DayNotes: FC<{
}),
),
// Overlapping notes first, then startsBefore, then rest.
ReadonlyArray.partition((row) => row.startsBefore && row.endsAfter),
Array.partition((row) => row.startsBefore && row.endsAfter),
([rest, overlapping]) =>
overlapping.concat(
...ReadonlyArray.partition(rest, (row) => !row.startsBefore),
...Array.partition(rest, (row) => !row.startsBefore),
),
),
[castTemporal, endOfDay, rows, startOfDay],
Expand Down Expand Up @@ -181,7 +181,7 @@ const TimeButton: FC<{
);
};

// const Tags: FC<{ tags: ReadonlyArray<string> }> = ({ tags }) => {
// const Tags: FC<{ tags: Array<string> }> = ({ tags }) => {
// return (
// <div {...props(styles.tags)}>
// <EnsureBaseline style={styles.tagsEnsureBaseLine} />
Expand Down
8 changes: 4 additions & 4 deletions components/TimePopover.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Function, ReadonlyArray } from "effect";
import { Array, Function } from "effect";
import {
FC,
memo,
Expand All @@ -12,9 +12,9 @@ import { Formatted } from "./Formatted";
import {
WheelPicker,
WheelPickerItem,
wheelPickerItemStyles,
WheelPickerScrollView,
WheelPickerScrollViewRef,
wheelPickerItemStyles,
} from "./WheelPicker";

export const TimePopover: FC<{
Expand Down Expand Up @@ -110,7 +110,7 @@ const roundPlainTimeToNearestMultiple = (time: Temporal.PlainTime) => {
const Hours = memo<{
onPress: (hour: number) => void;
}>(function Hours({ onPress }) {
return ReadonlyArray.makeBy(24, Function.identity).map((hour) => (
return Array.makeBy(24, Function.identity).map((hour) => (
<WheelPickerItem
key={hour}
onPress={() => {
Expand All @@ -126,7 +126,7 @@ const Hours = memo<{
const Minutes = memo<{
onPress: (hour: number) => void;
}>(function Hours({ onPress }) {
return ReadonlyArray.makeBy(
return Array.makeBy(
60 / minuteRoundingMultiple,
(n) => n * minuteRoundingMultiple,
).map((minute) => (
Expand Down
4 changes: 2 additions & 2 deletions components/WeekDayGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { create } from "@stylexjs/stylex";
import { ReadonlyArray } from "effect";
import { Array } from "effect";
import { memo, useContext } from "react";
import { Temporal } from "temporal-polyfill";
import { colors, fontSizes, spacing } from "../lib/Tokens.stylex";
Expand All @@ -15,7 +15,7 @@ export const WeekDayGrid = memo<{ weekday: "narrow" | "short" }>(

return (
<WeekGrid>
{ReadonlyArray.makeBy(7, (i) => {
{Array.makeBy(7, (i) => {
const day = date.add({ days: i });
return (
<Text
Expand Down
6 changes: 3 additions & 3 deletions components/YearMonthPopover.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReadonlyArray } from "effect";
import { Array } from "effect";
import {
FC,
memo,
Expand Down Expand Up @@ -107,7 +107,7 @@ const Months = memo<{
onPress: (index: number) => void;
}>(function Months({ onPress }) {
const intl = useContext(IntlContext);
return ReadonlyArray.makeBy(12, (index) => {
return Array.makeBy(12, (index) => {
const date = Temporal.PlainDate.from({
year: 2024,
month: index + 1,
Expand Down Expand Up @@ -136,7 +136,7 @@ const yearsOffset = 10;
const Years = memo<{
onPress: (hour: number) => void;
}>(function Years({ onPress }) {
return ReadonlyArray.makeBy(100, (index) => (
return Array.makeBy(100, (index) => (
<WheelPickerItem
key={index}
onPress={() => {
Expand Down
11 changes: 6 additions & 5 deletions lib/Db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const NoteTable = table({
id: NoteId,
content: ContentMax10k,
start: SqliteDateTime,
end: S.nullable(SqliteDateTime),
end: S.NullOr(SqliteDateTime),
});
export type NoteTable = S.Schema.Type<typeof NoteTable>;

Expand All @@ -34,12 +34,13 @@ const Database = database({
});
export type Database = S.Schema.Type<typeof Database>;

const indexes = [
Evolu.createIndex("indexNoteStart").on("note").column("start"),
];
const indexes = Evolu.createIndexes((create) => [
create("indexNoteStart").on("note").column("start"),
]);

export const evolu = createEvolu(Database, {
name: "Evolu.me",
name: "EvoluMe",
indexes,
// minimumLogLevel: "trace",
});
export const useEvolu = Evolu.useEvolu<Database>;
60 changes: 29 additions & 31 deletions lib/Lexical.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import { EditorState } from "lexical";
// to ensure a valid Schema.
// In the future, NoteEditor will use its format based on Peritext.

const Node = S.struct({
version: S.literal(1),
const Node = S.Struct({
version: S.Literal(1),
});
type Node = S.Schema.Type<typeof Node>;

const Element = Node.pipe(
S.extend(
S.struct({
direction: S.nullable(S.literal("ltr", "rtl")),
format: S.literal(
S.Struct({
direction: S.NullOr(S.Literal("ltr", "rtl")),
format: S.Literal(
"left",
"start",
"center",
Expand All @@ -24,53 +24,53 @@ const Element = Node.pipe(
"justify",
"",
),
indent: S.number,
indent: S.Number,
}),
),
);
type Element = S.Schema.Type<typeof Element>;

export const Text = Node.pipe(
S.extend(
S.struct({
type: S.literal("text"),
detail: S.number,
format: S.number,
mode: S.literal("normal", "token", "segmented"),
style: S.string,
text: S.string,
S.Struct({
type: S.Literal("text"),
detail: S.Number,
format: S.Number,
mode: S.Literal("normal", "token", "segmented"),
style: S.String,
text: S.String,
}),
),
);
export type Text = S.Schema.Type<typeof Text>;

export const LineBreak = Node.pipe(
S.extend(
S.struct({
type: S.literal("linebreak"),
S.Struct({
type: S.Literal("linebreak"),
}),
),
);
export type LineBreak = S.Schema.Type<typeof LineBreak>;

export const Paragraph = Element.pipe(
S.extend(
S.struct({
type: S.literal("paragraph"),
children: S.array(S.union(Text, LineBreak)),
S.Struct({
type: S.Literal("paragraph"),
children: S.Array(S.Union(Text, LineBreak)),
}),
),
);
export type Paragraph = S.Schema.Type<typeof Paragraph>;

export const Root = Element.pipe(
S.extend(
S.struct({
type: S.literal("root"),
S.Struct({
type: S.Literal("root"),
// It's mutable in Lexical, so it must be here as well.
// The array must be non-empty. Lexical can work with empty,
// but when a text is pasted, it fails with some error.
children: S.mutable(S.nonEmptyArray(Paragraph)),
children: S.mutable(S.NonEmptyArray(Paragraph)),
}),
),
);
Expand All @@ -85,9 +85,9 @@ export const rootsAreEqual = (root1: Root, root2: Root): boolean =>
* local-only tables because it can be huge. For the final state, use
* ContentMax10k.
*/
export const Content = S.struct({
_tag: S.literal("Content"),
version: S.literal(1),
export const Content = S.Struct({
_tag: S.Literal("Content"),
version: S.Literal(1),
root: Root,
});
export type Content = S.Schema.Type<typeof Content>;
Expand All @@ -104,19 +104,17 @@ export const contentFromEditorState = (editorState: EditorState) =>
/** ContentMax10k is {@link Content} with `JSON.stringify(a).length <= 10000`. */
export const ContentMax10k = Content.pipe(
S.omit("_tag"),
S.extend(S.struct({ _tag: S.literal("ContentMax10k") })),
S.extend(S.Struct({ _tag: S.Literal("ContentMax10k") })),
S.filter((a) => JSON.stringify(a).length <= 10000, {
message: () => "JSON.stringify(a).length > 10000",
}),
);
export type ContentMax10k = S.Schema.Type<typeof ContentMax10k>;

export const ContentMax10kFromContent = S.transform(
Content,
ContentMax10k,
(a) => ({ ...a, _tag: "ContentMax10k" as const }),
(a) => ({ ...a, _tag: "Content" as const }),
);
export const ContentMax10kFromContent = S.transform(Content, ContentMax10k, {
decode: (a) => ({ ...a, _tag: "ContentMax10k" as const }),
encode: (a) => ({ ...a, _tag: "Content" as const }),
});

export const emptyRoot: Root = {
type: "root",
Expand Down
14 changes: 8 additions & 6 deletions lib/Routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ const PlainDateFromSelf = S.declare(isPlainDate).pipe(

/** Date in this format: 2024-06-01 */
export const PlainDateFromUrlString = S.transformOrFail(
S.string,
S.String,
PlainDateFromSelf,
(string, _, ast) =>
/^\d{4}-\d{2}-\d{2}$/.test(string)
? ParseResult.succeed(Temporal.PlainDate.from(string))
: ParseResult.fail(new ParseResult.Type(ast, string)),
(date) => ParseResult.succeed(date.toString()),
{
decode: (string, _, ast) =>
/^\d{4}-\d{2}-\d{2}$/.test(string)
? ParseResult.succeed(Temporal.PlainDate.from(string))
: ParseResult.fail(new ParseResult.Type(ast, string)),
encode: (date) => ParseResult.succeed(date.toString()),
},
);

export const getDayUrl = (
Expand Down
2 changes: 1 addition & 1 deletion lib/temporal/castTemporal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Temporal } from "temporal-polyfill";
// https://www.sqlite.org/lang_datefunc.html

/** To avoid a clash with the JavaScript Date SqliteDate type. */
const TemporalString = S.string.pipe(S.brand("TemporalString"));
const TemporalString = S.String.pipe(S.brand("TemporalString"));

/**
* UTC DateTime is stored in ISO 8601 format to ensure datetimes can be sorted
Expand Down
Loading

0 comments on commit e499e71

Please sign in to comment.