jazz-react-native 0.9.8 → 0.9.10-jazz-bridge-preview.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
-
2
- > jazz-react-native@0.9.8 build /home/runner/work/jazz/jazz/packages/jazz-react-native
3
- > rm -rf ./dist && tsc --sourceMap --outDir dist
4
-
1
+
2
+ 
3
+ > jazz-react-native@0.9.9 build /Users/anselm/jazz/jazz/packages/jazz-react-native
4
+ > rm -rf ./dist && tsc --sourceMap --outDir dist
5
+
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # jazz-browser
2
2
 
3
+ ## 0.9.10-jazz-bridge-preview.0
4
+
5
+ ### Patch Changes
6
+
7
+ - f76274c: Fix image handling in react-native
8
+ - Updated dependencies [5f43fbf]
9
+ - jazz-tools@0.9.10-jazz-bridge-preview.0
10
+ - jazz-react-core@0.8.51-jazz-bridge-preview.0
11
+
12
+ ## 0.9.9
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies [8eb9247]
17
+ - Updated dependencies [8eb9247]
18
+ - jazz-tools@0.9.9
19
+ - cojson@0.9.9
20
+ - jazz-react-core@0.8.50
21
+ - cojson-storage-rn-sqlite@0.8.52
22
+ - cojson-transport-ws@0.9.9
23
+
3
24
  ## 0.9.8
4
25
 
5
26
  ### Patch Changes
package/dist/index.js CHANGED
@@ -2,5 +2,6 @@ export * from "./provider.js";
2
2
  export * from "./auth/auth.js";
3
3
  export * from "./storage/kv-store-context.js";
4
4
  export * from "./hooks.js";
5
+ export * from "./media.js";
5
6
  export { parseInviteLink, createInviteLink, setupKvStore } from "./platform.js";
