Skip to content

Commit 88e82ba

Browse files
Merge upstream develop
2 parents 640a742 + f78a9b3 commit 88e82ba

45 files changed

Lines changed: 575 additions & 175 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ yarn-error.log*
3535

3636
dist
3737
services/server/data
38+
polycentric-blobs/
3839

3940
# Turborepo
4041
.turbo/

.gitlab/ci/deploy_app.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,18 @@ app-deploy-image-production:
4747
strategy: depend
4848
variables:
4949
MANIFEST_SETUP_COMMAND: quick
50-
MANIFEST_QUICK_TARGETS: inventory/polycentric-2026/app.yml:$ENVIRONMENT
5150
MANIFEST_STAGGER_TIME: '10'
5251

5352
app-deploy-manifest-staging:
5453
extends: .app-deploy-manifest
5554
variables:
56-
ENVIRONMENT: staging
55+
MANIFEST_QUICK_TARGETS: inventory/polycentric-2026/app.yml:staging
5756
needs:
5857
- app-deploy-image-staging
5958

6059
app-deploy-manifest-production:
6160
extends: .app-deploy-manifest
6261
variables:
63-
ENVIRONMENT: polycentric # not production!
62+
MANIFEST_QUICK_TARGETS: inventory/polycentric-east/app.yml:polycentriceast,inventory/polycentric-west/app.yml:polycentricwest
6463
needs:
6564
- app-deploy-image-production

.gitlab/ci/deploy_server.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,18 @@ server-deploy-image-production:
4747
strategy: depend
4848
variables:
4949
MANIFEST_SETUP_COMMAND: quick
50-
MANIFEST_QUICK_TARGETS: inventory/polycentric-2026/server.yml:$ENVIRONMENT
5150
MANIFEST_STAGGER_TIME: '10'
5251

5352
server-deploy-manifest-staging:
5453
extends: .server-deploy-manifest
5554
variables:
56-
ENVIRONMENT: staging
55+
MANIFEST_QUICK_TARGETS: inventory/polycentric-2026/server.yml:staging
5756
needs:
5857
- server-deploy-image-staging
5958

6059
server-deploy-manifest-production:
6160
extends: .server-deploy-manifest
6261
variables:
63-
ENVIRONMENT: polycentric # not production!
62+
MANIFEST_QUICK_TARGETS: inventory/polycentric-east/server.yml:polycentriceast,inventory/polycentric-west/server.yml:polycentricwest
6463
needs:
6564
- server-deploy-image-production

apps/polycentric/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"expo-dev-client": "~55.0.10",
4242
"expo-device": "~55.0.0",
4343
"expo-document-picker": "~55.0.8",
44+
"expo-file-system": "~55.0.17",
4445
"expo-font": "~55.0.4",
4546
"expo-haptics": "~55.0.8",
4647
"expo-image": "~55.0.5",
Lines changed: 6 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { sha256 } from '@noble/hashes/sha2';
21
import { v2, type PolycentricClient } from '@polycentric/react-native';
32
import { File } from 'expo-file-system';
43
import { isWeb } from '@/src/common/util/platform';
@@ -11,16 +10,12 @@ export type ProcessAndUploadOptions = {
1110
sizes?: number[];
1211
/** `fill` crops to a square (default, for avatars). `fit` preserves aspect. */
1312
mode?: 'fill' | 'fit';
14-
/** Source image width. Required for `mode: 'fit'` so variants record correct dims. */
15-
sourceWidth?: number;
16-
/** Source image height. Required for `mode: 'fit'` so variants record correct dims. */
17-
sourceHeight?: number;
1813
};
1914

