@holochain-open-dev/file-storage 0.1.0 → 0.1.1

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 +1 @@
1
- {"version":3,"file":"upload-files.js","sourceRoot":"","sources":["../../src/elements/upload-files.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAG5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAEtD;;;GAGG;AACH,MAAM,OAAO,WAAY,SAAQ,mBAAmB,CAAC,UAAU,CAAC;IAAhE;QACE,wBAAwB;;QAExB;;WAEG;QACiD,YAAO,GAAG,KAAK,CAAC;QAEpE;;;WAGG;QACsD,kBAAa,GAEtD,SAAS,CAAC;IA4C5B,CAAC;IApCC,yBAAyB;IAEzB,YAAY;QACV,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC;QAE5B,IAAI,CAAC,mBAAmB,CACtB,WAAW,EACX,KAAM,SAAQ,eAAe;YAC3B,aAAa,CAAC,eAA4B,EAAE,OAAwB;gBAClE,OAAO,IAAI,iBAAiB,CAAC,eAAe,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;YACjE,CAAC;SACF,CACF,CAAC;IACJ,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAA;;mBAEI,IAAI,CAAC,OAAO;yBACN,IAAI,CAAC,aAAa;yBAClB,CAAC,CAAc,EAAE,EAAE,CAClC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;;KAEzC,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO;YACL,YAAY;YACZ,GAAG,CAAA;;;;OAIF;SACF,CAAC;IACJ,CAAC;CACF;AApDqD;IAAnD,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;4CAAiB;AAMX;IAAxD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC;kDAE9B;AAM1B;IADC,OAAO,CAAC,EAAE,OAAO,EAAE,wBAAwB,EAAE,CAAC;4CACnB","sourcesContent":["import { css, html, LitElement } from \"lit\";\nimport { property } from \"lit/decorators.js\";\n\nimport { ScopedElementsMixin } from \"@open-wc/scoped-elements\";\nimport { DropzoneElement } from \"@scoped-elements/dropzone\";\nimport { consume } from \"@lit-labs/context\";\nimport { DropzoneOptions } from \"dropzone\";\nimport { sharedStyles } from \"@holochain-open-dev/elements\";\n\nimport { FileStorageClient } from \"../file-storage-client\";\nimport { HolochainDropzone } from \"../holochain-dropzone\";\nimport { fileStorageClientContext } from \"../context\";\n\n/**\n * @fires file-uploaded - Fired after having uploaded the file\n * @csspart dropzone - Style the dropzone itself\n */\nexport class UploadFiles extends ScopedElementsMixin(LitElement) {\n /** Public attributes */\n\n /**\n * Whether this element should allow only file to be uploaded\n */\n @property({ type: Boolean, attribute: \"one-file\" }) oneFile = false;\n\n /**\n * The type of files accepted by this element\n * Learn how to use this here: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept\n */\n @property({ type: String, attribute: \"accepted-files\" }) acceptedFiles:\n | string\n | undefined = undefined;\n\n /**\n * @internal\n */\n @consume({ context: fileStorageClientContext })\n _client!: FileStorageClient;\n\n /** Private properties */\n\n firstUpdated() {\n const client = this._client;\n\n this.defineScopedElement(\n \"drop-zone\",\n class extends DropzoneElement {\n buildDropzone(dropzoneElement: HTMLElement, options: DropzoneOptions) {\n return new HolochainDropzone(dropzoneElement, client, options);\n }\n }\n );\n }\n\n render() {\n return html`\n <drop-zone\n .oneFile=${this.oneFile}\n .acceptedFiles=${this.acceptedFiles}\n @file-uploaded=${(e: CustomEvent) =>\n (e.detail.hash = e.detail.file.hash)}\n ></drop-zone>\n `;\n }\n\n static get styles() {\n return [\n sharedStyles,\n css`\n :host {\n display: contents;\n }\n `,\n ];\n }\n}\n"]}
1
+ {"version":3,"file":"upload-files.js","sourceRoot":"","sources":["../../src/elements/upload-files.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAG5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAEtD;;;GAGG;AACH,MAAM,OAAO,WAAY,SAAQ,mBAAmB,CAAC,UAAU,CAAC;IAAhE;QACE,wBAAwB;;QAExB;;WAEG;QACiD,YAAO,GAAG,KAAK,CAAC;QAEpE;;;WAGG;QACsD,kBAAa,GAEtD,SAAS,CAAC;IAgD5B,CAAC;IAxCC,yBAAyB;IAEzB,YAAY;QACV,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC;QAE5B,IAAI,CAAC,mBAAmB,CACtB,WAAW,EACX,KAAM,SAAQ,eAAe;YAC3B,aAAa,CAAC,eAA4B,EAAE,OAAwB;gBAClE,OAAO,IAAI,iBAAiB,CAC1B,eAAe,EACf,MAAM,EACN,OAAO,CACW,CAAC;YACvB,CAAC;SACF,CACF,CAAC;IACJ,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAA;;mBAEI,IAAI,CAAC,OAAO;yBACN,IAAI,CAAC,aAAa;yBAClB,CAAC,CAAc,EAAE,EAAE,CAClC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;;KAEzC,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO;YACL,YAAY;YACZ,GAAG,CAAA;;;;OAIF;SACF,CAAC;IACJ,CAAC;CACF;AAxDqD;IAAnD,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;4CAAiB;AAMX;IAAxD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC;kDAE9B;AAM1B;IADC,OAAO,CAAC,EAAE,OAAO,EAAE,wBAAwB,EAAE,CAAC;4CACnB","sourcesContent":["import { css, html, LitElement } from \"lit\";\nimport { property } from \"lit/decorators.js\";\n\nimport { ScopedElementsMixin } from \"@open-wc/scoped-elements\";\nimport { DropzoneElement } from \"@scoped-elements/dropzone\";\nimport { consume } from \"@lit-labs/context\";\nimport { DropzoneOptions } from \"dropzone\";\nimport { sharedStyles } from \"@holochain-open-dev/elements\";\n\nimport { FileStorageClient } from \"../file-storage-client\";\nimport { HolochainDropzone } from \"../holochain-dropzone\";\nimport { fileStorageClientContext } from \"../context\";\n\n/**\n * @fires file-uploaded - Fired after having uploaded the file\n * @csspart dropzone - Style the dropzone itself\n */\nexport class UploadFiles extends ScopedElementsMixin(LitElement) {\n /** Public attributes */\n\n /**\n * Whether this element should allow only file to be uploaded\n */\n @property({ type: Boolean, attribute: \"one-file\" }) oneFile = false;\n\n /**\n * The type of files accepted by this element\n * Learn how to use this here: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept\n */\n @property({ type: String, attribute: \"accepted-files\" }) acceptedFiles:\n | string\n | undefined = undefined;\n\n /**\n * @internal\n */\n @consume({ context: fileStorageClientContext })\n _client!: FileStorageClient;\n\n /** Private properties */\n\n firstUpdated() {\n const client = this._client;\n\n this.defineScopedElement(\n \"drop-zone\",\n class extends DropzoneElement {\n buildDropzone(dropzoneElement: HTMLElement, options: DropzoneOptions) {\n return new HolochainDropzone(\n dropzoneElement,\n client,\n options\n ) as any as Dropzone;\n }\n }\n );\n }\n\n render() {\n return html`\n <drop-zone\n .oneFile=${this.oneFile}\n .acceptedFiles=${this.acceptedFiles}\n @file-uploaded=${(e: CustomEvent) =>\n (e.detail.hash = e.detail.file.hash)}\n ></drop-zone>\n `;\n }\n\n static get styles() {\n return [\n sharedStyles,\n css`\n :host {\n display: contents;\n }\n `,\n ];\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import Dropzone, { DropzoneOptions } from "dropzone";
1
+ import { Dropzone, DropzoneOptions } from "dropzone";
2
2
  import { FileStorageClient } from "./file-storage-client";
3
3
  export declare class HolochainDropzone extends Dropzone {
4
4
  fileStorageClient: FileStorageClient;
@@ -1,4 +1,5 @@
1
- import Dropzone from "dropzone";
1
+ //@ts-nocheck
2
+ import { Dropzone } from "dropzone";
2
3
  export class HolochainDropzone extends Dropzone {
3
4
  constructor(el, fileStorageClient, options) {
4
5
  options.url = "https://holochain.org/"; // just to bypass the check.
@@ -1 +1 @@
1
- {"version":3,"file":"holochain-dropzone.js","sourceRoot":"","sources":["../src/holochain-dropzone.ts"],"names":[],"mappings":"AAAA,OAAO,QAA6B,MAAM,UAAU,CAAC;AAGrD,MAAM,OAAO,iBAAkB,SAAQ,QAAQ;IAE7C,YACE,EAAe,EACf,iBAAoC,EACpC,OAAwB;QAExB,OAAO,CAAC,GAAG,GAAG,wBAAwB,CAAC,CAAC,4BAA4B;QACpE,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QACnB,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;IAC7C,CAAC;IAED,WAAW,CAAC,KAA8B;QACxC,IAAI,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,uBAAuB,CAC3B,aAAsC;QAEtC,KAAK,MAAM,IAAI,IAAI,aAAa,EAAE;YAChC,IAAI;gBACF,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;gBACjD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAClD,IAAI,EACJ,CAAC,WAAW,EAAE,SAAS,EAAE,EAAE;oBACzB,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,EAAE,WAAW,GAAG,GAAG,EAAE,SAAS,CAAC,CAAC;gBAClE,CAAC,CACF,CAAC;gBACF,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;gBACrC,IAAY,CAAC,IAAI,GAAG,IAAI,CAAC;gBAC1B,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;aAC7B;YAAC,OAAO,CAAC,EAAE;gBACV,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBACjB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAG,CAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aAChD;SACF;IACH,CAAC;CACF","sourcesContent":["import Dropzone, { DropzoneOptions } from \"dropzone\";\nimport { FileStorageClient } from \"./file-storage-client\";\n\nexport class HolochainDropzone extends Dropzone {\n fileStorageClient: FileStorageClient;\n constructor(\n el: HTMLElement,\n fileStorageClient: FileStorageClient,\n options: DropzoneOptions\n ) {\n options.url = \"https://holochain.org/\"; // just to bypass the check.\n super(el, options);\n this.fileStorageClient = fileStorageClient;\n }\n\n uploadFiles(files: Dropzone.DropzoneFile[]) {\n this._uploadFilesToHolochain(files);\n }\n\n async _uploadFilesToHolochain(\n dropzoneFiles: Dropzone.DropzoneFile[]\n ): Promise<void> {\n for (const file of dropzoneFiles) {\n try {\n this.emit(\"sending\", file, undefined, undefined);\n const hash = await this.fileStorageClient.uploadFile(\n file,\n (percentatge, bytesSent) => {\n this.emit(\"uploadprogress\", file, percentatge * 100, bytesSent);\n }\n );\n this.emit(\"success\", file, undefined);\n (file as any).hash = hash;\n this.emit(\"complete\", file);\n } catch (e) {\n console.error(e);\n this.emit(\"error\", file, (e as any).data.data);\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"holochain-dropzone.js","sourceRoot":"","sources":["../src/holochain-dropzone.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,OAAO,EAAE,QAAQ,EAAmB,MAAM,UAAU,CAAC;AAGrD,MAAM,OAAO,iBAAkB,SAAQ,QAAQ;IAE7C,YACE,EAAe,EACf,iBAAoC,EACpC,OAAwB;QAExB,OAAO,CAAC,GAAG,GAAG,wBAAwB,CAAC,CAAC,4BAA4B;QACpE,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QACnB,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;IAC7C,CAAC;IAED,WAAW,CAAC,KAA8B;QACxC,IAAI,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,uBAAuB,CAC3B,aAAsC;QAEtC,KAAK,MAAM,IAAI,IAAI,aAAa,EAAE;YAChC,IAAI;gBACF,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;gBACjD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAClD,IAAI,EACJ,CAAC,WAAW,EAAE,SAAS,EAAE,EAAE;oBACzB,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,EAAE,WAAW,GAAG,GAAG,EAAE,SAAS,CAAC,CAAC;gBAClE,CAAC,CACF,CAAC;gBACF,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;gBACrC,IAAY,CAAC,IAAI,GAAG,IAAI,CAAC;gBAC1B,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;aAC7B;YAAC,OAAO,CAAC,EAAE;gBACV,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBACjB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAG,CAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aAChD;SACF;IACH,CAAC;CACF","sourcesContent":["//@ts-nocheck\nimport { Dropzone, DropzoneOptions } from \"dropzone\";\nimport { FileStorageClient } from \"./file-storage-client\";\n\nexport class HolochainDropzone extends Dropzone {\n fileStorageClient: FileStorageClient;\n constructor(\n el: HTMLElement,\n fileStorageClient: FileStorageClient,\n options: DropzoneOptions\n ) {\n options.url = \"https://holochain.org/\"; // just to bypass the check.\n super(el, options);\n this.fileStorageClient = fileStorageClient;\n }\n\n uploadFiles(files: Dropzone.DropzoneFile[]) {\n this._uploadFilesToHolochain(files);\n }\n\n async _uploadFilesToHolochain(\n dropzoneFiles: Dropzone.DropzoneFile[]\n ): Promise<void> {\n for (const file of dropzoneFiles) {\n try {\n this.emit(\"sending\", file, undefined, undefined);\n const hash = await this.fileStorageClient.uploadFile(\n file,\n (percentatge, bytesSent) => {\n this.emit(\"uploadprogress\", file, percentatge * 100, bytesSent);\n }\n );\n this.emit(\"success\", file, undefined);\n (file as any).hash = hash;\n this.emit(\"complete\", file);\n } catch (e) {\n console.error(e);\n this.emit(\"error\", file, (e as any).data.data);\n }\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.0",
3
+ "version": "0.1.1",
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
  "@open-wc/scoped-elements": "^2.1.0",
31
31
  "@scoped-elements/dropzone": "^0.0.3",
32
32
  "@scoped-elements/material-web": "^0.0.19",
33
+ "dropzone": "^5.9.3",
33
34
  "lit": "^2.6.0"
34
35
  },
35
36
  "devDependencies": {
@@ -50,9 +51,6 @@
50
51
  "vite": "^4.0.4",
51
52
  "vite-plugin-checker": "^0.5.3"
52
53
  },
53
- "eslintConfig": {
54
- "extends": ["@open-wc/eslint-config", "eslint-config-prettier"]
55
- },
56
54
  "prettier": {
57
55
  "singleQuote": true,
58
56
  "arrowParens": "avoid"