@holochain-open-dev/file-storage 0.1.3 → 0.1.4
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.
|
@@ -2,7 +2,7 @@ import { LitElement } from "lit";
|
|
|
2
2
|
import { DisplayError } from "@holochain-open-dev/elements";
|
|
3
3
|
import { EntryHash } from "@holochain/client";
|
|
4
4
|
import { Task } from "@lit-labs/task";
|
|
5
|
-
import {
|
|
5
|
+
import { CircularProgress } from "@scoped-elements/material-web";
|
|
6
6
|
import { FileStorageClient } from "../file-storage-client";
|
|
7
7
|
declare const ShowImage_base: typeof LitElement & import("@open-wc/dedupe-mixin").Constructor<import("@open-wc/scoped-elements/types/src/types").ScopedElementsHost>;
|
|
8
8
|
/**
|
|
@@ -30,7 +30,7 @@ export declare class ShowImage extends ShowImage_base {
|
|
|
30
30
|
* @internal
|
|
31
31
|
*/
|
|
32
32
|
static get scopedElements(): {
|
|
33
|
-
"
|
|
33
|
+
"mwc-circular-progress": typeof CircularProgress;
|
|
34
34
|
"display-error": typeof DisplayError;
|
|
35
35
|
};
|
|
36
36
|
}
|
|
@@ -5,7 +5,7 @@ import { DisplayError, hashProperty, sharedStyles, } from "@holochain-open-dev/e
|
|
|
5
5
|
import { ScopedElementsMixin } from "@open-wc/scoped-elements";
|
|
6
6
|
import { consume } from "@lit-labs/context";
|
|
7
7
|
import { Task } from "@lit-labs/task";
|
|
8
|
-
import {
|
|
8
|
+
import { CircularProgress } from "@scoped-elements/material-web";
|
|
9
9
|
import { fromUint8Array } from "js-base64";
|
|
10
10
|
import { localized, msg } from "@lit/localize";
|
|
11
11
|
import { fileStorageClientContext } from "../context";
|
|
@@ -27,12 +27,14 @@ let ShowImage = class ShowImage extends ScopedElementsMixin(LitElement) {
|
|
|
27
27
|
}, () => [this.imageHash]);
|
|
28
28
|
}
|
|
29
29
|
renderImage(file, data) {
|
|
30
|
-
return html `<img src="data:${file.type};base64,${fromUint8Array(data)}" style="flex: 1"></img>`;
|
|
30
|
+
return html `<img src="data:${file.type};base64,${fromUint8Array(data)}" style="flex: 1; object-fit: cover"></img>`;
|
|
31
31
|
}
|
|
32
32
|
render() {
|
|
33
33
|
return this._renderImage.render({
|
|
34
34
|
complete: ([f, d]) => this.renderImage(f, d),
|
|
35
|
-
pending: () => html `<
|
|
35
|
+
pending: () => html `<div class="row center-content" style="flex: 1">
|
|
36
|
+
<mwc-circular-progress></mwc-circular-progress>
|
|
37
|
+
</div>`,
|
|
36
38
|
error: (e) => html `<display-error
|
|
37
39
|
.headline=${msg("Error fetching the image")}
|
|
38
40
|
></display-error>`,
|
|
@@ -53,7 +55,10 @@ let ShowImage = class ShowImage extends ScopedElementsMixin(LitElement) {
|
|
|
53
55
|
* @internal
|
|
54
56
|
*/
|
|
55
57
|
static get scopedElements() {
|
|
56
|
-
return {
|
|
58
|
+
return {
|
|
59
|
+
"mwc-circular-progress": CircularProgress,
|
|
60
|
+
"display-error": DisplayError,
|
|
61
|
+
};
|
|
57
62
|
}
|
|
58
63
|
};
|
|
59
64
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"show-image.js","sourceRoot":"","sources":["../../src/elements/show-image.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,YAAY,GACb,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG5C,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"show-image.js","sourceRoot":"","sources":["../../src/elements/show-image.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GA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ACJ,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;YAC9B,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC;YAC5C,OAAO,EAAE,GAAG,EAAE,CACZ,IAAI,CAAA;;eAEG;YACT,KAAK,EAAE,CAAC,CAAM,EAAE,EAAE,CAChB,IAAI,CAAA;sBACU,GAAG,CAAC,0BAA0B,CAAC;0BAC3B;SACrB,CAAC,CAAC;IACL,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO;YACL,YAAY;YACZ,GAAG,CAAA;;;;;OAKF;SACF,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,MAAM,KAAK,cAAc;QACvB,OAAO;YACL,uBAAuB,EAAE,gBAAgB;YACzC,eAAe,EAAE,YAAY;SAC9B,CAAC;IACJ,CAAC;CACF,CAAA;AA/DuC;IAArC,QAAQ,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;4CAAuB;AAM5D;IADC,OAAO,CAAC,EAAE,OAAO,EAAE,wBAAwB,EAAE,CAAC;yCACpB;AAZhB,SAAS;IADrB,SAAS,EAAE;GACC,SAAS,CAqErB;SArEY,SAAS","sourcesContent":["import { css, html, LitElement } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport {\n DisplayError,\n hashProperty,\n sharedStyles,\n} from \"@holochain-open-dev/elements\";\nimport { ScopedElementsMixin } from \"@open-wc/scoped-elements\";\nimport { consume } from \"@lit-labs/context\";\n\nimport { EntryHash } from \"@holochain/client\";\nimport { Task } from \"@lit-labs/task\";\nimport { CircularProgress } from \"@scoped-elements/material-web\";\nimport { fromUint8Array } from \"js-base64\";\nimport { localized, msg } from \"@lit/localize\";\n\nimport { FileStorageClient } from \"../file-storage-client\";\nimport { fileStorageClientContext } from \"../context\";\n\n/**\n * @fires file-uploaded - Fired after having uploaded the file\n * @csspart dropzone - Style the dropzone itself\n */\n@localized()\nexport class ShowImage extends ScopedElementsMixin(LitElement) {\n /** Public attributes */\n\n /**\n * REQUIRED. The hash of the image to be rendered\n */\n @property(hashProperty(\"image-hash\")) imageHash!: EntryHash;\n\n /**\n * @internal\n */\n @consume({ context: fileStorageClientContext })\n client!: FileStorageClient;\n\n /**\n * @internal\n */\n _renderImage = new Task(\n this,\n async ([fileHash]) => {\n const file = await this.client.downloadFile(fileHash);\n const data = await file.arrayBuffer();\n\n return [file, new Uint8Array(data)] as [File, Uint8Array];\n },\n () => [this.imageHash]\n );\n\n renderImage(file: File, data: Uint8Array) {\n return html`<img src=\"data:${file.type};base64,${fromUint8Array(\n data\n )}\" style=\"flex: 1; object-fit: cover\"></img>`;\n }\n\n render() {\n return this._renderImage.render({\n complete: ([f, d]) => this.renderImage(f, d),\n pending: () =>\n html`<div class=\"row center-content\" style=\"flex: 1\">\n <mwc-circular-progress></mwc-circular-progress>\n </div>`,\n error: (e: any) =>\n html`<display-error\n .headline=${msg(\"Error fetching the image\")}\n ></display-error>`,\n });\n }\n\n static get styles() {\n return [\n sharedStyles,\n css`\n :host {\n display: flex;\n flex: 1;\n }\n `,\n ];\n }\n\n /**\n * @internal\n */\n static get scopedElements() {\n return {\n \"mwc-circular-progress\": CircularProgress,\n \"display-error\": DisplayError,\n };\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holochain-open-dev/file-storage",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "File storage utilities to store and retrieve files in a holochain DHT",
|
|
5
5
|
"author": "guillem.cordoba@gmail.com",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"@lit/localize": "^0.11.4",
|
|
31
31
|
"@open-wc/scoped-elements": "^2.1.0",
|
|
32
32
|
"@scoped-elements/dropzone": "^0.1.2",
|
|
33
|
+
"@scoped-elements/material-web": "^0.1.7",
|
|
33
34
|
"@scoped-elements/shoelace": "^0.1.0",
|
|
34
35
|
"lit": "^2.6.0"
|
|
35
36
|
},
|