2015
/**
2116
* Fetch an image from `uri`, resize it into each size in `sizes` via
22-
* the core's JPEG encoder, upload each variant's bytes to the client's
23-
* servers, and return the assembled `ImageSet`.
17+
* the core's JPEG encoder, commit each variant locally and upload to
18+
* the client's servers, and return the assembled `ImageSet`.
2419
*/
2520
export async function processAndUploadImage(
2621
client: PolycentricClient,
@@ -41,27 +36,14 @@ export async function processAndUploadImage(
4136

4237
const variants = await Promise.all(
4338
sizes.map(async (size) => {
44-
const jpeg = client.processImageToJpeg(raw, size, size, mode);
45-
const { width, height } = computeOutputDims(
39+
const { bytes, width, height } = client.processImageToJpeg(
40+
raw,
4641
size,
4742
size,
4843
mode,
49-
options.sourceWidth,
50-
options.sourceHeight,
5144
);
52-
const image = v2.Image.create({
53-
blob: {
54-
digest: {
55-
type: v2.ContentDigestType.SHA256,
56-
value: sha256(jpeg),
57-
},
58-
mimeType: 'image/jpeg',
59-
size: BigInt(jpeg.length),
60-
},
61-
width,
62-
height,
63-
});
64-
return { image, body: jpeg };
45+
const blob = await client.commitBlob(bytes, 'image/jpeg');
46+
return { image: v2.Image.create({ blob, width, height }), body: bytes };
6547
}),
6648
);
6749

@@ -75,27 +57,3 @@ export async function processAndUploadImage(
7557

7658
return v2.ImageSet.create({ images: variants.map((v) => v.image) });
7759
}
78-
79-
/**
80-
* Match the `image` crate's `resize()`: scale both axes by
81-
* `min(targetW/srcW, targetH/srcH)` and round. For fill mode the
82-
* output is always exactly the requested bounds. For fit mode without
83-
* known source dims, we fall back to the bounds (the client can re-
84-
* derive aspect from the served image if needed).
85-
*/
86-
function computeOutputDims(
87-
targetW: number,
88-
targetH: number,
89-
mode: 'fill' | 'fit',
90-
srcW?: number,
91-
srcH?: number,
92-
): { width: number; height: number } {
93-
if (mode === 'fill' || !srcW || !srcH) {
94-
return { width: targetW, height: targetH };
95-
}
96-
const ratio = Math.min(targetW / srcW, targetH / srcH);
97-
return {
98-
width: Math.max(1, Math.round(srcW * ratio)),
99-
height: Math.max(1, Math.round(srcH * ratio)),
100-
};
101-
}

apps/polycentric/src/features/composer/ComposeSheetInner.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,6 @@ export function ComposeSheetInner({
152152
processAndUploadImage(client, a.uri, {
153153
mode: 'fit',
154154
sizes: POST_VARIANT_SIZES,
155-
sourceWidth: a.width,
156-
sourceHeight: a.height,
157155
}),
158156
),
159157
)
@@ -190,6 +188,7 @@ export function ComposeSheetInner({
190188
signedEvent,
191189
serializedContent: { contentBytes: v2.Content.toBinary(content) },
192190
});
191+
193192
const identity = currentIdentityKey ?? '';
194193

195194
// Optimistically add the new event to the below query

apps/polycentric/src/features/profile/lib/publishProfileUpdate.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export async function publishProfileUpdate(
1717
const avatar = avatarUri
1818
? await processAndUploadImage(client, avatarUri)
1919
: undefined;
20-
2120
const content = client.contentManager.build({
2221
oneofKind: 'profileUpdate',
2322
profileUpdate: {

packages/js-browser/src/storage/indexeddb/content.repository.ts renamed to packages/js-browser/src/datastore/indexeddb/content.repository.ts

File renamed without changes.

packages/js-browser/src/storage/indexeddb/database.ts renamed to packages/js-browser/src/datastore/indexeddb/database.ts

File renamed without changes.

packages/js-browser/src/storage/indexeddb/event-ack.repository.ts renamed to packages/js-browser/src/datastore/indexeddb/event-ack.repository.ts

File renamed without changes.

0 commit comments

Comments
 (0)