@holochain-open-dev/file-storage 0.0.2 → 0.0.3
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,7 +1,7 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { css, html, LitElement } from 'lit';
|
|
3
3
|
import { property } from 'lit/decorators.js';
|
|
4
|
-
import { hashProperty } from '@holochain-open-dev/
|
|
4
|
+
import { hashProperty } from '@holochain-open-dev/elements';
|
|
5
5
|
import { ScopedElementsMixin } from '@open-wc/scoped-elements';
|
|
6
6
|
import { contextProvided } from '@lit-labs/context';
|
|
7
7
|
import { sharedStyles } from '../shared-styles';
|
|
@@ -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,EAAE,YAAY,EAAE,MAAM,
|
|
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,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAEtD,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,UA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C;4CAAuB;AAK5D;IADC,eAAe,CAAC,EAAE,OAAO,EAAE,wBAAwB,EAAE,CAAC;0CAC3B","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { hashProperty } from '@holochain-open-dev/elements';\nimport { ScopedElementsMixin } from '@open-wc/scoped-elements';\nimport { contextProvided } from '@lit-labs/context';\n\nimport { FileStorageClient } from '../file-storage-client';\nimport { sharedStyles } from '../shared-styles';\nimport { fileStorageClientContext } from '../context';\nimport { EntryHash } from '@holochain/client';\nimport { Task } from '@lit-labs/task';\nimport { SlSkeleton } from '@scoped-elements/shoelace'\nimport { fromUint8Array } from 'js-base64'\n\n/**\n * @fires file-uploaded - Fired after having uploaded the file\n * @csspart dropzone - Style the dropzone itself\n */\nexport class ShowImage extends ScopedElementsMixin(LitElement) {\n /** Public attributes */\n\n @property(hashProperty('image-hash')) imageHash!: EntryHash;\n\n /** Dependencies */\n\n @contextProvided({ context: fileStorageClientContext })\n _client!: FileStorageClient;\n\n _renderImage = new Task(this, 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 }, () => [this.imageHash]);\n\n renderImage(file: File, data: Uint8Array) {\n return html`<img src=\"data:${file.type};base64,${fromUint8Array(data)}\" style=\"flex: 1\"></img>`;\n }\n\n render() {\n return this._renderImage.render({\n complete: ([f, d]) => this.renderImage(f, d),\n pending: () => html`<sl-skeleton effect=\"pulse\" style=\"flex: 1\"></sl-skeleton>`\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 static get scopedElements() {\n return { 'sl-skeleton': SlSkeleton }\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holochain-open-dev/file-storage",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "File storage utilities to store files in holochain DHT",
|
|
5
5
|
"author": "guillem.cordoba@gmail.com",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@holochain/client": "^0.9.3",
|
|
26
|
+
"@holochain-open-dev/elements": "^0.0.4",
|
|
26
27
|
"@lit-labs/context": "^0.1.3",
|
|
27
28
|
"@lit-labs/task": "^2.0.0",
|
|
28
29
|
"@open-wc/scoped-elements": "^2.1.0",
|