···7import { email_subscriptions_to_entity } from "drizzle/schema";
8import postgres from "postgres";
9import { getBlocksWithTypeLocal } from "src/hooks/queries/useBlocks";
10-import { Fact, PermissionToken } from "src/replicache";
11-import { Attributes } from "src/replicache/attributes";
12import { Database } from "supabase/database.types";
13import * as Y from "yjs";
14import { YJSFragmentToString } from "components/Blocks/TextBlock/RenderYJSFragment";
···90 let { data } = await supabase.rpc("get_facts", {
91 root: root_entity,
92 });
93- let initialFacts = (data as unknown as Fact<keyof typeof Attributes>[]) || [];
94 let firstPage = initialFacts.find((f) => f.attribute === "root/page") as
95 | Fact<"root/page">
96 | undefined;
···7import { email_subscriptions_to_entity } from "drizzle/schema";
8import postgres from "postgres";
9import { getBlocksWithTypeLocal } from "src/hooks/queries/useBlocks";
10+import type { Fact, PermissionToken } from "src/replicache";
11+import type { Attribute } from "src/replicache/attributes";
12import { Database } from "supabase/database.types";
13import * as Y from "yjs";
14import { YJSFragmentToString } from "components/Blocks/TextBlock/RenderYJSFragment";
···90 let { data } = await supabase.rpc("get_facts", {
91 root: root_entity,
92 });
93+ let initialFacts = (data as unknown as Fact<Attribute>[]) || [];
94 let firstPage = initialFacts.find((f) => f.attribute === "root/page") as
95 | Fact<"root/page">
96 | undefined;
+2-2
app/[leaflet_id]/Leaflet.tsx
···1"use client";
2import { Fact, PermissionToken, ReplicacheProvider } from "src/replicache";
3-import { Attributes } from "src/replicache/attributes";
4import { SelectionManager } from "components/SelectionManager";
5import { Pages } from "components/Pages";
6import {
···1617export function Leaflet(props: {
18 token: PermissionToken;
19- initialFacts: Fact<keyof typeof Attributes>[];
20 leaflet_id: string;
21}) {
22 return (
···1"use client";
2import { Fact, PermissionToken, ReplicacheProvider } from "src/replicache";
3+import type { Attribute } from "src/replicache/attributes";
4import { SelectionManager } from "components/SelectionManager";
5import { Pages } from "components/Pages";
6import {
···1617export function Leaflet(props: {
18 token: PermissionToken;
19+ initialFacts: Fact<Attribute>[];
20 leaflet_id: string;
21}) {
22 return (
+3-4
app/[leaflet_id]/icon.tsx
···1import { ImageResponse } from "next/og";
2-import { Fact } from "src/replicache";
3-import { Attributes } from "src/replicache/attributes";
4import { Database } from "../../supabase/database.types";
5import { createServerClient } from "@supabase/ssr";
6import { parseHSBToRGB } from "src/utils/parseHSB";
···36 let { data } = await supabase.rpc("get_facts", {
37 root: rootEntity,
38 });
39- let initialFacts =
40- (data as unknown as Fact<keyof typeof Attributes>[]) || [];
41 let themePageBG = initialFacts.find(
42 (f) => f.attribute === "theme/card-background",
43 ) as Fact<"theme/card-background"> | undefined;
···1import { ImageResponse } from "next/og";
2+import type { Fact } from "src/replicache";
3+import type { Attribute } from "src/replicache/attributes";
4import { Database } from "../../supabase/database.types";
5import { createServerClient } from "@supabase/ssr";
6import { parseHSBToRGB } from "src/utils/parseHSB";
···36 let { data } = await supabase.rpc("get_facts", {
37 root: rootEntity,
38 });
39+ let initialFacts = (data as unknown as Fact<Attribute>[]) || [];
040 let themePageBG = initialFacts.find(
41 (f) => f.attribute === "theme/card-background",
42 ) as Fact<"theme/card-background"> | undefined;
+4-4
app/[leaflet_id]/page.tsx
···2import * as Y from "yjs";
3import * as base64 from "base64-js";
45-import { Fact } from "src/replicache";
6-import { Attributes } from "src/replicache/attributes";
7import { YJSFragmentToString } from "components/Blocks/TextBlock/RenderYJSFragment";
8import { Leaflet } from "./Leaflet";
9import { scanIndexLocal } from "src/replicache/utils";
···53 getRSVPData(res.data.permission_token_rights.map((ptr) => ptr.entity_set)),
54 getPollData(res.data.permission_token_rights.map((ptr) => ptr.entity_set)),
55 ]);
56- let initialFacts = (data as unknown as Fact<keyof typeof Attributes>[]) || [];
57 return (
58 <PageSWRDataProvider
59 rsvp_data={rsvp_data}
···81 let { data } = await supabaseServerClient.rpc("get_facts", {
82 root: rootEntity,
83 });
84- let initialFacts = (data as unknown as Fact<keyof typeof Attributes>[]) || [];
85 let scan = scanIndexLocal(initialFacts);
86 let firstPage =
87 scan.eav(rootEntity, "root/page")[0]?.data.value || rootEntity;
···2import * as Y from "yjs";
3import * as base64 from "base64-js";
45+import type { Fact } from "src/replicache";
6+import type { Attribute } from "src/replicache/attributes";
7import { YJSFragmentToString } from "components/Blocks/TextBlock/RenderYJSFragment";
8import { Leaflet } from "./Leaflet";
9import { scanIndexLocal } from "src/replicache/utils";
···53 getRSVPData(res.data.permission_token_rights.map((ptr) => ptr.entity_set)),
54 getPollData(res.data.permission_token_rights.map((ptr) => ptr.entity_set)),
55 ]);
56+ let initialFacts = (data as unknown as Fact<Attribute>[]) || [];
57 return (
58 <PageSWRDataProvider
59 rsvp_data={rsvp_data}
···81 let { data } = await supabaseServerClient.rpc("get_facts", {
82 root: rootEntity,
83 });
84+ let initialFacts = (data as unknown as Fact<Attribute>[]) || [];
85 let scan = scanIndexLocal(initialFacts);
86 let firstPage =
87 scan.eav(rootEntity, "root/page")[0]?.data.value || rootEntity;
+4-6
app/api/rpc/[command]/getFactsFromHomeLeaflets.ts
···1import { z } from "zod";
2-import { Fact } from "src/replicache";
3-import { Attributes } from "src/replicache/attributes";
4import { makeRoute } from "../lib";
5import { Env } from "./route";
6···20 result: all_facts.data.reduce(
21 (acc, fact) => {
22 if (!acc[fact.root_id]) acc[fact.root_id] = [];
23- acc[fact.root_id].push(
24- fact as unknown as Fact<keyof typeof Attributes>,
25- );
26 return acc;
27 },
28- {} as { [key: string]: Fact<keyof typeof Attributes>[] },
29 ),
30 };
31 }
···1import { z } from "zod";
2+import type { Fact } from "src/replicache";
3+import type { Attribute } from "src/replicache/attributes";
4import { makeRoute } from "../lib";
5import { Env } from "./route";
6···20 result: all_facts.data.reduce(
21 (acc, fact) => {
22 if (!acc[fact.root_id]) acc[fact.root_id] = [];
23+ acc[fact.root_id].push(fact as unknown as Fact<Attribute>);
0024 return acc;
25 },
26+ {} as { [key: string]: Fact<Attribute>[] },
27 ),
28 };
29 }
+3-5
app/api/rpc/[command]/pull.ts
···4 PullResponseV1,
5 VersionNotSupportedResponse,
6} from "replicache";
7-import { Fact } from "src/replicache";
8import { FactWithIndexes } from "src/replicache/utils";
9-import { Attributes } from "src/replicache/attributes";
10import { makeRoute } from "../lib";
11import { Env } from "./route";
12···95 return {
96 op: "put",
97 key: f.id,
98- value: FactWithIndexes(
99- f as unknown as Fact<keyof typeof Attributes>,
100- ),
101 } as const;
102 }),
103 ],
···4 PullResponseV1,
5 VersionNotSupportedResponse,
6} from "replicache";
7+import type { Fact } from "src/replicache";
8import { FactWithIndexes } from "src/replicache/utils";
9+import type { Attributes } from "src/replicache/attributes";
10import { makeRoute } from "../lib";
11import { Env } from "./route";
12···95 return {
96 op: "put",
97 key: f.id,
98+ value: FactWithIndexes(f as unknown as Fact<Attribute>),
0099 } as const;
100 }),
101 ],
+2-2
app/home/LeafletList.tsx
···6import { Fact, ReplicacheProvider } from "src/replicache";
7import { LeafletPreview } from "./LeafletPreview";
8import { useIdentityData } from "components/IdentityProvider";
9-import { Attributes } from "src/replicache/attributes";
10import { getIdentityData } from "actions/getIdentityData";
11import { callRPC } from "app/api/rpc/client";
1213export function LeafletList(props: {
14 initialFacts: {
15- [root_entity: string]: Fact<keyof typeof Attributes>[];
16 };
17}) {
18 let { data: localLeaflets } = useSWR("leaflets", () => getHomeDocs(), {
···6import { Fact, ReplicacheProvider } from "src/replicache";
7import { LeafletPreview } from "./LeafletPreview";
8import { useIdentityData } from "components/IdentityProvider";
9+import type { Attribute } from "src/replicache/attributes";
10import { getIdentityData } from "actions/getIdentityData";
11import { callRPC } from "app/api/rpc/client";
1213export function LeafletList(props: {
14 initialFacts: {
15+ [root_entity: string]: Fact<Attribute>[];
16 };
17}) {
18 let { data: localLeaflets } = useSWR("leaflets", () => getHomeDocs(), {
+1-1
app/home/LeafletOptions.tsx
···1"use client";
23import { Menu, MenuItem } from "components/Layout";
4-import { PermissionToken } from "src/replicache";
5import { hideDoc } from "./storage";
6import { useState } from "react";
7import { ButtonPrimary } from "components/Buttons";
···1"use client";
23import { Menu, MenuItem } from "components/Layout";
4+import type { PermissionToken } from "src/replicache";
5import { hideDoc } from "./storage";
6import { useState } from "react";
7import { ButtonPrimary } from "components/Buttons";
+5-6
app/home/icon.tsx
···1import { ImageResponse } from "next/og";
2-import { Fact } from "src/replicache";
3-import { Attributes } from "src/replicache/attributes";
4import { Database } from "../../supabase/database.types";
5import { createServerClient } from "@supabase/ssr";
6import { parseHSBToRGB } from "src/utils/parseHSB";
···49 let { data } = await supabase.rpc("get_facts", {
50 root: rootEntity,
51 });
52- let initialFacts =
53- (data as unknown as Fact<keyof typeof Attributes>[]) || [];
54 let themePageBG = initialFacts.find(
55 (f) => f.attribute === "theme/card-background",
56 ) as Fact<"theme/card-background"> | undefined;
···67 return new ImageResponse(
68 (
69 // ImageResponse JSX element
70- (<div style={{ display: "flex" }}>
71 <svg
72 width="32"
73 height="32"
···91 fill={fillColor ? fillColor : "#272727"}
92 />
93 </svg>
94- </div>)
95 ),
96 // ImageResponse options
97 {
···1import { ImageResponse } from "next/og";
2+import type { Fact } from "src/replicache";
3+import type { Attribute } from "src/replicache/attributes";
4import { Database } from "../../supabase/database.types";
5import { createServerClient } from "@supabase/ssr";
6import { parseHSBToRGB } from "src/utils/parseHSB";
···49 let { data } = await supabase.rpc("get_facts", {
50 root: rootEntity,
51 });
52+ let initialFacts = (data as unknown as Fact<Attribute>[]) || [];
053 let themePageBG = initialFacts.find(
54 (f) => f.attribute === "theme/card-background",
55 ) as Fact<"theme/card-background"> | undefined;
···66 return new ImageResponse(
67 (
68 // ImageResponse JSX element
69+ <div style={{ display: "flex" }}>
70 <svg
71 width="32"
72 height="32"
···90 fill={fillColor ? fillColor : "#272727"}
91 />
92 </svg>
93+ </div>
94 ),
95 // ImageResponse options
96 {
+2-2
app/home/page.tsx
···1import { cookies } from "next/headers";
2import { Fact, ReplicacheProvider } from "src/replicache";
3-import { Attributes } from "src/replicache/attributes";
4import {
5 ThemeBackgroundProvider,
6 ThemeProvider,
···76 : undefined,
77 ]);
78 let initialFacts =
79- (homeLeafletFacts.data as unknown as Fact<keyof typeof Attributes>[]) || [];
8081 let root_entity = permission_token.root_entity;
82 let home_docs_initialFacts = allLeafletFacts?.result || {};
···1import { cookies } from "next/headers";
2import { Fact, ReplicacheProvider } from "src/replicache";
3+import type { Attribute } from "src/replicache/attributes";
4import {
5 ThemeBackgroundProvider,
6 ThemeProvider,
···76 : undefined,
77 ]);
78 let initialFacts =
79+ (homeLeafletFacts.data as unknown as Fact<Attribute>[]) || [];
8081 let root_entity = permission_token.root_entity;
82 let home_docs_initialFacts = allLeafletFacts?.result || {};
+1-1
app/home/storage.ts
···1-import { PermissionToken } from "src/replicache";
2import { mutate } from "swr";
34export type HomeDoc = {
···1+import type { PermissionToken } from "src/replicache";
2import { mutate } from "swr";
34export type HomeDoc = {
-1
app/lish/[handle]/[publication]/DraftList.tsx
···1"use client";
23-import { Fact, ReplicacheProvider } from "src/replicache";
4import { usePublicationRelationship } from "./usePublicationRelationship";
5import { usePublicationContext } from "components/Providers/PublicationContext";
6import Link from "next/link";
···1"use client";
203import { usePublicationRelationship } from "./usePublicationRelationship";
4import { usePublicationContext } from "components/Providers/PublicationContext";
5import Link from "next/link";
+5-6
app/templates/icon.tsx
···2// we could make it different so it's clear it's not your personal colors?
34import { ImageResponse } from "next/og";
5-import { Fact } from "src/replicache";
6-import { Attributes } from "src/replicache/attributes";
7import { Database } from "../../supabase/database.types";
8import { createServerClient } from "@supabase/ssr";
9import { parseHSBToRGB } from "src/utils/parseHSB";
···52 let { data } = await supabase.rpc("get_facts", {
53 root: rootEntity,
54 });
55- let initialFacts =
56- (data as unknown as Fact<keyof typeof Attributes>[]) || [];
57 let themePageBG = initialFacts.find(
58 (f) => f.attribute === "theme/card-background",
59 ) as Fact<"theme/card-background"> | undefined;
···70 return new ImageResponse(
71 (
72 // ImageResponse JSX element
73- (<div style={{ display: "flex" }}>
74 <svg
75 width="32"
76 height="32"
···94 fill={fillColor ? fillColor : "#272727"}
95 />
96 </svg>
97- </div>)
98 ),
99 // ImageResponse options
100 {
···2// we could make it different so it's clear it's not your personal colors?
34import { ImageResponse } from "next/og";
5+import type { Fact } from "src/replicache";
6+import type { Attribute } from "src/replicache/attributes";
7import { Database } from "../../supabase/database.types";
8import { createServerClient } from "@supabase/ssr";
9import { parseHSBToRGB } from "src/utils/parseHSB";
···52 let { data } = await supabase.rpc("get_facts", {
53 root: rootEntity,
54 });
55+ let initialFacts = (data as unknown as Fact<Attribute>[]) || [];
056 let themePageBG = initialFacts.find(
57 (f) => f.attribute === "theme/card-background",
58 ) as Fact<"theme/card-background"> | undefined;
···69 return new ImageResponse(
70 (
71 // ImageResponse JSX element
72+ <div style={{ display: "flex" }}>
73 <svg
74 width="32"
75 height="32"
···93 fill={fillColor ? fillColor : "#272727"}
94 />
95 </svg>
96+ </div>
97 ),
98 // ImageResponse options
99 {
+1-1
components/Blocks/BlockCommands.tsx
···1-import { Fact, ReplicacheMutators } from "src/replicache";
2import { useUIState } from "src/useUIState";
34import { generateKeyBetween } from "fractional-indexing";
···1+import type { Fact, ReplicacheMutators } from "src/replicache";
2import { useUIState } from "src/useUIState";
34import { generateKeyBetween } from "fractional-indexing";
+1-1
components/Blocks/TextBlock/inputRules.ts
···5} from "prosemirror-inputrules";
6import { MutableRefObject } from "react";
7import { Replicache } from "replicache";
8-import { ReplicacheMutators } from "src/replicache";
9import { BlockProps } from "../Block";
10import { focusBlock } from "src/utils/focusBlock";
11import { schema } from "./schema";
···5} from "prosemirror-inputrules";
6import { MutableRefObject } from "react";
7import { Replicache } from "replicache";
8+import type { ReplicacheMutators } from "src/replicache";
9import { BlockProps } from "../Block";
10import { focusBlock } from "src/utils/focusBlock";
11import { schema } from "./schema";
+1-1
components/Blocks/TextBlock/keymap.ts
···12} from "prosemirror-state";
13import { RefObject } from "react";
14import { Replicache } from "replicache";
15-import { ReplicacheMutators } from "src/replicache";
16import { elementId } from "src/utils/elementId";
17import { schema } from "./schema";
18import { useUIState } from "src/useUIState";
···12} from "prosemirror-state";
13import { RefObject } from "react";
14import { Replicache } from "replicache";
15+import type { ReplicacheMutators } from "src/replicache";
16import { elementId } from "src/utils/elementId";
17import { schema } from "./schema";
18import { useUIState } from "src/useUIState";
+1-1
components/Blocks/TextBlock/useHandlePaste.ts
···14import { markdownToHtml } from "src/htmlMarkdownParsers";
15import { betterIsUrl, isUrl } from "src/utils/isURL";
16import { TextSelection } from "prosemirror-state";
17-import { FilterAttributes } from "src/replicache/attributes";
18import { addLinkBlock } from "src/utils/addLinkBlock";
19import { UndoManager } from "src/undoManager";
20
···14import { markdownToHtml } from "src/htmlMarkdownParsers";
15import { betterIsUrl, isUrl } from "src/utils/isURL";
16import { TextSelection } from "prosemirror-state";
17+import type { FilterAttributes } from "src/replicache/attributes";
18import { addLinkBlock } from "src/utils/addLinkBlock";
19import { UndoManager } from "src/undoManager";
20
···77 },
78 async assertFact(f) {
79 if (!f.entity) return;
80- let attribute = Attributes[f.attribute as keyof typeof Attributes];
81 if (!attribute) return;
82 let id = f.id || v7();
83 let data = { ...f.data };
···77 },
78 async assertFact(f) {
79 if (!f.entity) return;
80+ let attribute = Attributes[f.attribute as Attribute];
81 if (!attribute) return;
82 let id = f.id || v7();
83 let data = { ...f.data };
···1import { PostgresJsDatabase } from "drizzle-orm/postgres-js";
2import * as driz from "drizzle-orm";
3+import type { Fact } from ".";
4import { replicache_clients } from "drizzle/schema";
5+import type { Attribute, FilterAttributes } from "./attributes";
6import { ReadTransaction, WriteTransaction } from "replicache";
78+export function FactWithIndexes(f: Fact<Attribute>) {
9 let indexes: {
10 eav: string;
11 aev: string;
···42}
4344export const scanIndex = (tx: ReadTransaction) => ({
45+ async eav<A extends Attribute>(entity: string, attribute: A | "") {
00046 return (
47 (
48 await tx
···66});
6768export const scanIndexLocal = (initialFacts: Fact<any>[]) => ({
69+ eav<A extends Attribute>(entity: string, attribute: A) {
70 return initialFacts.filter(
71 (f) => f.entity === entity && f.attribute === attribute,
72 ) as Fact<A>[];
+1-1
src/utils/addImage.ts
···1import { Replicache } from "replicache";
2import { ReplicacheMutators } from "../replicache";
3import { supabaseBrowserClient } from "supabase/browserClient";
4-import { FilterAttributes } from "src/replicache/attributes";
5import { rgbaToDataURL, rgbaToThumbHash, thumbHashToDataURL } from "thumbhash";
6import { v7 } from "uuid";
7
···1import { Replicache } from "replicache";
2import { ReplicacheMutators } from "../replicache";
3import { supabaseBrowserClient } from "supabase/browserClient";
4+import type { FilterAttributes } from "src/replicache/attributes";
5import { rgbaToDataURL, rgbaToThumbHash, thumbHashToDataURL } from "thumbhash";
6import { v7 } from "uuid";
7
+1-1
src/utils/addLinkBlock.ts
···4 LinkPreviewMetadataResult,
5} from "app/api/link_previews/route";
6import { Replicache } from "replicache";
7-import { ReplicacheMutators } from "src/replicache";
8import { AtpAgent } from "@atproto/api";
9import { v7 } from "uuid";
10
···4 LinkPreviewMetadataResult,
5} from "app/api/link_previews/route";
6import { Replicache } from "replicache";
7+import type { ReplicacheMutators } from "src/replicache";
8import { AtpAgent } from "@atproto/api";
9import { v7 } from "uuid";
10
+1-1
src/utils/copySelection.ts
···1import { getBlocksAsHTML } from "src/utils/getBlocksAsHTML";
2import { htmlToMarkdown } from "src/htmlMarkdownParsers";
3import { Replicache } from "replicache";
4-import { ReplicacheMutators } from "src/replicache";
5import { Block } from "components/Blocks/Block";
67export async function copySelection(
···1import { getBlocksAsHTML } from "src/utils/getBlocksAsHTML";
2import { htmlToMarkdown } from "src/htmlMarkdownParsers";
3import { Replicache } from "replicache";
4+import type { ReplicacheMutators } from "src/replicache";
5import { Block } from "components/Blocks/Block";
67export async function copySelection(
+1-1
src/utils/getBlocksAsHTML.tsx
···1import { ReadTransaction, Replicache } from "replicache";
2-import { Fact, ReplicacheMutators } from "src/replicache";
3import { scanIndex } from "src/replicache/utils";
4import { renderToStaticMarkup } from "react-dom/server";
5import * as Y from "yjs";
···1import { ReadTransaction, Replicache } from "replicache";
2+import type { Fact, ReplicacheMutators } from "src/replicache";
3import { scanIndex } from "src/replicache/utils";
4import { renderToStaticMarkup } from "react-dom/server";
5import * as Y from "yjs";
+1-1
src/utils/list-operations.ts
···1import { Block } from "components/Blocks/Block";
2import { Replicache } from "replicache";
3-import { ReplicacheMutators } from "src/replicache";
4import { useUIState } from "src/useUIState";
5import { v7 } from "uuid";
6
···1import { Block } from "components/Blocks/Block";
2import { Replicache } from "replicache";
3+import type { ReplicacheMutators } from "src/replicache";
4import { useUIState } from "src/useUIState";
5import { v7 } from "uuid";
6