@fireproof/core 0.20.5-dev-preview-12 → 0.20.5-dev-preview-13
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/cli/main.js +2 -2
- package/deno.json +1 -1
- package/package.json +2 -2
- package/react/img-file.d.ts.map +1 -1
- package/react/img-file.js +6 -37
- package/react/img-file.js.map +1 -1
package/cli/main.js
CHANGED
@@ -26145,8 +26145,8 @@ function writeEnvCmd(sthis) {
|
|
26145
26145
|
}
|
26146
26146
|
|
26147
26147
|
// node_modules/.pnpm/zx@8.5.4/node_modules/zx/build/deno.js
|
26148
|
-
import { createRequire as createRequire2 } from "
|
26149
|
-
import * as process2 from "
|
26148
|
+
import { createRequire as createRequire2 } from "module";
|
26149
|
+
import * as process2 from "process";
|
26150
26150
|
if (globalThis.Deno) {
|
26151
26151
|
globalThis.require = createRequire2(import.meta.url);
|
26152
26152
|
globalThis.__filename = new URL(import.meta.url).pathname;
|
package/deno.json
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
"@web3-storage/pail": "npm:@web3-storage/pail@^0.6.2",
|
9
9
|
"cborg": "npm:cborg@^4.2.10",
|
10
10
|
"jose": "npm:jose@^6.0.11",
|
11
|
-
"multiformats": "npm:multiformats@^13.3.
|
11
|
+
"multiformats": "npm:multiformats@^13.3.4",
|
12
12
|
"charwise": "npm:charwise@^3.0.1",
|
13
13
|
"prolly-trees": "npm:prolly-trees@^1.0.4",
|
14
14
|
"idb": "npm:idb@^8.0.3",
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fireproof/core",
|
3
|
-
"version": "0.20.5-dev-preview-
|
3
|
+
"version": "0.20.5-dev-preview-13",
|
4
4
|
"description": "Live ledger for the web.",
|
5
5
|
"type": "module",
|
6
6
|
"module": "./index.js",
|
@@ -93,7 +93,7 @@
|
|
93
93
|
"@web3-storage/pail": "^0.6.2",
|
94
94
|
"cborg": "^4.2.10",
|
95
95
|
"jose": "^6.0.11",
|
96
|
-
"multiformats": "^13.3.
|
96
|
+
"multiformats": "^13.3.4",
|
97
97
|
"charwise": "^3.0.1",
|
98
98
|
"prolly-trees": "^1.0.4",
|
99
99
|
"idb": "^8.0.3",
|
package/react/img-file.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"img-file.d.ts","sourceRoot":"","sources":["../../../../src/react/img-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,EAAE,
|
1
|
+
{"version":3,"file":"img-file.d.ts","sourceRoot":"","sources":["../../../../src/react/img-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,EAAE,EAAuB,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAGtE,KAAK,QAAQ,GAAG,IAAI,GAAG,WAAW,CAAC;AAEnC,UAAU,YAAa,SAAQ,IAAI,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,EAAE,KAAK,CAAC;IAC7E,IAAI,CAAC,EAAE,QAAQ,CAAC;IAKhB,IAAI,CAAC,EAAE,QAAQ,CAAC;CACjB;AAYD,wBAAgB,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,QAAQ,EAAE,EAAE,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAwDhE;AAED,eAAe,OAAO,CAAC"}
|
package/react/img-file.js
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
import React, { useState, useEffect
|
2
|
-
const objectUrlCache = new Map();
|
1
|
+
import React, { useState, useEffect } from "react";
|
3
2
|
function isFile(obj) {
|
4
3
|
return "type" in obj && "size" in obj && "stream" in obj && typeof obj.stream === "function";
|
5
4
|
}
|
@@ -8,21 +7,7 @@ function isFileMeta(obj) {
|
|
8
7
|
}
|
9
8
|
export function ImgFile({ file, meta, ...imgProps }) {
|
10
9
|
const [imgDataUrl, setImgDataUrl] = useState("");
|
11
|
-
const
|
12
|
-
const cleanupRef = useRef(null);
|
13
|
-
const fileData = useMemo(() => {
|
14
|
-
return file || meta;
|
15
|
-
}, [file, meta]);
|
16
|
-
const getCacheKey = (fileObj) => {
|
17
|
-
return `${fileObj.name}-${fileObj.size}-${fileObj.lastModified}`;
|
18
|
-
};
|
19
|
-
const getObjectUrl = (fileObj) => {
|
20
|
-
const cacheKey = getCacheKey(fileObj);
|
21
|
-
if (!objectUrlCache.has(cacheKey)) {
|
22
|
-
objectUrlCache.set(cacheKey, URL.createObjectURL(fileObj));
|
23
|
-
}
|
24
|
-
return objectUrlCache.get(cacheKey);
|
25
|
-
};
|
10
|
+
const fileData = file || meta;
|
26
11
|
useEffect(() => {
|
27
12
|
if (!fileData)
|
28
13
|
return;
|
@@ -39,30 +24,14 @@ export function ImgFile({ file, meta, ...imgProps }) {
|
|
39
24
|
fileObj = (await fileData.file?.()) || null;
|
40
25
|
break;
|
41
26
|
}
|
42
|
-
if (fileObjRef.current !== fileObj && cleanupRef.current) {
|
43
|
-
cleanupRef.current();
|
44
|
-
cleanupRef.current = null;
|
45
|
-
}
|
46
27
|
if (fileObj && /image/.test(fileType)) {
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
fileObjRef.current = fileObj;
|
51
|
-
cleanupRef.current = () => {
|
52
|
-
const cacheKey = getCacheKey(fileObj);
|
53
|
-
if (objectUrlCache.has(cacheKey)) {
|
54
|
-
URL.revokeObjectURL(objectUrlCache.get(cacheKey));
|
55
|
-
objectUrlCache.delete(cacheKey);
|
56
|
-
}
|
57
|
-
};
|
58
|
-
return cleanupRef.current;
|
59
|
-
}
|
60
|
-
return cleanupRef.current;
|
28
|
+
const src = URL.createObjectURL(fileObj);
|
29
|
+
setImgDataUrl(src);
|
30
|
+
return () => URL.revokeObjectURL(src);
|
61
31
|
}
|
62
|
-
return null;
|
63
32
|
};
|
64
33
|
let isMounted = true;
|
65
|
-
let cleanup
|
34
|
+
let cleanup;
|
66
35
|
loadFile().then((result) => {
|
67
36
|
if (isMounted) {
|
68
37
|
cleanup = result;
|
package/react/img-file.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"img-file.js","sourceRoot":"","sources":["../../../../src/react/img-file.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,
|
1
|
+
{"version":3,"file":"img-file.js","sourceRoot":"","sources":["../../../../src/react/img-file.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAqB,MAAM,OAAO,CAAC;AAetE,SAAS,MAAM,CAAC,GAAa;IAC3B,OAAO,MAAM,IAAI,GAAG,IAAI,MAAM,IAAI,GAAG,IAAI,QAAQ,IAAI,GAAG,IAAI,OAAO,GAAG,CAAC,MAAM,KAAK,UAAU,CAAC;AAC/F,CAAC;AAGD,SAAS,UAAU,CAAC,GAAa;IAC/B,OAAO,MAAM,IAAI,GAAG,IAAI,MAAM,IAAI,GAAG,IAAI,MAAM,IAAI,GAAG,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,UAAU,CAAC;AAC3F,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,QAAQ,EAAgB;IAC/D,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IAGj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