jazz-tools 0.18.25 → 0.18.27
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/.turbo/turbo-build.log +41 -41
- package/CHANGELOG.md +21 -0
- package/dist/{chunk-DOCEAUVD.js → chunk-ZIAN4UY5.js} +338 -9
- package/dist/chunk-ZIAN4UY5.js.map +1 -0
- package/dist/index.js +97 -5
- package/dist/index.js.map +1 -1
- package/dist/media/{chunk-W3S526L3.js → chunk-K6GCHLQU.js} +1 -1
- package/dist/media/chunk-K6GCHLQU.js.map +1 -0
- package/dist/media/create-image/browser.d.ts +1 -1
- package/dist/media/create-image/react-native.d.ts +1 -1
- package/dist/media/create-image/react-native.d.ts.map +1 -1
- package/dist/media/create-image/server.d.ts +1 -1
- package/dist/media/create-image-factory.d.ts +5 -2
- package/dist/media/create-image-factory.d.ts.map +1 -1
- package/dist/media/index.browser.js +1 -1
- package/dist/media/index.d.ts +3 -4
- package/dist/media/index.d.ts.map +1 -1
- package/dist/media/index.js +1 -1
- package/dist/media/index.native.js +63 -28
- package/dist/media/index.native.js.map +1 -1
- package/dist/media/index.server.js +1 -1
- package/dist/react/index.js.map +1 -1
- package/dist/testing.js +1 -1
- package/dist/tools/coValues/coVector.d.ts +127 -0
- package/dist/tools/coValues/coVector.d.ts.map +1 -0
- package/dist/tools/coValues/request.d.ts +70 -0
- package/dist/tools/coValues/request.d.ts.map +1 -1
- package/dist/tools/exports.d.ts +1 -1
- package/dist/tools/exports.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/coExport.d.ts +2 -1
- package/dist/tools/implementation/zodSchema/coExport.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/runtimeConverters/coValueSchemaTransformation.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoVectorSchema.d.ts +47 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/CoVectorSchema.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts +2 -2
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts +2 -2
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/zodCo.d.ts +2 -1
- package/dist/tools/implementation/zodSchema/zodCo.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/zodSchema.d.ts +3 -2
- package/dist/tools/implementation/zodSchema/zodSchema.d.ts.map +1 -1
- package/dist/tools/internal.d.ts +2 -0
- package/dist/tools/internal.d.ts.map +1 -1
- package/dist/tools/tests/authenticate-request.test.d.ts +2 -0
- package/dist/tools/tests/authenticate-request.test.d.ts.map +1 -0
- package/dist/tools/tests/coVector.test-d.d.ts +2 -0
- package/dist/tools/tests/coVector.test-d.d.ts.map +1 -0
- package/dist/tools/tests/coVector.test.d.ts +2 -0
- package/dist/tools/tests/coVector.test.d.ts.map +1 -0
- package/package.json +8 -4
- package/src/media/create-image/react-native.ts +75 -30
- package/src/media/create-image-factory.test.ts +18 -0
- package/src/media/create-image-factory.ts +6 -1
- package/src/media/index.ts +7 -4
- package/src/tools/coValues/coVector.ts +432 -0
- package/src/tools/coValues/request.ts +188 -4
- package/src/tools/exports.ts +3 -0
- package/src/tools/implementation/zodSchema/coExport.ts +2 -0
- package/src/tools/implementation/zodSchema/runtimeConverters/coValueSchemaTransformation.ts +13 -0
- package/src/tools/implementation/zodSchema/schemaTypes/CoVectorSchema.ts +105 -0
- package/src/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.ts +9 -5
- package/src/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.ts +15 -9
- package/src/tools/implementation/zodSchema/zodCo.ts +15 -0
- package/src/tools/implementation/zodSchema/zodSchema.ts +15 -6
- package/src/tools/internal.ts +2 -0
- package/src/tools/tests/authenticate-request.test.ts +194 -0
- package/src/tools/tests/coVector.test-d.ts +40 -0
- package/src/tools/tests/coVector.test.ts +891 -0
- package/dist/chunk-DOCEAUVD.js.map +0 -1
- package/dist/media/chunk-W3S526L3.js.map +0 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> jazz-tools@0.18.
|
|
2
|
+
> jazz-tools@0.18.27 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","tools/ssr":"src/tools/ssr/index.ts"}
|
|
@@ -109,103 +109,103 @@
|
|
|
109
109
|
[34mESM[39m Build start
|
|
110
110
|
[32mESM[39m [1mdist/tiptap/index.js [22m[32m564.00 B[39m
|
|
111
111
|
[32mESM[39m [1mdist/tiptap/index.js.map [22m[32m1.21 KB[39m
|
|
112
|
-
[32mESM[39m ⚡️ Build success in
|
|
113
|
-
[32mESM[39m [1mdist/worker/index.js [22m[32m3.16 KB[39m
|
|
112
|
+
[32mESM[39m ⚡️ Build success in 39ms
|
|
114
113
|
[32mESM[39m [1mdist/worker/edge-wasm.js [22m[32m215.00 B[39m
|
|
114
|
+
[32mESM[39m [1mdist/worker/index.js [22m[32m3.16 KB[39m
|
|
115
115
|
[32mESM[39m [1mdist/worker/napi-crypto.js [22m[32m110.00 B[39m
|
|
116
|
-
[32mESM[39m [1mdist/worker/index.js.map [22m[32m6.14 KB[39m
|
|
117
116
|
[32mESM[39m [1mdist/worker/edge-wasm.js.map [22m[32m434.00 B[39m
|
|
117
|
+
[32mESM[39m [1mdist/worker/index.js.map [22m[32m6.14 KB[39m
|
|
118
118
|
[32mESM[39m [1mdist/worker/napi-crypto.js.map [22m[32m162.00 B[39m
|
|
119
|
-
[32mESM[39m ⚡️ Build success in
|
|
119
|
+
[32mESM[39m ⚡️ Build success in 39ms
|
|
120
120
|
[32mESM[39m [1mdist/better-auth/auth/client.js [22m[32m4.50 KB[39m
|
|
121
121
|
[32mESM[39m [1mdist/better-auth/auth/server.js [22m[32m8.36 KB[39m
|
|
122
122
|
[32mESM[39m [1mdist/better-auth/auth/react.js [22m[32m799.00 B[39m
|
|
123
|
-
[32mESM[39m [1mdist/better-auth/auth/server.js.map [22m[32m15.29 KB[39m
|
|
124
123
|
[32mESM[39m [1mdist/better-auth/auth/client.js.map [22m[32m8.32 KB[39m
|
|
124
|
+
[32mESM[39m [1mdist/better-auth/auth/server.js.map [22m[32m15.29 KB[39m
|
|
125
125
|
[32mESM[39m [1mdist/better-auth/auth/react.js.map [22m[32m2.04 KB[39m
|
|
126
|
-
[32mESM[39m ⚡️ Build success in
|
|
126
|
+
[32mESM[39m ⚡️ Build success in 29ms
|
|
127
127
|
[32mESM[39m [1mdist/media/index.js [22m[32m236.00 B[39m
|
|
128
128
|
[32mESM[39m [1mdist/media/index.browser.js [22m[32m2.79 KB[39m
|
|
129
|
-
[32mESM[39m [1mdist/media/index.native.js [22m[
|
|
129
|
+
[32mESM[39m [1mdist/media/index.native.js [22m[32m4.01 KB[39m
|
|
130
130
|
[32mESM[39m [1mdist/media/index.server.js [22m[32m2.95 KB[39m
|
|
131
|
-
[32mESM[39m [1mdist/media/chunk-
|
|
131
|
+
[32mESM[39m [1mdist/media/chunk-K6GCHLQU.js [22m[32m6.47 KB[39m
|
|
132
132
|
[32mESM[39m [1mdist/media/index.js.map [22m[32m71.00 B[39m
|
|
133
|
-
[32mESM[39m [1mdist/media/index.native.js.map [22m[32m6.09 KB[39m
|
|
134
133
|
[32mESM[39m [1mdist/media/index.browser.js.map [22m[32m6.15 KB[39m
|
|
134
|
+
[32mESM[39m [1mdist/media/index.native.js.map [22m[32m8.10 KB[39m
|
|
135
135
|
[32mESM[39m [1mdist/media/index.server.js.map [22m[32m6.37 KB[39m
|
|
136
|
-
[32mESM[39m [1mdist/media/chunk-
|
|
137
|
-
[32mESM[39m ⚡️ Build success in
|
|
136
|
+
[32mESM[39m [1mdist/media/chunk-K6GCHLQU.js.map [22m[32m16.64 KB[39m
|
|
137
|
+
[32mESM[39m ⚡️ Build success in 36ms
|
|
138
|
+
[32mESM[39m [1mdist/react-native/index.js [22m[32m2.53 KB[39m
|
|
138
139
|
[32mESM[39m [1mdist/react-native/testing.js [22m[32m120.00 B[39m
|
|
139
140
|
[32mESM[39m [1mdist/react-native/crypto.js [22m[32m161.00 B[39m
|
|
140
|
-
[32mESM[39m [1mdist/react-native/index.js
|
|
141
|
+
[32mESM[39m [1mdist/react-native/index.js.map [22m[32m5.68 KB[39m
|
|
141
142
|
[32mESM[39m [1mdist/react-native/testing.js.map [22m[32m176.00 B[39m
|
|
142
143
|
[32mESM[39m [1mdist/react-native/crypto.js.map [22m[32m197.00 B[39m
|
|
143
|
-
[32mESM[39m
|
|
144
|
-
[32mESM[39m ⚡️ Build success in 36ms
|
|
144
|
+
[32mESM[39m ⚡️ Build success in 33ms
|
|
145
145
|
[32mESM[39m [1mdist/react-core/index.js [22m[32m13.94 KB[39m
|
|
146
146
|
[32mESM[39m [1mdist/react-core/testing.js [22m[32m1.22 KB[39m
|
|
147
147
|
[32mESM[39m [1mdist/react-core/chunk-7DYMJ74I.js [22m[32m279.00 B[39m
|
|
148
148
|
[32mESM[39m [1mdist/react-core/testing.js.map [22m[32m1.86 KB[39m
|
|
149
|
-
[32mESM[39m [1mdist/react-core/index.js.map [22m[32m42.53 KB[39m
|
|
150
149
|
[32mESM[39m [1mdist/react-core/chunk-7DYMJ74I.js.map [22m[32m533.00 B[39m
|
|
151
|
-
[32mESM[39m
|
|
150
|
+
[32mESM[39m [1mdist/react-core/index.js.map [22m[32m42.53 KB[39m
|
|
151
|
+
[32mESM[39m ⚡️ Build success in 35ms
|
|
152
152
|
[32mESM[39m [1mdist/expo/index.js [22m[32m4.68 KB[39m
|
|
153
153
|
[32mESM[39m [1mdist/expo/testing.js [22m[32m112.00 B[39m
|
|
154
154
|
[32mESM[39m [1mdist/expo/crypto.js [22m[32m153.00 B[39m
|
|
155
155
|
[32mESM[39m [1mdist/expo/index.js.map [22m[32m10.23 KB[39m
|
|
156
|
-
[32mESM[39m [1mdist/expo/crypto.js.map [22m[32m189.00 B[39m
|
|
157
156
|
[32mESM[39m [1mdist/expo/testing.js.map [22m[32m168.00 B[39m
|
|
158
|
-
[32mESM[39m
|
|
157
|
+
[32mESM[39m [1mdist/expo/crypto.js.map [22m[32m189.00 B[39m
|
|
158
|
+
[32mESM[39m ⚡️ Build success in 38ms
|
|
159
159
|
[32mESM[39m [1mdist/browser/index.js [22m[32m14.06 KB[39m
|
|
160
160
|
[32mESM[39m [1mdist/browser/index.js.map [22m[32m29.94 KB[39m
|
|
161
|
-
[32mESM[39m ⚡️ Build success in
|
|
162
|
-
[32mESM[39m [1mdist/
|
|
163
|
-
[32mESM[39m [1mdist/
|
|
164
|
-
[32mESM[39m ⚡️ Build success in
|
|
161
|
+
[32mESM[39m ⚡️ Build success in 46ms
|
|
162
|
+
[32mESM[39m [1mdist/prosemirror/index.js [22m[32m77.76 KB[39m
|
|
163
|
+
[32mESM[39m [1mdist/prosemirror/index.js.map [22m[32m307.20 KB[39m
|
|
164
|
+
[32mESM[39m ⚡️ Build success in 57ms
|
|
165
165
|
[32mESM[39m [1mdist/react-native-core/index.js [22m[32m18.93 KB[39m
|
|
166
166
|
[32mESM[39m [1mdist/react-native-core/testing.js [22m[32m119.00 B[39m
|
|
167
167
|
[32mESM[39m [1mdist/react-native-core/crypto.js [22m[32m2.10 KB[39m
|
|
168
168
|
[32mESM[39m [1mdist/react-native-core/index.js.map [22m[32m38.12 KB[39m
|
|
169
|
-
[32mESM[39m [1mdist/react-native-core/crypto.js.map [22m[32m4.25 KB[39m
|
|
170
169
|
[32mESM[39m [1mdist/react-native-core/testing.js.map [22m[32m175.00 B[39m
|
|
171
|
-
[32mESM[39m
|
|
170
|
+
[32mESM[39m [1mdist/react-native-core/crypto.js.map [22m[32m4.25 KB[39m
|
|
171
|
+
[32mESM[39m ⚡️ Build success in 55ms
|
|
172
172
|
[32mESM[39m [1mdist/react/testing.js [22m[32m122.00 B[39m
|
|
173
173
|
[32mESM[39m [1mdist/react/ssr.js [22m[32m697.00 B[39m
|
|
174
174
|
[32mESM[39m [1mdist/react/index.js [22m[32m25.32 KB[39m
|
|
175
175
|
[32mESM[39m [1mdist/react/testing.js.map [22m[32m165.00 B[39m
|
|
176
176
|
[32mESM[39m [1mdist/react/ssr.js.map [22m[32m1.11 KB[39m
|
|
177
|
-
[32mESM[39m [1mdist/react/index.js.map [22m[32m54.
|
|
178
|
-
[32mESM[39m ⚡️ Build success in
|
|
179
|
-
[32mESM[39m [1mdist/
|
|
180
|
-
[32mESM[39m [1mdist/
|
|
181
|
-
[32mESM[39m ⚡️ Build success in
|
|
177
|
+
[32mESM[39m [1mdist/react/index.js.map [22m[32m54.33 KB[39m
|
|
178
|
+
[32mESM[39m ⚡️ Build success in 49ms
|
|
179
|
+
[32mESM[39m [1mdist/better-auth/database-adapter/index.js [22m[32m26.34 KB[39m
|
|
180
|
+
[32mESM[39m [1mdist/better-auth/database-adapter/index.js.map [22m[32m57.62 KB[39m
|
|
181
|
+
[32mESM[39m ⚡️ Build success in 48ms
|
|
182
182
|
[32mESM[39m [1mdist/inspector/index.js [22m[32m71.88 KB[39m
|
|
183
183
|
[32mESM[39m [1mdist/inspector/index.js.map [22m[32m124.87 KB[39m
|
|
184
|
-
[32mESM[39m ⚡️ Build success in
|
|
185
|
-
[32mESM[39m [1mdist/tools/ssr.js [22m[32m156.00 B[39m
|
|
186
|
-
[32mESM[39m [1mdist/index.js [22m[32m26.24 KB[39m
|
|
184
|
+
[32mESM[39m ⚡️ Build success in 74ms
|
|
187
185
|
[32mESM[39m [1mdist/chunk-M2HGBOXS.js [22m[32m694.00 B[39m
|
|
188
186
|
[32mESM[39m [1mdist/chunk-PZ5AY32C.js [22m[32m233.00 B[39m
|
|
189
187
|
[32mESM[39m [1mdist/testing.js [22m[32m8.32 KB[39m
|
|
190
|
-
[32mESM[39m [1mdist/
|
|
191
|
-
[32mESM[39m [1mdist/
|
|
188
|
+
[32mESM[39m [1mdist/tools/ssr.js [22m[32m156.00 B[39m
|
|
189
|
+
[32mESM[39m [1mdist/index.js [22m[32m28.78 KB[39m
|
|
190
|
+
[32mESM[39m [1mdist/chunk-ZIAN4UY5.js [22m[32m189.00 KB[39m
|
|
192
191
|
[32mESM[39m [1mdist/chunk-M2HGBOXS.js.map [22m[32m1.10 KB[39m
|
|
193
|
-
[32mESM[39m [1mdist/index.js.map [22m[32m52.92 KB[39m
|
|
194
192
|
[32mESM[39m [1mdist/chunk-PZ5AY32C.js.map [22m[32m71.00 B[39m
|
|
195
193
|
[32mESM[39m [1mdist/testing.js.map [22m[32m15.83 KB[39m
|
|
196
|
-
[32mESM[39m [1mdist/
|
|
197
|
-
[32mESM[39m
|
|
194
|
+
[32mESM[39m [1mdist/tools/ssr.js.map [22m[32m71.00 B[39m
|
|
195
|
+
[32mESM[39m [1mdist/index.js.map [22m[32m59.94 KB[39m
|
|
196
|
+
[32mESM[39m [1mdist/chunk-ZIAN4UY5.js.map [22m[32m447.28 KB[39m
|
|
197
|
+
[32mESM[39m ⚡️ Build success in 81ms
|
|
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-A7UAELEG.js [22m[32m1.54 MB[39m
|
|
201
201
|
[32mESM[39m [1mdist/inspector/custom-element-A7UAELEG.js.map [22m[32m2.36 MB[39m
|
|
202
|
-
[32mESM[39m ⚡️ Build success in
|
|
202
|
+
[32mESM[39m ⚡️ Build success in 124ms
|
|
203
203
|
|
|
204
|
-
> jazz-tools@0.18.
|
|
204
|
+
> jazz-tools@0.18.27 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.27 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,26 @@
|
|
|
1
1
|
# jazz-tools
|
|
2
2
|
|
|
3
|
+
## 0.18.27
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6c6eb35: feat: enabled the usage of "expo-image-manipulator" as resize engine in react-native
|
|
8
|
+
- 6ca0b59: feat: Add generateAuthToken and authenticateRequest
|
|
9
|
+
- 88c5f1c: fix: createImage return type now has the original image already loaded
|
|
10
|
+
- cojson@0.18.27
|
|
11
|
+
- cojson-storage-indexeddb@0.18.27
|
|
12
|
+
- cojson-transport-ws@0.18.27
|
|
13
|
+
|
|
14
|
+
## 0.18.26
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 4e0ea26: Added new CoVector type of CoValue
|
|
19
|
+
- Updated dependencies [f956cd3]
|
|
20
|
+
- cojson@0.18.26
|
|
21
|
+
- cojson-storage-indexeddb@0.18.26
|
|
22
|
+
- cojson-transport-ws@0.18.26
|
|
23
|
+
|
|
3
24
|
## 0.18.25
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
|
@@ -3299,6 +3299,279 @@ var SchemaUnion = class _SchemaUnion extends CoValueBase {
|
|
|
3299
3299
|
}
|
|
3300
3300
|
};
|
|
3301
3301
|
|
|
3302
|
+
// src/tools/coValues/coVector.ts
|
|
3303
|
+
import { cojsonInternals as cojsonInternals5 } from "cojson";
|
|
3304
|
+
var _CoVector = class _CoVector extends Float32Array {
|
|
3305
|
+
static get [Symbol.species]() {
|
|
3306
|
+
return Float32Array;
|
|
3307
|
+
}
|
|
3308
|
+
constructor(options) {
|
|
3309
|
+
const dimensionsCount = new.target.requiredDimensionsCount;
|
|
3310
|
+
if (dimensionsCount === void 0) {
|
|
3311
|
+
throw new Error(
|
|
3312
|
+
"Instantiating CoVector without a dimensions count is not allowed. Use co.vector(...).create() instead."
|
|
3313
|
+
);
|
|
3314
|
+
}
|
|
3315
|
+
super(dimensionsCount);
|
|
3316
|
+
const isFromRaw = "fromRaw" in options;
|
|
3317
|
+
const raw = isFromRaw ? options.fromRaw : options.owner.$jazz.raw.createBinaryStream();
|
|
3318
|
+
Object.defineProperties(this, {
|
|
3319
|
+
[TypeSym]: { value: "BinaryCoStream", enumerable: false },
|
|
3320
|
+
$jazz: {
|
|
3321
|
+
value: new CoVectorJazzApi(this, raw),
|
|
3322
|
+
enumerable: false
|
|
3323
|
+
},
|
|
3324
|
+
_isVectorLoaded: { value: false, enumerable: false, writable: true },
|
|
3325
|
+
_requiredDimensionsCount: {
|
|
3326
|
+
value: dimensionsCount,
|
|
3327
|
+
enumerable: false,
|
|
3328
|
+
writable: false
|
|
3329
|
+
}
|
|
3330
|
+
});
|
|
3331
|
+
if (isFromRaw) {
|
|
3332
|
+
this.loadVectorData();
|
|
3333
|
+
}
|
|
3334
|
+
}
|
|
3335
|
+
/** @category Internals */
|
|
3336
|
+
static fromRaw(raw) {
|
|
3337
|
+
return new this({ fromRaw: raw });
|
|
3338
|
+
}
|
|
3339
|
+
/**
|
|
3340
|
+
* Create a new `CoVector` instance with the given vector.
|
|
3341
|
+
*
|
|
3342
|
+
* @category Creation
|
|
3343
|
+
* @deprecated Use `co.vector(...).create` instead.
|
|
3344
|
+
*/
|
|
3345
|
+
static create(vector, options) {
|
|
3346
|
+
const vectorAsFloat32Array = vector instanceof Float32Array ? vector : new Float32Array(vector);
|
|
3347
|
+
const givenVectorDimensions = vectorAsFloat32Array.byteLength / vectorAsFloat32Array.BYTES_PER_ELEMENT;
|
|
3348
|
+
if (this.requiredDimensionsCount !== void 0 && givenVectorDimensions !== this.requiredDimensionsCount) {
|
|
3349
|
+
throw new Error(
|
|
3350
|
+
`Vector dimension mismatch! Expected ${this.requiredDimensionsCount} dimensions, got ${givenVectorDimensions}`
|
|
3351
|
+
);
|
|
3352
|
+
}
|
|
3353
|
+
const coVector = new this(parseCoValueCreateOptions(options));
|
|
3354
|
+
coVector.setVectorData(vectorAsFloat32Array);
|
|
3355
|
+
const byteArray = _CoVector.toByteArray(vectorAsFloat32Array);
|
|
3356
|
+
coVector.$jazz.raw.startBinaryStream({
|
|
3357
|
+
mimeType: "application/vector+octet-stream",
|
|
3358
|
+
totalSizeBytes: byteArray.byteLength
|
|
3359
|
+
});
|
|
3360
|
+
const chunkSize = cojsonInternals5.TRANSACTION_CONFIG.MAX_RECOMMENDED_TX_SIZE;
|
|
3361
|
+
for (let idx = 0; idx < byteArray.length; idx += chunkSize) {
|
|
3362
|
+
coVector.$jazz.raw.pushBinaryStreamChunk(
|
|
3363
|
+
byteArray.slice(idx, idx + chunkSize)
|
|
3364
|
+
);
|
|
3365
|
+
}
|
|
3366
|
+
coVector.$jazz.raw.endBinaryStream();
|
|
3367
|
+
return coVector;
|
|
3368
|
+
}
|
|
3369
|
+
static toByteArray(vector) {
|
|
3370
|
+
return new Uint8Array(vector.buffer, vector.byteOffset, vector.byteLength);
|
|
3371
|
+
}
|
|
3372
|
+
static fromByteArray(bytesChunks) {
|
|
3373
|
+
const total = bytesChunks.reduce((acc, c) => acc + c.byteLength, 0);
|
|
3374
|
+
if (total % 4 !== 0)
|
|
3375
|
+
throw new Error("[INTERNAL] Total byte length must be multiple of 4");
|
|
3376
|
+
const u8 = new Uint8Array(total);
|
|
3377
|
+
let off = 0;
|
|
3378
|
+
for (const c of bytesChunks) {
|
|
3379
|
+
u8.set(c, off);
|
|
3380
|
+
off += c.byteLength;
|
|
3381
|
+
}
|
|
3382
|
+
return new Float32Array(u8.buffer, u8.byteOffset, total / 4);
|
|
3383
|
+
}
|
|
3384
|
+
loadVectorData() {
|
|
3385
|
+
if (this._isVectorLoaded === true) {
|
|
3386
|
+
return;
|
|
3387
|
+
}
|
|
3388
|
+
const chunks = this.$jazz.raw.getBinaryChunks();
|
|
3389
|
+
if (!chunks) {
|
|
3390
|
+
throw new Error(`CoVector '${this.$jazz.raw.id}' is not loaded`);
|
|
3391
|
+
}
|
|
3392
|
+
const vector = _CoVector.fromByteArray(chunks.chunks);
|
|
3393
|
+
if (vector.length !== this._requiredDimensionsCount) {
|
|
3394
|
+
throw new Error(
|
|
3395
|
+
`Vector dimension mismatch! CoVector '${this.$jazz.raw.id}' loaded with ${vector.length} dimensions, but the schema requires ${this._requiredDimensionsCount} dimensions`
|
|
3396
|
+
);
|
|
3397
|
+
}
|
|
3398
|
+
this.setVectorData(vector);
|
|
3399
|
+
return;
|
|
3400
|
+
}
|
|
3401
|
+
setVectorData(vector) {
|
|
3402
|
+
super.set(vector, 0);
|
|
3403
|
+
this._isVectorLoaded = true;
|
|
3404
|
+
}
|
|
3405
|
+
/**
|
|
3406
|
+
* Get a JSON representation of the `CoVector`
|
|
3407
|
+
* @category Content
|
|
3408
|
+
*/
|
|
3409
|
+
toJSON() {
|
|
3410
|
+
return Array.from(this);
|
|
3411
|
+
}
|
|
3412
|
+
/** @internal */
|
|
3413
|
+
[inspect]() {
|
|
3414
|
+
return this.toJSON();
|
|
3415
|
+
}
|
|
3416
|
+
/**
|
|
3417
|
+
* Load a `CoVector`
|
|
3418
|
+
*
|
|
3419
|
+
* @category Subscription & Loading
|
|
3420
|
+
* @deprecated Use `co.vector(...).load` instead.
|
|
3421
|
+
*/
|
|
3422
|
+
static async load(id, options) {
|
|
3423
|
+
const coVector = await loadCoValueWithoutMe(this, id, options);
|
|
3424
|
+
if (!coVector?.$jazz.raw.isBinaryStreamEnded()) {
|
|
3425
|
+
return new Promise((resolve) => {
|
|
3426
|
+
subscribeToCoValueWithoutMe(
|
|
3427
|
+
this,
|
|
3428
|
+
id,
|
|
3429
|
+
options || {},
|
|
3430
|
+
(value, unsubscribe) => {
|
|
3431
|
+
if (value.$jazz.raw.isBinaryStreamEnded()) {
|
|
3432
|
+
unsubscribe();
|
|
3433
|
+
resolve(value);
|
|
3434
|
+
}
|
|
3435
|
+
}
|
|
3436
|
+
);
|
|
3437
|
+
});
|
|
3438
|
+
}
|
|
3439
|
+
coVector.loadVectorData();
|
|
3440
|
+
return coVector;
|
|
3441
|
+
}
|
|
3442
|
+
static subscribe(id, ...args) {
|
|
3443
|
+
const { options, listener } = parseSubscribeRestArgs(args);
|
|
3444
|
+
return subscribeToCoValueWithoutMe(this, id, options, listener);
|
|
3445
|
+
}
|
|
3446
|
+
// CoVector mutation method overrides, as CoVectors aren't meant to be mutated
|
|
3447
|
+
/**
|
|
3448
|
+
* Calling `copyWithin` on a CoVector is forbidden. CoVectors are immutable.
|
|
3449
|
+
* @deprecated If you want to change the vector, replace the former instance of CoVector with a new one.
|
|
3450
|
+
*/
|
|
3451
|
+
copyWithin(target, start, end) {
|
|
3452
|
+
throw new Error("Cannot mutate a CoVector using `copyWithin`");
|
|
3453
|
+
}
|
|
3454
|
+
/**
|
|
3455
|
+
* Calling `fill` on a CoVector is forbidden. CoVectors are immutable.
|
|
3456
|
+
* @deprecated If you want to change the vector, replace the former instance of CoVector with a new one.
|
|
3457
|
+
*/
|
|
3458
|
+
fill(value, start, end) {
|
|
3459
|
+
throw new Error("Cannot mutate a CoVector using `fill`");
|
|
3460
|
+
}
|
|
3461
|
+
/**
|
|
3462
|
+
* Calling `reverse` on a CoVector is forbidden. CoVectors are immutable.
|
|
3463
|
+
* @deprecated If you want to change the vector, replace the former instance of CoVector with a new one.
|
|
3464
|
+
*/
|
|
3465
|
+
reverse() {
|
|
3466
|
+
throw new Error("Cannot mutate a CoVector using `reverse`");
|
|
3467
|
+
}
|
|
3468
|
+
/**
|
|
3469
|
+
* Calling `set` on a CoVector is forbidden. CoVectors are immutable.
|
|
3470
|
+
* @deprecated If you want to change the vector, replace the former instance of CoVector with a new one.
|
|
3471
|
+
// */
|
|
3472
|
+
set(array2, offset) {
|
|
3473
|
+
throw new Error("Cannot mutate a CoVector using `set`");
|
|
3474
|
+
}
|
|
3475
|
+
/**
|
|
3476
|
+
* Calling `sort` on a CoVector is forbidden. CoVectors are immutable.
|
|
3477
|
+
* @deprecated If you want to change the vector, replace the former instance of CoVector with a new one.
|
|
3478
|
+
*/
|
|
3479
|
+
sort(compareFn) {
|
|
3480
|
+
throw new Error("Cannot mutate a CoVector using `sort`");
|
|
3481
|
+
}
|
|
3482
|
+
};
|
|
3483
|
+
_CoVector.requiredDimensionsCount = void 0;
|
|
3484
|
+
var CoVector = _CoVector;
|
|
3485
|
+
var CoVectorJazzApi = class extends CoValueJazzApi {
|
|
3486
|
+
constructor(coVector, raw) {
|
|
3487
|
+
super(coVector);
|
|
3488
|
+
this.coVector = coVector;
|
|
3489
|
+
this.raw = raw;
|
|
3490
|
+
}
|
|
3491
|
+
get owner() {
|
|
3492
|
+
return getCoValueOwner(this.coVector);
|
|
3493
|
+
}
|
|
3494
|
+
/**
|
|
3495
|
+
* An instance method to subscribe to an existing `CoVector`
|
|
3496
|
+
* @category Subscription & Loading
|
|
3497
|
+
*/
|
|
3498
|
+
subscribe(listener) {
|
|
3499
|
+
return subscribeToExistingCoValue(this.coVector, {}, listener);
|
|
3500
|
+
}
|
|
3501
|
+
/**
|
|
3502
|
+
* Wait for the `CoVector` to be uploaded to the other peers.
|
|
3503
|
+
*
|
|
3504
|
+
* @category Subscription & Loading
|
|
3505
|
+
*/
|
|
3506
|
+
waitForSync(options) {
|
|
3507
|
+
return this.raw.core.waitForSync(options);
|
|
3508
|
+
}
|
|
3509
|
+
// Vector operations
|
|
3510
|
+
/**
|
|
3511
|
+
* Calculate the magnitude of this vector.
|
|
3512
|
+
*/
|
|
3513
|
+
magnitude() {
|
|
3514
|
+
return VectorCalculation.magnitude(this.coVector);
|
|
3515
|
+
}
|
|
3516
|
+
/**
|
|
3517
|
+
* Normalize this vector.
|
|
3518
|
+
* @returns A new instance of a normalized vector.
|
|
3519
|
+
*/
|
|
3520
|
+
normalize() {
|
|
3521
|
+
return VectorCalculation.normalize(this.coVector);
|
|
3522
|
+
}
|
|
3523
|
+
/**
|
|
3524
|
+
* Calculate the dot product of this vector and another vector.
|
|
3525
|
+
*/
|
|
3526
|
+
dotProduct(otherVector) {
|
|
3527
|
+
return VectorCalculation.dotProduct(this.coVector, otherVector);
|
|
3528
|
+
}
|
|
3529
|
+
/**
|
|
3530
|
+
* Calculate the cosine similarity between this vector and another vector.
|
|
3531
|
+
*
|
|
3532
|
+
* @returns A value between `-1` and `1`:
|
|
3533
|
+
* - `1` means the vectors are identical
|
|
3534
|
+
* - `0` means the vectors are orthogonal (i.e. no similarity)
|
|
3535
|
+
* - `-1` means the vectors are opposite direction (perfectly dissimilar)
|
|
3536
|
+
*/
|
|
3537
|
+
cosineSimilarity(otherVector) {
|
|
3538
|
+
return VectorCalculation.cosineSimilarity(this.coVector, otherVector);
|
|
3539
|
+
}
|
|
3540
|
+
};
|
|
3541
|
+
var VectorCalculation = {
|
|
3542
|
+
magnitude: (vector) => {
|
|
3543
|
+
let sum = 0;
|
|
3544
|
+
for (const v of vector) {
|
|
3545
|
+
sum += v * v;
|
|
3546
|
+
}
|
|
3547
|
+
return Math.sqrt(sum);
|
|
3548
|
+
},
|
|
3549
|
+
normalize: (vector) => {
|
|
3550
|
+
const mag = VectorCalculation.magnitude(vector);
|
|
3551
|
+
if (mag === 0) {
|
|
3552
|
+
return new Float32Array(vector.length).fill(0);
|
|
3553
|
+
}
|
|
3554
|
+
return vector.map((v) => v / mag);
|
|
3555
|
+
},
|
|
3556
|
+
dotProduct: (vectorA, vectorB) => {
|
|
3557
|
+
if (vectorA.length !== vectorB.length) {
|
|
3558
|
+
throw new Error(
|
|
3559
|
+
`Vector dimensions don't match: ${vectorA.length} vs ${vectorB.length}`
|
|
3560
|
+
);
|
|
3561
|
+
}
|
|
3562
|
+
return vectorA.reduce((sum, a, i) => sum + a * vectorB[i], 0);
|
|
3563
|
+
},
|
|
3564
|
+
cosineSimilarity: (vectorA, vectorB) => {
|
|
3565
|
+
const magnitudeA = VectorCalculation.magnitude(vectorA);
|
|
3566
|
+
const magnitudeB = VectorCalculation.magnitude(vectorB);
|
|
3567
|
+
if (magnitudeA === 0 || magnitudeB === 0) {
|
|
3568
|
+
return 0;
|
|
3569
|
+
}
|
|
3570
|
+
const dotProductAB = VectorCalculation.dotProduct(vectorA, vectorB);
|
|
3571
|
+
return dotProductAB / (magnitudeA * magnitudeB);
|
|
3572
|
+
}
|
|
3573
|
+
};
|
|
3574
|
+
|
|
3302
3575
|
// src/tools/implementation/anonymousJazzAgent.ts
|
|
3303
3576
|
var _a;
|
|
3304
3577
|
_a = TypeSym;
|
|
@@ -3560,7 +3833,7 @@ function applyCoValueMigrations(instance) {
|
|
|
3560
3833
|
|
|
3561
3834
|
// src/tools/subscribe/CoValueCoreSubscription.ts
|
|
3562
3835
|
import {
|
|
3563
|
-
cojsonInternals as
|
|
3836
|
+
cojsonInternals as cojsonInternals6
|
|
3564
3837
|
} from "cojson";
|
|
3565
3838
|
var CoValueCoreSubscription = class {
|
|
3566
3839
|
constructor(localNode, id, listener, skipRetry, branch) {
|
|
@@ -3607,7 +3880,7 @@ var CoValueCoreSubscription = class {
|
|
|
3607
3880
|
* Either subscribes directly or attempts to get the requested branch.
|
|
3608
3881
|
*/
|
|
3609
3882
|
handleAvailableSource() {
|
|
3610
|
-
if (!this.branchName || !
|
|
3883
|
+
if (!this.branchName || !cojsonInternals6.canBeBranched(this.source)) {
|
|
3611
3884
|
this.subscribe(this.source.getCurrentContent());
|
|
3612
3885
|
return;
|
|
3613
3886
|
}
|
|
@@ -4740,6 +5013,16 @@ var coFileStreamDefiner = () => {
|
|
|
4740
5013
|
const coreSchema = createCoreFileStreamSchema();
|
|
4741
5014
|
return hydrateCoreCoValueSchema(coreSchema);
|
|
4742
5015
|
};
|
|
5016
|
+
var coVectorDefiner = (dimensions) => {
|
|
5017
|
+
const isPositiveInteger = Number.isInteger(dimensions) && dimensions > 0;
|
|
5018
|
+
if (!isPositiveInteger) {
|
|
5019
|
+
throw new Error(
|
|
5020
|
+
"co.vector() expects the vector dimensions count to be a positive integer"
|
|
5021
|
+
);
|
|
5022
|
+
}
|
|
5023
|
+
const coreSchema = createCoreCoVectorSchema(dimensions);
|
|
5024
|
+
return hydrateCoreCoValueSchema(coreSchema);
|
|
5025
|
+
};
|
|
4743
5026
|
var coPlainTextDefiner = () => {
|
|
4744
5027
|
const coreSchema = createCoreCoPlainTextSchema();
|
|
4745
5028
|
return hydrateCoreCoValueSchema(coreSchema);
|
|
@@ -4773,6 +5056,7 @@ __export(coExport_exports, {
|
|
|
4773
5056
|
Optional: () => CoOptionalSchema,
|
|
4774
5057
|
PlainText: () => PlainTextSchema,
|
|
4775
5058
|
RichText: () => RichTextSchema,
|
|
5059
|
+
Vector: () => CoVectorSchema,
|
|
4776
5060
|
account: () => coAccountDefiner,
|
|
4777
5061
|
discriminatedUnion: () => coDiscriminatedUnionDefiner,
|
|
4778
5062
|
feed: () => coFeedDefiner,
|
|
@@ -4785,7 +5069,8 @@ __export(coExport_exports, {
|
|
|
4785
5069
|
plainText: () => coPlainTextDefiner,
|
|
4786
5070
|
profile: () => coProfileDefiner,
|
|
4787
5071
|
record: () => coRecordDefiner,
|
|
4788
|
-
richText: () => coRichTextDefiner
|
|
5072
|
+
richText: () => coRichTextDefiner,
|
|
5073
|
+
vector: () => coVectorDefiner
|
|
4789
5074
|
});
|
|
4790
5075
|
|
|
4791
5076
|
// src/tools/implementation/zodSchema/schemaTypes/CoMapSchema.ts
|
|
@@ -5052,6 +5337,41 @@ var FileStreamSchema = class {
|
|
|
5052
5337
|
}
|
|
5053
5338
|
};
|
|
5054
5339
|
|
|
5340
|
+
// src/tools/implementation/zodSchema/schemaTypes/CoVectorSchema.ts
|
|
5341
|
+
function createCoreCoVectorSchema(dimensions) {
|
|
5342
|
+
return {
|
|
5343
|
+
collaborative: true,
|
|
5344
|
+
builtin: "CoVector",
|
|
5345
|
+
dimensions
|
|
5346
|
+
};
|
|
5347
|
+
}
|
|
5348
|
+
var CoVectorSchema = class {
|
|
5349
|
+
constructor(dimensions, coValueClass) {
|
|
5350
|
+
this.dimensions = dimensions;
|
|
5351
|
+
this.coValueClass = coValueClass;
|
|
5352
|
+
this.collaborative = true;
|
|
5353
|
+
this.builtin = "CoVector";
|
|
5354
|
+
}
|
|
5355
|
+
create(vector, options) {
|
|
5356
|
+
return this.coValueClass.create(vector, options);
|
|
5357
|
+
}
|
|
5358
|
+
/**
|
|
5359
|
+
* Load a `CoVector` with a given ID.
|
|
5360
|
+
*/
|
|
5361
|
+
load(id, options) {
|
|
5362
|
+
return this.coValueClass.load(id, options);
|
|
5363
|
+
}
|
|
5364
|
+
subscribe(...args) {
|
|
5365
|
+
return this.coValueClass.subscribe(...args);
|
|
5366
|
+
}
|
|
5367
|
+
getCoValueClass() {
|
|
5368
|
+
return this.coValueClass;
|
|
5369
|
+
}
|
|
5370
|
+
optional() {
|
|
5371
|
+
return coOptionalDefiner(this);
|
|
5372
|
+
}
|
|
5373
|
+
};
|
|
5374
|
+
|
|
5055
5375
|
// src/tools/implementation/zodSchema/schemaTypes/AccountSchema.ts
|
|
5056
5376
|
function createCoreAccountSchema(shape) {
|
|
5057
5377
|
return {
|
|
@@ -5318,6 +5638,7 @@ function isCoValueSchema(schema) {
|
|
|
5318
5638
|
return isAnyCoValueSchema2(schema) && "getCoValueClass" in schema;
|
|
5319
5639
|
}
|
|
5320
5640
|
function hydrateCoreCoValueSchema(schema) {
|
|
5641
|
+
var _a2;
|
|
5321
5642
|
if (isCoValueSchema(schema)) {
|
|
5322
5643
|
return schema;
|
|
5323
5644
|
}
|
|
@@ -5366,6 +5687,14 @@ function hydrateCoreCoValueSchema(schema) {
|
|
|
5366
5687
|
} else if (schema.builtin === "FileStream") {
|
|
5367
5688
|
const coValueClass = FileStream;
|
|
5368
5689
|
return new FileStreamSchema(coValueClass);
|
|
5690
|
+
} else if (schema.builtin === "CoVector") {
|
|
5691
|
+
const dimensions = schema.dimensions;
|
|
5692
|
+
const coValueClass = (_a2 = class extends CoVector {
|
|
5693
|
+
}, _a2.requiredDimensionsCount = dimensions, _a2);
|
|
5694
|
+
return new CoVectorSchema(
|
|
5695
|
+
dimensions,
|
|
5696
|
+
coValueClass
|
|
5697
|
+
);
|
|
5369
5698
|
} else if (schema.builtin === "CoPlainText") {
|
|
5370
5699
|
const coValueClass = CoPlainText;
|
|
5371
5700
|
return new PlainTextSchema(coValueClass);
|
|
@@ -5404,7 +5733,7 @@ var ImageDefinitionBase = coMapDefiner({
|
|
|
5404
5733
|
var ImageDefinition = ImageDefinitionBase;
|
|
5405
5734
|
|
|
5406
5735
|
// src/tools/implementation/ContextManager.ts
|
|
5407
|
-
import { cojsonInternals as
|
|
5736
|
+
import { cojsonInternals as cojsonInternals7 } from "cojson";
|
|
5408
5737
|
import { PureJSCrypto } from "cojson/dist/crypto/PureJSCrypto";
|
|
5409
5738
|
|
|
5410
5739
|
// src/tools/auth/KvStoreContext.ts
|
|
@@ -5775,7 +6104,7 @@ var JazzContextManager = class {
|
|
|
5775
6104
|
}
|
|
5776
6105
|
const currentContext = this.context;
|
|
5777
6106
|
if (prevContext && currentContext && "me" in prevContext && "me" in currentContext) {
|
|
5778
|
-
const [prevAccountAsPeer, currentAccountAsPeer] =
|
|
6107
|
+
const [prevAccountAsPeer, currentAccountAsPeer] = cojsonInternals7.connectedPeers(
|
|
5779
6108
|
prevContext.me.$jazz.id,
|
|
5780
6109
|
currentContext.me.$jazz.id,
|
|
5781
6110
|
{
|
|
@@ -6043,9 +6372,9 @@ function isAccountInstance(instance) {
|
|
|
6043
6372
|
return TypeSym in instance && instance[TypeSym] === "Account";
|
|
6044
6373
|
}
|
|
6045
6374
|
function parseCoValueCreateOptions(options) {
|
|
6046
|
-
const
|
|
6375
|
+
const Group18 = RegisteredSchemas["Group"];
|
|
6047
6376
|
if (!options) {
|
|
6048
|
-
return { owner:
|
|
6377
|
+
return { owner: Group18.create(), uniqueness: void 0 };
|
|
6049
6378
|
}
|
|
6050
6379
|
if (TypeSym in options) {
|
|
6051
6380
|
if (options[TypeSym] === "Account") {
|
|
@@ -6056,7 +6385,7 @@ function parseCoValueCreateOptions(options) {
|
|
|
6056
6385
|
}
|
|
6057
6386
|
const uniqueness = options.unique ? { uniqueness: options.unique } : void 0;
|
|
6058
6387
|
const opts = {
|
|
6059
|
-
owner: options.owner ? accountOrGroupToGroup(options.owner) :
|
|
6388
|
+
owner: options.owner ? accountOrGroupToGroup(options.owner) : Group18.create(),
|
|
6060
6389
|
uniqueness
|
|
6061
6390
|
};
|
|
6062
6391
|
return opts;
|
|
@@ -6234,4 +6563,4 @@ export {
|
|
|
6234
6563
|
JazzContextManager
|
|
6235
6564
|
};
|
|
6236
6565
|
/* istanbul ignore file -- @preserve */
|
|
6237
|
-
//# sourceMappingURL=chunk-
|
|
6566
|
+
//# sourceMappingURL=chunk-ZIAN4UY5.js.map
|