Compare commits

...

7 Commits

Author SHA1 Message Date
Trisha Lim
2cf7867e38 Add Gio to team page 2024-11-25 09:53:01 +00:00
Benjamin S. Leveritt
d020ee2825 Merge pull request #856 from garden-co/trishalim-jazz-522
API Reference: typography and spacing adjustments
2024-11-23 07:26:36 +00:00
Guido D'Orsi
e00489d8ee Merge pull request #865 from garden-co/fix/less-reads-on-known-state
chore(SyncStateSubscriptionManager): improve the internal API
2024-11-22 18:21:39 +01:00
Guido D'Orsi
5a5f886bdf chore: formatting 2024-11-22 18:20:41 +01:00
Guido D'Orsi
e5c575ec10 chore(SyncStateSubscriptionManager): improve the internal API 2024-11-22 18:18:44 +01:00
Trisha Lim
94e3922efc Adjust scroll margin in API Reference pages; fixes #830 2024-11-22 15:00:50 +00:00
Trisha Lim
a18ed077ca API Ref: make headings more prominent 2024-11-22 14:48:16 +00:00
9 changed files with 53 additions and 39 deletions

View File

@@ -69,6 +69,15 @@ const team: Array<TeamMember> = [
github: "marinoska",
image: "marina.jpeg",
},
{
name: "Giordano Ricci",
titles: ["Full-Stack Dev", "DevOps"],
location: "Lisbon, Portugal ",
linkedin: "giordanoricci",
github: "Elfo404",
website: "https://giordanoricci.com",
image: "gio.jpg",
},
];
function SocialLink({

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

View File

@@ -15,7 +15,7 @@ export default function Layout({
}) {
return (
<DocsLayout nav={<ApiNav />}>
<Prose className="py-8">{children}</Prose>
<Prose className="py-8 [&_*]:scroll-mt-[8rem]">{children}</Prose>
</DocsLayout>
);
}

View File

@@ -70,7 +70,11 @@ function RenderPackageChild({
return child.getAllSignatures().map((signature, i) => {
const paramTypes = printParamsWithTypes(signature);
return (
<div key={i} id={child.name} className="not-prose mt-4">
<div
key={i}
id={child.name}
className="not-prose mt-4 p-3 rounded bg-stone-50 dark:bg-stone-925"
>
{
<Highlight hide={[0, 2]}>
{`function \n${printSimpleSignature(child, signature) + ":"}\n {}`}
@@ -171,10 +175,7 @@ function RenderClassOrInterface({
</div>
)}
{classOrInterface.categories?.map((category) => (
<div
className="flex flex-col divide-y divide-stone-200 dark:divide-stone-900"
key={category.title}
>
<div className="flex flex-col mt-6 first:mt-0" key={category.title}>
<PropCategory
name={category.title}
description={renderSummary(

View File

@@ -80,15 +80,15 @@ export function ClassOrInterface({
className="inline-flex items-center gap-2 lg:-ml-[22px]"
>
<LinkIcon size={14} className="hidden lg:inline" />
<h3>
<h3 className="text-lg lg:text-xl">
<Highlight>
{(isInterface ? "interface " : "class ") + name + typeParameters}
</Highlight>
</h3>
</Link>
</div>
<div className="flex flex-col gap-5">
<div>{doc}</div>
<div className="flex flex-col gap-5 mt-5">
{doc && <div>{doc}</div>}
<div>{children}</div>
</div>
</div>
@@ -119,7 +119,7 @@ export function PropDecl({
example?: ReactNode;
}) {
return (
<div className="text-sm py-3 flex flex-col gap-5">
<div className="text-sm flex flex-col gap-3 my-2 p-3 rounded bg-stone-50 dark:bg-stone-925">
{(name || type) && (
<div>
{name && <Highlight>{name + ":"}</Highlight>}
@@ -157,7 +157,7 @@ export function FnDecl({
example: ReactNode;
}) {
return (
<div className="text-sm py-3 flex flex-col gap-5">
<div className="text-sm flex flex-col gap-3 my-2 p-3 rounded bg-stone-50 dark:bg-stone-925">
<div className="flex flex-col gap-2">
<div>
{<Highlight>{signature + ":"}</Highlight>}{" "}
@@ -201,7 +201,7 @@ export function PropCategory({
}) {
return (
<>
<div className="col-span-6 uppercase font-medium tracking-widest text-stone-500 text-xs py-3">
<div className="col-span-6 py-3 font-display font-semibold text-lg text-stone-900 dark:text-white">
{name}
</div>
{description && <PropDecl doc={description} example={example} />}

View File

@@ -6,15 +6,19 @@ import {
emptyKnownState,
} from "./sync.js";
export type SyncStateGetter = {
isUploaded: boolean;
};
export type GlobalSyncStateListenerCallback = (
peerId: PeerID,
knownState: CoValueKnownState,
getIsUploadCompleted: () => boolean,
sync: SyncStateGetter,
) => void;
export type PeerSyncStateListenerCallback = (
knownState: CoValueKnownState,
getIsUploadCompleted: () => boolean,
sync: SyncStateGetter,
) => void;
export class SyncStateSubscriptionManager {
@@ -66,18 +70,29 @@ export class SyncStateSubscriptionManager {
}
const knownState = peer.knownStates.get(id) ?? emptyKnownState(id);
const getIsCoValueFullyUploadedIntoPeer = simpleMemoize(() =>
// Build a lazy sync state object to process the isUploaded info
// only when requested
const syncState = {} as SyncStateGetter;
const getIsUploaded = simpleMemoize(() =>
this.getIsCoValueFullyUploadedIntoPeer(peerId, id),
);
Object.defineProperties(syncState, {
isUploaded: {
enumerable: true,
get: getIsUploaded,
},
});
for (const listener of this.listeners) {
listener(peerId, knownState, getIsCoValueFullyUploadedIntoPeer);
listener(peerId, knownState, syncState);
}
if (!peerListeners) return;
for (const listener of peerListeners) {
listener(knownState, getIsCoValueFullyUploadedIntoPeer);
listener(knownState, syncState);
}
}

View File

@@ -164,7 +164,7 @@ export class CoValueCore {
return {
id: this.id,
header: true,
sessions
sessions,
};
}

View File

@@ -718,8 +718,8 @@ export class SyncManager {
const unsubscribe =
this.syncStateSubscriptionManager.subscribeToPeerUpdates(
peerId,
(knownState, getIsUploadCompleted) => {
if (getIsUploadCompleted() && knownState.id === id) {
(knownState, syncState) => {
if (syncState.isUploaded && knownState.id === id) {
resolve(true);
unsubscribe?.();
}

View File

@@ -33,9 +33,7 @@ describe("SyncStateSubscriptionManager", () => {
const subscriptionManager = client.syncManager.syncStateSubscriptionManager;
const updateSpy: GlobalSyncStateListenerCallback = vi
.fn()
.mockImplementation((_, __, isUploaded) => isUploaded());
const updateSpy: GlobalSyncStateListenerCallback = vi.fn();
const unsubscribe = subscriptionManager.subscribeToUpdates(updateSpy);
await client.syncManager.actuallySyncCoValue(map.core);
@@ -43,9 +41,8 @@ describe("SyncStateSubscriptionManager", () => {
expect(updateSpy).toHaveBeenCalledWith(
"jazzCloudConnection",
emptyKnownState(map.core.id),
expect.any(Function),
{ isUploaded: false },
);
expect(updateSpy).toHaveLastReturnedWith(false);
await waitFor(() => {
return subscriptionManager.getIsCoValueFullyUploadedIntoPeer(
@@ -59,9 +56,8 @@ describe("SyncStateSubscriptionManager", () => {
client.syncManager.peers["jazzCloudConnection"]!.knownStates.get(
map.core.id,
)!,
expect.any(Function),
{ isUploaded: true },
);
expect(updateSpy).toHaveLastReturnedWith(true);
// Cleanup
unsubscribe();
@@ -98,12 +94,8 @@ describe("SyncStateSubscriptionManager", () => {
const subscriptionManager = client.syncManager.syncStateSubscriptionManager;
const updateToJazzCloudSpy: PeerSyncStateListenerCallback = vi
.fn()
.mockImplementation((_, isUploaded) => isUploaded());
const updateToStorageSpy: PeerSyncStateListenerCallback = vi
.fn()
.mockImplementation((_, isUploaded) => isUploaded());
const updateToJazzCloudSpy: PeerSyncStateListenerCallback = vi.fn();
const updateToStorageSpy: PeerSyncStateListenerCallback = vi.fn();
const unsubscribe1 = subscriptionManager.subscribeToPeerUpdates(
"jazzCloudConnection",
updateToJazzCloudSpy,
@@ -122,9 +114,8 @@ describe("SyncStateSubscriptionManager", () => {
expect(updateToJazzCloudSpy).toHaveBeenCalledWith(
emptyKnownState(map.core.id),
expect.any(Function),
{ isUploaded: false },
);
expect(updateToJazzCloudSpy).toHaveLastReturnedWith(false);
await waitFor(() => {
return subscriptionManager.getIsCoValueFullyUploadedIntoPeer(
@@ -137,15 +128,13 @@ describe("SyncStateSubscriptionManager", () => {
client.syncManager.peers["jazzCloudConnection"]!.knownStates.get(
map.core.id,
)!,
expect.any(Function),
{ isUploaded: true },
);
expect(updateToJazzCloudSpy).toHaveLastReturnedWith(true);
expect(updateToStorageSpy).toHaveBeenLastCalledWith(
emptyKnownState(map.core.id),
expect.any(Function),
{ isUploaded: false },
);
expect(updateToStorageSpy).toHaveLastReturnedWith(false);
});
test("getIsCoValueFullyUploadedIntoPeer returns correct status", async () => {