6
7
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC"}
package/dist/media.js CHANGED
@@ -8,20 +8,37 @@ export function useProgressiveImg({ image, maxWidth, }) {
8
8
  return;
9
9
  const unsub = image.subscribe({}, (update) => {
10
10
  const highestRes = update?.highestResAvailable({ maxWidth });
11
- if (highestRes) {
12
- if (highestRes.res !== lastHighestRes) {
13
- lastHighestRes = highestRes.res;
14
- const blob = highestRes.stream.toBlob();
15
- if (blob) {
16
- const blobURI = URL.createObjectURL(blob);
17
- setCurrent({ src: blobURI, res: highestRes.res });
18
- return () => {
19
- setTimeout(() => URL.revokeObjectURL(blobURI), 200);
20
- };
21
- }
11
+ if (highestRes && highestRes.res !== lastHighestRes) {
12
+ lastHighestRes = highestRes.res;
13
+ // use the base64 data directly
14
+ const chunks = highestRes.stream.getChunks();
15
+ if (chunks?.chunks && chunks.chunks.length > 0) {
16
+ // convert chunks to base64
17
+ const totalLength = chunks.chunks.reduce((acc, chunk) => acc + chunk.length, 0);
18
+ const combinedArray = new Uint8Array(totalLength);
19
+ let offset = 0;
20
+ chunks.chunks.forEach((chunk) => {
21
+ combinedArray.set(chunk, offset);
22
+ offset += chunk.length;
23
+ });
24
+ // Create data URL
25
+ const base64 = Buffer.from(combinedArray).toString("base64");
26
+ const dataUrl = `data:${chunks.mimeType};base64,${base64}`;
27
+ setCurrent({
28
+ src: dataUrl,
29
+ res: highestRes.res,
30
+ });
31
+ }
32
+ else {
33
+ // Fallback to placeholder if chunks aren't available
34
+ console.warn("No chunks available for image", image.id);
35
+ setCurrent({
36
+ src: update?.placeholderDataURL,
37
+ res: "placeholder",
38
+ });
22
39
  }
23
40
  }
24
- else {
41
+ else if (!highestRes) {
25
42
  setCurrent({
26
43
  src: update?.placeholderDataURL,
27
44
  res: "placeholder",
package/dist/media.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"media.js","sourceRoot":"","sources":["../src/media.tsx"],"names":[],"mappings":"AACA,OAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEnD,sBAAsB;AACtB,MAAM,UAAU,iBAAiB,CAAC,EAChC,KAAK,EACL,QAAQ,GAIT;IACC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAEpC,SAAS,CAAC,CAAC;IAEb,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,cAAkC,CAAC;QACvC,IAAI,CAAC,KAAK;YAAE,OAAO;QACnB,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC,MAAM,EAAE,EAAE;YAC3C,MAAM,UAAU,GAAG,MAAM,EAAE,mBAAmB,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;YAC7D,IAAI,UAAU,EAAE,CAAC;gBACf,IAAI,UAAU,CAAC,GAAG,KAAK,cAAc,EAAE,CAAC;oBACtC,cAAc,GAAG,UAAU,CAAC,GAAG,CAAC;oBAChC,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;oBACxC,IAAI,IAAI,EAAE,CAAC;wBACT,MAAM,OAAO,GAAG,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;wBAC1C,UAAU,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC;wBAClD,OAAO,GAAG,EAAE;4BACV,UAAU,CAAC,GAAG,EAAE,CA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AC;wBACT,GAAG,EAAE,MAAM,EAAE,kBAAkB;wBAC/B,GAAG,EAAE,aAAa;qBACnB,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;iBAAM,IAAI,CAAC,UAAU,EAAE,CAAC;gBACvB,UAAU,CAAC;oBACT,GAAG,EAAE,MAAM,EAAE,kBAAkB;oBAC/B,GAAG,EAAE,aAAa;iBACnB,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,KAAK,CAAC;IACf,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC;IAE1B,OAAO;QACL,GAAG,EAAE,OAAO,EAAE,GAAG;QACjB,GAAG,EAAE,OAAO,EAAE,GAAG;QACjB,YAAY,EAAE,KAAK,EAAE,YAAY;KAClC,CAAC;AACJ,CAAC;AAED,sBAAsB;AACtB,MAAM,UAAU,cAAc,CAAC,EAC7B,QAAQ,EACR,KAAK,EACL,QAAQ,GAST;IACC,MAAM,MAAM,GAAG,iBAAiB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;IACtD,OAAO,MAAM,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jazz-react-native",
3
- "version": "0.9.8",
3
+ "version": "0.9.10-jazz-bridge-preview.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -27,11 +27,11 @@
27
27
  "dependencies": {
28
28
  "@scure/base": "1.2.1",
29
29
  "react-native-quick-crypto": "1.0.0-beta.9",
30
- "jazz-react-core": "0.8.49",
31
- "cojson": "0.9.0",
32
- "cojson-transport-ws": "0.9.0",
33
- "cojson-storage-rn-sqlite": "0.8.51",
34
- "jazz-tools": "0.9.8"
30
+ "jazz-react-core": "0.8.51-jazz-bridge-preview.0",
31
+ "cojson": "0.9.9",
32
+ "cojson-transport-ws": "0.9.9",
33
+ "jazz-tools": "0.9.10-jazz-bridge-preview.0",
34
+ "cojson-storage-rn-sqlite": "0.8.52"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "@react-native-community/netinfo": "*",
package/src/index.ts CHANGED
@@ -2,5 +2,6 @@ export * from "./provider.js";
2
2
  export * from "./auth/auth.js";
3
3
  export * from "./storage/kv-store-context.js";
4
4
  export * from "./hooks.js";
5
+ export * from "./media.js";
5
6
 
6
7
  export { parseInviteLink, createInviteLink, setupKvStore } from "./platform.js";
package/src/media.tsx CHANGED
@@ -18,19 +18,40 @@ export function useProgressiveImg({
18
18
  if (!image) return;
19
19
  const unsub = image.subscribe({}, (update) => {
20
20
  const highestRes = update?.highestResAvailable({ maxWidth });
21
- if (highestRes) {
22
- if (highestRes.res !== lastHighestRes) {
23
- lastHighestRes = highestRes.res;
24
- const blob = highestRes.stream.toBlob();
25
- if (blob) {
26
- const blobURI = URL.createObjectURL(blob);
27
- setCurrent({ src: blobURI, res: highestRes.res });
28
- return () => {
29
- setTimeout(() => URL.revokeObjectURL(blobURI), 200);
30
- };
31
- }
21
+ if (highestRes && highestRes.res !== lastHighestRes) {
22
+ lastHighestRes = highestRes.res;
23
+ // use the base64 data directly
24
+ const chunks = highestRes.stream.getChunks();
25
+ if (chunks?.chunks && chunks.chunks.length > 0) {
26
+ // convert chunks to base64
27
+ const totalLength = chunks.chunks.reduce(
28
+ (acc, chunk) => acc + chunk.length,
29
+ 0,
30
+ );
31
+ const combinedArray = new Uint8Array(totalLength);
32
+ let offset = 0;
33
+ chunks.chunks.forEach((chunk) => {
34
+ combinedArray.set(chunk, offset);
35
+ offset += chunk.length;
36
+ });
37
+
38
+ // Create data URL
39
+ const base64 = Buffer.from(combinedArray).toString("base64");
40
+ const dataUrl = `data:${chunks.mimeType};base64,${base64}`;
41
+
42
+ setCurrent({
43
+ src: dataUrl,
44
+ res: highestRes.res,
45
+ });
46
+ } else {
47
+ // Fallback to placeholder if chunks aren't available
48
+ console.warn("No chunks available for image", image.id);
49
+ setCurrent({
50
+ src: update?.placeholderDataURL,
51
+ res: "placeholder",
52
+ });
32
53
  }
33
- } else {
54
+ } else if (!highestRes) {
34
55
  setCurrent({
35
56
  src: update?.placeholderDataURL,
36
57
  res: "placeholder",