jazz-tools 0.18.16 → 0.18.17
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.
- package/.svelte-kit/__package__/media/image.svelte +104 -98
- package/.svelte-kit/__package__/media/image.svelte.d.ts.map +1 -1
- package/.svelte-kit/__package__/tests/media/image.svelte.test.js +16 -2
- package/.turbo/turbo-build.log +42 -42
- package/CHANGELOG.md +11 -0
- package/dist/{chunk-GRN6OAUX.js → chunk-OTWWOZMB.js} +73 -4
- package/dist/chunk-OTWWOZMB.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/react/index.js +2 -0
- package/dist/react/index.js.map +1 -1
- package/dist/react/media/image.d.ts.map +1 -1
- package/dist/react-native-core/index.js +3 -1
- package/dist/react-native-core/index.js.map +1 -1
- package/dist/react-native-core/media/image.d.ts.map +1 -1
- package/dist/svelte/media/image.svelte +104 -98
- package/dist/svelte/media/image.svelte.d.ts.map +1 -1
- package/dist/svelte/tests/media/image.svelte.test.js +16 -2
- package/dist/testing.js +1 -1
- package/dist/tools/implementation/refs.d.ts +1 -1
- package/dist/tools/implementation/refs.d.ts.map +1 -1
- package/dist/tools/subscribe/CoValueCoreSubscription.d.ts +4 -0
- package/dist/tools/subscribe/CoValueCoreSubscription.d.ts.map +1 -1
- package/dist/tools/subscribe/SubscriptionScope.d.ts +7 -0
- package/dist/tools/subscribe/SubscriptionScope.d.ts.map +1 -1
- package/dist/tools/subscribe/index.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/react/media/image.tsx +2 -0
- package/src/react/tests/media/image.test.tsx +20 -2
- package/src/react-native-core/media/image.tsx +4 -1
- package/src/svelte/media/image.svelte +104 -98
- package/src/svelte/tests/media/image.svelte.test.ts +18 -2
- package/src/tools/implementation/refs.ts +27 -3
- package/src/tools/subscribe/CoValueCoreSubscription.ts +14 -0
- package/src/tools/subscribe/SubscriptionScope.ts +62 -1
- package/src/tools/subscribe/index.ts +8 -0
- package/dist/chunk-GRN6OAUX.js.map +0 -1
@@ -1,118 +1,122 @@
|
|
1
1
|
<script lang="ts">
|
2
|
-
import { ImageDefinition } from "jazz-tools";
|
3
|
-
import { highestResAvailable } from "jazz-tools/media";
|
4
|
-
import { onDestroy } from "svelte";
|
5
|
-
import { CoState } from "../jazz.class.svelte";
|
6
|
-
import type { ImageProps } from "./image.types.js";
|
7
|
-
|
8
|
-
const { imageId, width, height, ...rest }: ImageProps = $props();
|
9
|
-
|
10
|
-
const imageState = new CoState(ImageDefinition, () => imageId);
|
11
|
-
let lastBestImage: [string, string] | null = null;
|
12
|
-
|
13
|
-
/**
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
let waitingLazyLoading = $state(rest.loading === "lazy");
|
20
|
-
const lazyPlaceholder = $derived.by(() =>
|
21
|
-
|
22
|
-
);
|
23
|
-
|
24
|
-
const dimensions = $derived.by<{
|
25
|
-
|
26
|
-
|
27
|
-
}>(() => {
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
// Both width and height are "original"
|
32
|
-
if (width === "original" && height === "original") {
|
33
|
-
return { width: originalWidth, height: originalHeight };
|
34
|
-
}
|
2
|
+
import { ImageDefinition } from "jazz-tools";
|
3
|
+
import { highestResAvailable } from "jazz-tools/media";
|
4
|
+
import { onDestroy } from "svelte";
|
5
|
+
import { CoState } from "../jazz.class.svelte";
|
6
|
+
import type { ImageProps } from "./image.types.js";
|
7
|
+
|
8
|
+
const { imageId, width, height, ...rest }: ImageProps = $props();
|
9
|
+
|
10
|
+
const imageState = new CoState(ImageDefinition, () => imageId);
|
11
|
+
let lastBestImage: [string, string] | null = null;
|
12
|
+
|
13
|
+
/**
|
14
|
+
* For lazy loading, we use the browser's strategy for images with loading="lazy".
|
15
|
+
* We use an empty image, and when the browser triggers the load event, we load the best available image.
|
16
|
+
* On page loading, if the image url is already in browser's cache, the load event is triggered immediately.
|
17
|
+
* This is why we need to use a different blob url for every image.
|
18
|
+
*/
|
19
|
+
let waitingLazyLoading = $state(rest.loading === "lazy");
|
20
|
+
const lazyPlaceholder = $derived.by(() =>
|
21
|
+
waitingLazyLoading ? URL.createObjectURL(emptyPixelBlob) : undefined,
|
22
|
+
);
|
23
|
+
|
24
|
+
const dimensions = $derived.by<{
|
25
|
+
width: number | undefined;
|
26
|
+
height: number | undefined;
|
27
|
+
}>(() => {
|
28
|
+
const originalWidth = imageState.current?.originalSize?.[0];
|
29
|
+
const originalHeight = imageState.current?.originalSize?.[1];
|
35
30
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
return {
|
40
|
-
width: Math.round((height * originalWidth) / originalHeight),
|
41
|
-
height,
|
42
|
-
};
|
31
|
+
// Both width and height are "original"
|
32
|
+
if (width === "original" && height === "original") {
|
33
|
+
return { width: originalWidth, height: originalHeight };
|
43
34
|
}
|
44
|
-
return { width: undefined, height };
|
45
|
-
}
|
46
35
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
36
|
+
// Width is "original", height is a number
|
37
|
+
if (width === "original" && typeof height === "number") {
|
38
|
+
if (originalWidth && originalHeight) {
|
39
|
+
return {
|
40
|
+
width: Math.round((height * originalWidth) / originalHeight),
|
41
|
+
height,
|
42
|
+
};
|
43
|
+
}
|
44
|
+
return { width: undefined, height };
|
54
45
|
}
|
55
|
-
return { width, height: undefined };
|
56
|
-
}
|
57
46
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
47
|
+
// Height is "original", width is a number
|
48
|
+
if (height === "original" && typeof width === "number") {
|
49
|
+
if (originalWidth && originalHeight) {
|
50
|
+
return {
|
51
|
+
width,
|
52
|
+
height: Math.round((width * originalHeight) / originalWidth),
|
53
|
+
};
|
54
|
+
}
|
55
|
+
return { width, height: undefined };
|
56
|
+
}
|
64
57
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
58
|
+
// In all other cases, use the property value:
|
59
|
+
return {
|
60
|
+
width: width === "original" ? originalWidth : width,
|
61
|
+
height: height === "original" ? originalHeight : height,
|
62
|
+
};
|
63
|
+
});
|
69
64
|
|
70
|
-
const
|
71
|
-
|
65
|
+
const src = $derived.by(() => {
|
66
|
+
if (waitingLazyLoading) {
|
67
|
+
return lazyPlaceholder;
|
68
|
+
}
|
72
69
|
|
73
|
-
|
74
|
-
image
|
75
|
-
|
76
|
-
dimensions.height || dimensions.width || 9999,
|
77
|
-
);
|
70
|
+
const image = imageState.current;
|
71
|
+
if (image === undefined)
|
72
|
+
return "data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==";
|
78
73
|
|
79
|
-
|
80
|
-
if (lastBestImage?.[0] === bestImage.image.$jazz.id) return lastBestImage?.[1];
|
74
|
+
if (!image) return undefined;
|
81
75
|
|
82
|
-
|
76
|
+
const bestImage = highestResAvailable(
|
77
|
+
image,
|
78
|
+
dimensions.width || dimensions.height || 9999,
|
79
|
+
dimensions.height || dimensions.width || 9999,
|
80
|
+
);
|
83
81
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
82
|
+
if (!bestImage) return image.placeholderDataURL;
|
83
|
+
if (lastBestImage?.[0] === bestImage.image.$jazz.id)
|
84
|
+
return lastBestImage?.[1];
|
85
|
+
|
86
|
+
const blob = bestImage.image.toBlob();
|
87
|
+
|
88
|
+
if (blob) {
|
89
|
+
const url = URL.createObjectURL(blob);
|
90
|
+
revokeObjectURL(lastBestImage?.[1]);
|
91
|
+
lastBestImage = [bestImage.image.$jazz.id, url];
|
92
|
+
return url;
|
93
|
+
}
|
90
94
|
|
91
|
-
|
92
|
-
});
|
95
|
+
return image.placeholderDataURL;
|
96
|
+
});
|
93
97
|
|
94
|
-
// Cleanup object URL on component destroy
|
95
|
-
onDestroy(() => {
|
96
|
-
|
97
|
-
});
|
98
|
+
// Cleanup object URL on component destroy
|
99
|
+
onDestroy(() => {
|
100
|
+
revokeObjectURL(lastBestImage?.[1]);
|
101
|
+
});
|
98
102
|
|
99
|
-
function revokeObjectURL(url: string | undefined) {
|
100
|
-
|
101
|
-
|
103
|
+
function revokeObjectURL(url: string | undefined) {
|
104
|
+
if (url && url.startsWith("blob:")) {
|
105
|
+
URL.revokeObjectURL(url);
|
106
|
+
}
|
102
107
|
}
|
103
|
-
}
|
104
108
|
|
105
|
-
const emptyPixelBlob = new Blob(
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
109
|
+
const emptyPixelBlob = new Blob(
|
110
|
+
[
|
111
|
+
Uint8Array.from(
|
112
|
+
atob(
|
113
|
+
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==",
|
114
|
+
),
|
115
|
+
(c) => c.charCodeAt(0),
|
110
116
|
),
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
{ type: "image/png" },
|
115
|
-
);
|
117
|
+
],
|
118
|
+
{ type: "image/png" },
|
119
|
+
);
|
116
120
|
</script>
|
117
121
|
|
118
122
|
<img
|
@@ -120,6 +124,8 @@ const emptyPixelBlob = new Blob(
|
|
120
124
|
width={dimensions.width}
|
121
125
|
height={dimensions.height}
|
122
126
|
alt={rest.alt}
|
123
|
-
onload={() => {
|
127
|
+
onload={() => {
|
128
|
+
waitingLazyLoading = false;
|
129
|
+
}}
|
124
130
|
{...rest}
|
125
131
|
/>
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"image.svelte.d.ts","sourceRoot":"","sources":["../../../../src/svelte/media/image.svelte.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;
|
1
|
+
{"version":3,"file":"image.svelte.d.ts","sourceRoot":"","sources":["../../../../src/svelte/media/image.svelte.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAiInD,QAAA,MAAM,KAAK,gDAAsC,CAAC;AAClD,KAAK,KAAK,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC;AACtC,eAAe,KAAK,CAAC"}
|
@@ -10,7 +10,7 @@ describe("Image", async () => {
|
|
10
10
|
});
|
11
11
|
const renderWithAccount = (props) => render(Image, props, { account });
|
12
12
|
describe("initial rendering", () => {
|
13
|
-
it("should render
|
13
|
+
it("should render a blank placeholder while waiting for the coValue to load", async () => {
|
14
14
|
const { container } = renderWithAccount({
|
15
15
|
imageId: "co_zMTubMby3QiKDYnW9e2BEXW7Xaq",
|
16
16
|
alt: "test",
|
@@ -20,7 +20,21 @@ describe("Image", async () => {
|
|
20
20
|
expect(img.getAttribute("width")).toBe(null);
|
21
21
|
expect(img.getAttribute("height")).toBe(null);
|
22
22
|
expect(img.alt).toBe("test");
|
23
|
-
expect(img.src).toBe("");
|
23
|
+
expect(img.src).toBe("data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==");
|
24
|
+
});
|
25
|
+
it("should render nothing if coValue is not found", async () => {
|
26
|
+
const { container } = renderWithAccount({
|
27
|
+
imageId: "co_zMTubMby3QiKDYnW9e2BEXW7Xaq",
|
28
|
+
alt: "test",
|
29
|
+
});
|
30
|
+
await waitFor(() => {
|
31
|
+
const img = container.querySelector("img");
|
32
|
+
expect(img).toBeDefined();
|
33
|
+
expect(img.getAttribute("width")).toBe(null);
|
34
|
+
expect(img.getAttribute("height")).toBe(null);
|
35
|
+
expect(img.alt).toBe("test");
|
36
|
+
expect(img.src).toBe("");
|
37
|
+
});
|
24
38
|
});
|
25
39
|
it("should render an empty image if the image is not loaded yet", async () => {
|
26
40
|
const original = FileStream.create({ owner: account.$jazz.owner });
|
package/.turbo/turbo-build.log
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
> jazz-tools@0.18.
|
2
|
+
> jazz-tools@0.18.17 build /home/runner/_work/jazz/jazz/packages/jazz-tools
|
3
3
|
> tsup && pnpm types && pnpm build:svelte
|
4
4
|
|
5
5
|
[34mCLI[39m Building entry: {"index":"src/index.ts","testing":"src/testing.ts"}
|
@@ -114,24 +114,17 @@
|
|
114
114
|
[34mESM[39m Build start
|
115
115
|
[34mCLI[39m Cleaning output folder
|
116
116
|
[34mESM[39m Build start
|
117
|
-
[32mESM[39m [1mdist/tiptap/index.js [22m[32m564.00 B[39m
|
118
|
-
[32mESM[39m [1mdist/tiptap/index.js.map [22m[32m1.21 KB[39m
|
119
|
-
[32mESM[39m ⚡️ Build success in 13ms
|
120
117
|
[32mESM[39m [1mdist/react/ssr.js [22m[32m688.00 B[39m
|
121
118
|
[32mESM[39m [1mdist/react/ssr.js.map [22m[32m1.12 KB[39m
|
119
|
+
[32mESM[39m ⚡️ Build success in 20ms
|
120
|
+
[32mESM[39m [1mdist/tiptap/index.js [22m[32m564.00 B[39m
|
121
|
+
[32mESM[39m [1mdist/tiptap/index.js.map [22m[32m1.21 KB[39m
|
122
122
|
[32mESM[39m ⚡️ Build success in 15ms
|
123
123
|
[32mESM[39m [1mdist/worker/index.js [22m[32m3.19 KB[39m
|
124
124
|
[32mESM[39m [1mdist/worker/edge-wasm.js [22m[32m215.00 B[39m
|
125
125
|
[32mESM[39m [1mdist/worker/index.js.map [22m[32m6.17 KB[39m
|
126
126
|
[32mESM[39m [1mdist/worker/edge-wasm.js.map [22m[32m434.00 B[39m
|
127
|
-
[32mESM[39m ⚡️ Build success in
|
128
|
-
[32mESM[39m [1mdist/better-auth/auth/client.js [22m[32m4.44 KB[39m
|
129
|
-
[32mESM[39m [1mdist/better-auth/auth/react.js [22m[32m799.00 B[39m
|
130
|
-
[32mESM[39m [1mdist/better-auth/auth/server.js [22m[32m8.36 KB[39m
|
131
|
-
[32mESM[39m [1mdist/better-auth/auth/client.js.map [22m[32m8.24 KB[39m
|
132
|
-
[32mESM[39m [1mdist/better-auth/auth/react.js.map [22m[32m2.04 KB[39m
|
133
|
-
[32mESM[39m [1mdist/better-auth/auth/server.js.map [22m[32m15.29 KB[39m
|
134
|
-
[32mESM[39m ⚡️ Build success in 18ms
|
127
|
+
[32mESM[39m ⚡️ Build success in 16ms
|
135
128
|
[32mESM[39m [1mdist/media/index.js [22m[32m236.00 B[39m
|
136
129
|
[32mESM[39m [1mdist/media/index.browser.js [22m[32m2.79 KB[39m
|
137
130
|
[32mESM[39m [1mdist/media/index.native.js [22m[32m2.90 KB[39m
|
@@ -142,70 +135,77 @@
|
|
142
135
|
[32mESM[39m [1mdist/media/index.native.js.map [22m[32m6.09 KB[39m
|
143
136
|
[32mESM[39m [1mdist/media/index.server.js.map [22m[32m6.37 KB[39m
|
144
137
|
[32mESM[39m [1mdist/media/chunk-W3S526L3.js.map [22m[32m16.57 KB[39m
|
145
|
-
[32mESM[39m ⚡️ Build success in
|
138
|
+
[32mESM[39m ⚡️ Build success in 31ms
|
139
|
+
[32mESM[39m [1mdist/better-auth/auth/client.js [22m[32m4.44 KB[39m
|
140
|
+
[32mESM[39m [1mdist/better-auth/auth/react.js [22m[32m799.00 B[39m
|
141
|
+
[32mESM[39m [1mdist/better-auth/auth/server.js [22m[32m8.36 KB[39m
|
142
|
+
[32mESM[39m [1mdist/better-auth/auth/client.js.map [22m[32m8.24 KB[39m
|
143
|
+
[32mESM[39m [1mdist/better-auth/auth/react.js.map [22m[32m2.04 KB[39m
|
144
|
+
[32mESM[39m [1mdist/better-auth/auth/server.js.map [22m[32m15.29 KB[39m
|
145
|
+
[32mESM[39m ⚡️ Build success in 27ms
|
146
|
+
[32mESM[39m [1mdist/react-native/index.js [22m[32m2.53 KB[39m
|
147
|
+
[32mESM[39m [1mdist/react-native/crypto.js [22m[32m161.00 B[39m
|
148
|
+
[32mESM[39m [1mdist/react-native/testing.js [22m[32m120.00 B[39m
|
149
|
+
[32mESM[39m [1mdist/react-native/index.js.map [22m[32m5.68 KB[39m
|
150
|
+
[32mESM[39m [1mdist/react-native/crypto.js.map [22m[32m197.00 B[39m
|
151
|
+
[32mESM[39m [1mdist/react-native/testing.js.map [22m[32m176.00 B[39m
|
152
|
+
[32mESM[39m ⚡️ Build success in 35ms
|
146
153
|
[32mESM[39m [1mdist/react-core/index.js [22m[32m10.72 KB[39m
|
147
154
|
[32mESM[39m [1mdist/react-core/testing.js [22m[32m1.17 KB[39m
|
148
155
|
[32mESM[39m [1mdist/react-core/chunk-7DYMJ74I.js [22m[32m279.00 B[39m
|
149
156
|
[32mESM[39m [1mdist/react-core/index.js.map [22m[32m33.90 KB[39m
|
150
157
|
[32mESM[39m [1mdist/react-core/testing.js.map [22m[32m1.82 KB[39m
|
151
158
|
[32mESM[39m [1mdist/react-core/chunk-7DYMJ74I.js.map [22m[32m533.00 B[39m
|
152
|
-
[32mESM[39m ⚡️ Build success in
|
159
|
+
[32mESM[39m ⚡️ Build success in 32ms
|
153
160
|
[32mESM[39m [1mdist/expo/index.js [22m[32m4.68 KB[39m
|
154
161
|
[32mESM[39m [1mdist/expo/testing.js [22m[32m112.00 B[39m
|
155
162
|
[32mESM[39m [1mdist/expo/crypto.js [22m[32m153.00 B[39m
|
156
163
|
[32mESM[39m [1mdist/expo/index.js.map [22m[32m10.23 KB[39m
|
157
164
|
[32mESM[39m [1mdist/expo/testing.js.map [22m[32m168.00 B[39m
|
158
165
|
[32mESM[39m [1mdist/expo/crypto.js.map [22m[32m189.00 B[39m
|
159
|
-
[32mESM[39m ⚡️ Build success in
|
160
|
-
[32mESM[39m [1mdist/react-native/index.js [22m[32m2.53 KB[39m
|
161
|
-
[32mESM[39m [1mdist/react-native/crypto.js [22m[32m161.00 B[39m
|
162
|
-
[32mESM[39m [1mdist/react-native/testing.js [22m[32m120.00 B[39m
|
163
|
-
[32mESM[39m [1mdist/react-native/index.js.map [22m[32m5.68 KB[39m
|
164
|
-
[32mESM[39m [1mdist/react-native/crypto.js.map [22m[32m197.00 B[39m
|
165
|
-
[32mESM[39m [1mdist/react-native/testing.js.map [22m[32m176.00 B[39m
|
166
|
-
[32mESM[39m ⚡️ Build success in 38ms
|
166
|
+
[32mESM[39m ⚡️ Build success in 44ms
|
167
167
|
[32mESM[39m [1mdist/browser/index.js [22m[32m13.64 KB[39m
|
168
168
|
[32mESM[39m [1mdist/browser/index.js.map [22m[32m29.14 KB[39m
|
169
|
-
[32mESM[39m ⚡️ Build success in
|
169
|
+
[32mESM[39m ⚡️ Build success in 46ms
|
170
170
|
[32mESM[39m [1mdist/better-auth/database-adapter/index.js [22m[32m26.34 KB[39m
|
171
171
|
[32mESM[39m [1mdist/better-auth/database-adapter/index.js.map [22m[32m57.62 KB[39m
|
172
|
-
[32mESM[39m ⚡️ Build success in
|
173
|
-
[32mESM[39m [1mdist/react/
|
174
|
-
[32mESM[39m [1mdist/react/index.js [22m[32m24.76 KB[39m
|
175
|
-
[32mESM[39m [1mdist/react/testing.js.map [22m[32m165.00 B[39m
|
176
|
-
[32mESM[39m [1mdist/react/index.js.map [22m[32m53.56 KB[39m
|
177
|
-
[32mESM[39m ⚡️ Build success in 49ms
|
178
|
-
[32mESM[39m [1mdist/react-native-core/index.js [22m[32m18.03 KB[39m
|
179
|
-
[32mESM[39m [1mdist/react-native-core/testing.js [22m[32m119.00 B[39m
|
172
|
+
[32mESM[39m ⚡️ Build success in 39ms
|
173
|
+
[32mESM[39m [1mdist/react-native-core/index.js [22m[32m18.13 KB[39m
|
180
174
|
[32mESM[39m [1mdist/react-native-core/crypto.js [22m[32m2.10 KB[39m
|
181
|
-
[32mESM[39m [1mdist/react-native-core/
|
182
|
-
[32mESM[39m [1mdist/react-native-core/
|
175
|
+
[32mESM[39m [1mdist/react-native-core/testing.js [22m[32m119.00 B[39m
|
176
|
+
[32mESM[39m [1mdist/react-native-core/index.js.map [22m[32m36.96 KB[39m
|
183
177
|
[32mESM[39m [1mdist/react-native-core/crypto.js.map [22m[32m4.25 KB[39m
|
184
|
-
[32mESM[39m
|
178
|
+
[32mESM[39m [1mdist/react-native-core/testing.js.map [22m[32m175.00 B[39m
|
179
|
+
[32mESM[39m ⚡️ Build success in 51ms
|
180
|
+
[32mESM[39m [1mdist/react/index.js [22m[32m24.88 KB[39m
|
181
|
+
[32mESM[39m [1mdist/react/testing.js [22m[32m122.00 B[39m
|
182
|
+
[32mESM[39m [1mdist/react/testing.js.map [22m[32m165.00 B[39m
|
183
|
+
[32mESM[39m [1mdist/react/index.js.map [22m[32m53.71 KB[39m
|
184
|
+
[32mESM[39m ⚡️ Build success in 52ms
|
185
185
|
[32mESM[39m [1mdist/prosemirror/index.js [22m[32m77.76 KB[39m
|
186
186
|
[32mESM[39m [1mdist/prosemirror/index.js.map [22m[32m307.20 KB[39m
|
187
|
-
[32mESM[39m ⚡️ Build success in
|
187
|
+
[32mESM[39m ⚡️ Build success in 54ms
|
188
188
|
[32mESM[39m [1mdist/inspector/index.js [22m[32m69.71 KB[39m
|
189
189
|
[32mESM[39m [1mdist/inspector/index.js.map [22m[32m121.38 KB[39m
|
190
|
-
[32mESM[39m ⚡️ Build success in
|
190
|
+
[32mESM[39m ⚡️ Build success in 64ms
|
191
|
+
[32mESM[39m [1mdist/chunk-OTWWOZMB.js [22m[32m176.08 KB[39m
|
191
192
|
[32mESM[39m [1mdist/testing.js [22m[32m7.17 KB[39m
|
192
193
|
[32mESM[39m [1mdist/index.js [22m[32m26.13 KB[39m
|
193
|
-
[32mESM[39m [1mdist/chunk-
|
194
|
+
[32mESM[39m [1mdist/chunk-OTWWOZMB.js.map [22m[32m419.55 KB[39m
|
194
195
|
[32mESM[39m [1mdist/testing.js.map [22m[32m14.10 KB[39m
|
195
196
|
[32mESM[39m [1mdist/index.js.map [22m[32m52.92 KB[39m
|
196
|
-
[32mESM[39m
|
197
|
-
[32mESM[39m ⚡️ Build success in 80ms
|
197
|
+
[32mESM[39m ⚡️ Build success in 82ms
|
198
198
|
[32mESM[39m [1mdist/inspector/register-custom-element.js [22m[32m218.00 B[39m
|
199
199
|
[32mESM[39m [1mdist/inspector/register-custom-element.js.map [22m[32m314.00 B[39m
|
200
200
|
[32mESM[39m [1mdist/inspector/custom-element-G6SPZEBR.js [22m[32m1.54 MB[39m
|
201
201
|
[32mESM[39m [1mdist/inspector/custom-element-G6SPZEBR.js.map [22m[32m2.36 MB[39m
|
202
|
-
[32mESM[39m ⚡️ Build success in
|
202
|
+
[32mESM[39m ⚡️ Build success in 123ms
|
203
203
|
|
204
|
-
> jazz-tools@0.18.
|
204
|
+
> jazz-tools@0.18.17 types /home/runner/_work/jazz/jazz/packages/jazz-tools
|
205
205
|
> tsc --outDir dist
|
206
206
|
|
207
207
|
|
208
|
-
> jazz-tools@0.18.
|
208
|
+
> jazz-tools@0.18.17 build:svelte /home/runner/_work/jazz/jazz/packages/jazz-tools
|
209
209
|
> rm -rf dist/svelte && svelte-package -i src/svelte -o dist/svelte --tsconfig tsconfig.svelte.json
|
210
210
|
|
211
211
|
src/svelte -> dist/svelte
|
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# jazz-tools
|
2
2
|
|
3
|
+
## 0.18.17
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 75d1afa: Fix an issue where a flash of alt text displays while an image definition is loading from storage
|
8
|
+
- 8aa4acd: Optimized the inactive subscriptions, improving performance of updates on created and loaded values by 2.5x
|
9
|
+
- Updated dependencies [925da72]
|
10
|
+
- cojson@0.18.17
|
11
|
+
- cojson-storage-indexeddb@0.18.17
|
12
|
+
- cojson-transport-ws@0.18.17
|
13
|
+
|
3
14
|
## 0.18.16
|
4
15
|
|
5
16
|
### Patch Changes
|
@@ -3317,8 +3317,21 @@ var Ref = class {
|
|
3317
3317
|
}
|
3318
3318
|
async load() {
|
3319
3319
|
const subscriptionScope = getSubscriptionScope(this.parent);
|
3320
|
-
|
3321
|
-
|
3320
|
+
let node;
|
3321
|
+
if (subscriptionScope.closed) {
|
3322
|
+
node = new SubscriptionScope(
|
3323
|
+
subscriptionScope.node,
|
3324
|
+
true,
|
3325
|
+
this.id,
|
3326
|
+
this.schema,
|
3327
|
+
subscriptionScope.skipRetry,
|
3328
|
+
subscriptionScope.bestEffortResolution,
|
3329
|
+
subscriptionScope.unstable_branch
|
3330
|
+
);
|
3331
|
+
} else {
|
3332
|
+
subscriptionScope.subscribeToId(this.id, this.schema);
|
3333
|
+
node = subscriptionScope.childNodes.get(this.id);
|
3334
|
+
}
|
3322
3335
|
if (!node) {
|
3323
3336
|
return null;
|
3324
3337
|
}
|
@@ -3338,6 +3351,9 @@ var Ref = class {
|
|
3338
3351
|
unsubscribe();
|
3339
3352
|
resolve(null);
|
3340
3353
|
}
|
3354
|
+
if (subscriptionScope.closed) {
|
3355
|
+
node.destroy();
|
3356
|
+
}
|
3341
3357
|
});
|
3342
3358
|
});
|
3343
3359
|
}
|
@@ -3523,6 +3539,17 @@ var CoValueCoreSubscription = class {
|
|
3523
3539
|
this.source = localNode.getCoValue(id);
|
3524
3540
|
this.initializeSubscription();
|
3525
3541
|
}
|
3542
|
+
/**
|
3543
|
+
* Rehydrates the subscription by resetting the unsubscribed flag and initializing the subscription again
|
3544
|
+
*/
|
3545
|
+
pullValue() {
|
3546
|
+
if (!this.unsubscribed) {
|
3547
|
+
return;
|
3548
|
+
}
|
3549
|
+
this.unsubscribed = false;
|
3550
|
+
this.initializeSubscription();
|
3551
|
+
this.unsubscribe();
|
3552
|
+
}
|
3526
3553
|
/**
|
3527
3554
|
* Main entry point for subscription initialization.
|
3528
3555
|
* Determines the subscription strategy based on current availability and branch requirements.
|
@@ -3753,6 +3780,7 @@ var SubscriptionScope = class _SubscriptionScope {
|
|
3753
3780
|
this.totalValidTransactions = 0;
|
3754
3781
|
this.migrated = false;
|
3755
3782
|
this.migrating = false;
|
3783
|
+
this.closed = false;
|
3756
3784
|
this.silenceUpdates = false;
|
3757
3785
|
this.handleChildUpdate = (id, value, key) => {
|
3758
3786
|
if (value.type === "unloaded") {
|
@@ -3788,7 +3816,6 @@ var SubscriptionScope = class _SubscriptionScope {
|
|
3788
3816
|
lastUpdate = value;
|
3789
3817
|
if (skipRetry && value === "unavailable") {
|
3790
3818
|
this.handleUpdate(value);
|
3791
|
-
this.destroy();
|
3792
3819
|
return;
|
3793
3820
|
}
|
3794
3821
|
if (!this.migrated && value !== "unavailable") {
|
@@ -3992,8 +4019,37 @@ var SubscriptionScope = class _SubscriptionScope {
|
|
3992
4019
|
isSubscribedToId(id) {
|
3993
4020
|
return this.idsSubscribed.has(id) || this.childValues.has(id) || this.pendingAutoloadedChildren.has(id) || this.pendingLoadedChildren.has(id);
|
3994
4021
|
}
|
4022
|
+
/**
|
4023
|
+
* Checks if the currently unloaded value has got some updates
|
4024
|
+
*
|
4025
|
+
* Used to make the autoload work on closed subscription scopes
|
4026
|
+
*/
|
4027
|
+
pullValue(listener) {
|
4028
|
+
if (!this.closed) {
|
4029
|
+
throw new Error("Cannot pull a non-closed subscription scope");
|
4030
|
+
}
|
4031
|
+
if (this.value.type === "loaded") {
|
4032
|
+
return;
|
4033
|
+
}
|
4034
|
+
this.subscription.pullValue();
|
4035
|
+
const value = this.getCurrentValue();
|
4036
|
+
if (value) {
|
4037
|
+
listener({
|
4038
|
+
type: "loaded",
|
4039
|
+
value,
|
4040
|
+
id: this.id
|
4041
|
+
});
|
4042
|
+
}
|
4043
|
+
}
|
3995
4044
|
subscribeToId(id, descriptor) {
|
3996
4045
|
if (this.isSubscribedToId(id)) {
|
4046
|
+
if (!this.closed) {
|
4047
|
+
return;
|
4048
|
+
}
|
4049
|
+
const child2 = this.childNodes.get(id);
|
4050
|
+
if (child2) {
|
4051
|
+
child2.pullValue((value) => this.handleChildUpdate(id, value));
|
4052
|
+
}
|
3997
4053
|
return;
|
3998
4054
|
}
|
3999
4055
|
this.idsSubscribed.add(id);
|
@@ -4011,6 +4067,9 @@ var SubscriptionScope = class _SubscriptionScope {
|
|
4011
4067
|
);
|
4012
4068
|
this.childNodes.set(id, child);
|
4013
4069
|
child.setListener((value) => this.handleChildUpdate(id, value));
|
4070
|
+
if (this.closed) {
|
4071
|
+
child.destroy();
|
4072
|
+
}
|
4014
4073
|
this.silenceUpdates = false;
|
4015
4074
|
}
|
4016
4075
|
loadChildren() {
|
@@ -4200,8 +4259,12 @@ var SubscriptionScope = class _SubscriptionScope {
|
|
4200
4259
|
);
|
4201
4260
|
this.childNodes.set(id, child);
|
4202
4261
|
child.setListener((value) => this.handleChildUpdate(id, value, key));
|
4262
|
+
if (this.closed) {
|
4263
|
+
child.destroy();
|
4264
|
+
}
|
4203
4265
|
}
|
4204
4266
|
destroy() {
|
4267
|
+
this.closed = true;
|
4205
4268
|
this.subscription.unsubscribe();
|
4206
4269
|
this.subscribers.clear();
|
4207
4270
|
this.childNodes.forEach((child) => child.destroy());
|
@@ -4227,12 +4290,18 @@ function getSubscriptionScope(value) {
|
|
4227
4290
|
enumerable: false,
|
4228
4291
|
configurable: false
|
4229
4292
|
});
|
4293
|
+
newSubscriptionScope.destroy();
|
4230
4294
|
return newSubscriptionScope;
|
4231
4295
|
}
|
4232
4296
|
function accessChildByKey(parent, childId, key) {
|
4233
4297
|
const subscriptionScope = getSubscriptionScope(parent);
|
4298
|
+
const node = subscriptionScope.childNodes.get(childId);
|
4234
4299
|
if (!subscriptionScope.isSubscribedToId(childId)) {
|
4235
4300
|
subscriptionScope.subscribeToKey(key);
|
4301
|
+
} else if (node && node.closed) {
|
4302
|
+
node.pullValue(
|
4303
|
+
(value2) => subscriptionScope.handleChildUpdate(childId, value2)
|
4304
|
+
);
|
4236
4305
|
}
|
4237
4306
|
const value = subscriptionScope.childValues.get(childId);
|
4238
4307
|
if (value?.type === "loaded") {
|
@@ -6078,4 +6147,4 @@ export {
|
|
6078
6147
|
JazzContextManager
|
6079
6148
|
};
|
6080
6149
|
/* istanbul ignore file -- @preserve */
|
6081
|
-
//# sourceMappingURL=chunk-
|
6150
|
+
//# sourceMappingURL=chunk-OTWWOZMB.js.map
|