@thirdweb-dev/storage
Advanced tools
Comparing version 0.1.0 to 0.1.1-nightly-274afb5
@@ -1,1 +0,1 @@ | ||
export * from "./declarations/dist/index"; | ||
export * from "./declarations/src/index"; |
@@ -5,5 +5,5 @@ 'use strict'; | ||
var file = require('@web-std/file'); | ||
var FormData = require('form-data'); | ||
var fetch$1 = require('cross-fetch'); | ||
var zod = require('zod'); | ||
@@ -566,2 +566,8 @@ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; } | ||
function isFileInstance(data) { | ||
return global.File && data instanceof File; | ||
} | ||
function isBufferInstance(data) { | ||
return global.Buffer && data instanceof Buffer; | ||
} | ||
/** | ||
@@ -585,3 +591,3 @@ * Given a map of file hashes to ipfs uris, this function will hash | ||
var val = object[keys[key]]; | ||
var isFile = val instanceof file.File || val instanceof Buffer; | ||
var isFile = isFileInstance(val) || isBufferInstance(val); | ||
@@ -659,3 +665,3 @@ if (_typeof(val) === "object" && !isFile) { | ||
object[keys[key]] = val.map(function (el) { | ||
var isFile = el instanceof file.File || el instanceof Buffer; | ||
var isFile = isFileInstance(el) || isBufferInstance(el); | ||
@@ -670,3 +676,3 @@ if (_typeof(el) === "object" && !isFile) { | ||
var isFile = val instanceof file.File || val instanceof Buffer; | ||
var isFile = isFileInstance(val) || isBufferInstance(val); | ||
@@ -933,16 +939,16 @@ if (_typeof(val) === "object" && !isFile) { | ||
var fileNames = []; | ||
files.forEach(function (file$1, i) { | ||
files.forEach(function (file, i) { | ||
var fileName = ""; | ||
var fileData = file$1; // if it is a file, we passthrough the file extensions, | ||
var fileData = file; // if it is a file, we passthrough the file extensions, | ||
// if it is a buffer or string, the filename would be fileStartNumber + index | ||
// if it is a buffer or string with names, the filename would be the name | ||
if (file$1 instanceof file.File) { | ||
if (isFileInstance(file)) { | ||
var extensions = ""; | ||
if (file$1.name) { | ||
var extensionStartIndex = file$1.name.lastIndexOf("."); | ||
if (file.name) { | ||
var extensionStartIndex = file.name.lastIndexOf("."); | ||
if (extensionStartIndex > -1) { | ||
extensions = file$1.name.substring(extensionStartIndex); | ||
extensions = file.name.substring(extensionStartIndex); | ||
} | ||
@@ -952,7 +958,7 @@ } | ||
fileName = "".concat(i + fileStartNumber).concat(extensions); | ||
} else if (file$1 instanceof Buffer || typeof file$1 === "string") { | ||
} else if (isBufferInstance(file) || typeof file === "string") { | ||
fileName = "".concat(i + fileStartNumber); | ||
} else if (file$1 && file$1.name && file$1 !== null && file$1 !== void 0 && file$1.data) { | ||
fileData = file$1 === null || file$1 === void 0 ? void 0 : file$1.data; | ||
fileName = "".concat(file$1.name); | ||
} else if (file && file.name && file !== null && file !== void 0 && file.data) { | ||
fileData = file === null || file === void 0 ? void 0 : file.data; | ||
fileName = "".concat(file.name); | ||
} else { | ||
@@ -1478,3 +1484,3 @@ // default behavior | ||
if (val instanceof file.File || val instanceof Buffer) { | ||
if (isFileInstance(val) || isBufferInstance(val)) { | ||
files.push(val); | ||
@@ -1577,3 +1583,2 @@ } else if (_typeof(val) === "object") { | ||
*/ | ||
var RemoteStorage = /*#__PURE__*/function () { | ||
@@ -1675,3 +1680,3 @@ function RemoteStorage(storage) { | ||
if (!(data instanceof file.File || data instanceof Buffer || data.name && data.data && data.data instanceof Buffer)) { | ||
if (!(isFileInstance(data) || isBufferInstance(data) || data.name && data.data && isBufferInstance(data.data))) { | ||
_context2.next = 5; | ||
@@ -1688,6 +1693,6 @@ break; | ||
allFiles = data.filter(function (item) { | ||
return item instanceof file.File || item instanceof Buffer || item.name && item.data && item.data instanceof Buffer; | ||
return isFileInstance(item) || isBufferInstance(item) || item.name && item.data && isBufferInstance(item.data); | ||
}); | ||
allObjects = data.filter(function (item) { | ||
return !(item instanceof file.File) && !(item instanceof Buffer); | ||
return !isFileInstance(item) && !isBufferInstance(item); | ||
}); | ||
@@ -1788,3 +1793,13 @@ | ||
var isBrowser = function isBrowser() { | ||
return typeof window !== "undefined"; | ||
}; | ||
var fileOrBufferUnion = isBrowser() ? [zod.z["instanceof"](File), zod.z.string()] : [zod.z["instanceof"](Buffer), zod.z.string()]; | ||
var FileBufferOrStringSchema = zod.z.union(fileOrBufferUnion); | ||
exports.FileBufferOrStringSchema = FileBufferOrStringSchema; | ||
exports.IpfsStorage = IpfsStorage; | ||
exports.RemoteStorage = RemoteStorage; | ||
exports.isBrowser = isBrowser; | ||
exports.isBufferInstance = isBufferInstance; | ||
exports.isFileInstance = isFileInstance; |
@@ -5,5 +5,5 @@ 'use strict'; | ||
var file = require('@web-std/file'); | ||
var FormData = require('form-data'); | ||
var fetch$1 = require('cross-fetch'); | ||
var zod = require('zod'); | ||
@@ -566,2 +566,8 @@ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; } | ||
function isFileInstance(data) { | ||
return global.File && data instanceof File; | ||
} | ||
function isBufferInstance(data) { | ||
return global.Buffer && data instanceof Buffer; | ||
} | ||
/** | ||
@@ -585,3 +591,3 @@ * Given a map of file hashes to ipfs uris, this function will hash | ||
var val = object[keys[key]]; | ||
var isFile = val instanceof file.File || val instanceof Buffer; | ||
var isFile = isFileInstance(val) || isBufferInstance(val); | ||
@@ -659,3 +665,3 @@ if (_typeof(val) === "object" && !isFile) { | ||
object[keys[key]] = val.map(function (el) { | ||
var isFile = el instanceof file.File || el instanceof Buffer; | ||
var isFile = isFileInstance(el) || isBufferInstance(el); | ||
@@ -670,3 +676,3 @@ if (_typeof(el) === "object" && !isFile) { | ||
var isFile = val instanceof file.File || val instanceof Buffer; | ||
var isFile = isFileInstance(val) || isBufferInstance(val); | ||
@@ -933,16 +939,16 @@ if (_typeof(val) === "object" && !isFile) { | ||
var fileNames = []; | ||
files.forEach(function (file$1, i) { | ||
files.forEach(function (file, i) { | ||
var fileName = ""; | ||
var fileData = file$1; // if it is a file, we passthrough the file extensions, | ||
var fileData = file; // if it is a file, we passthrough the file extensions, | ||
// if it is a buffer or string, the filename would be fileStartNumber + index | ||
// if it is a buffer or string with names, the filename would be the name | ||
if (file$1 instanceof file.File) { | ||
if (isFileInstance(file)) { | ||
var extensions = ""; | ||
if (file$1.name) { | ||
var extensionStartIndex = file$1.name.lastIndexOf("."); | ||
if (file.name) { | ||
var extensionStartIndex = file.name.lastIndexOf("."); | ||
if (extensionStartIndex > -1) { | ||
extensions = file$1.name.substring(extensionStartIndex); | ||
extensions = file.name.substring(extensionStartIndex); | ||
} | ||
@@ -952,7 +958,7 @@ } | ||
fileName = "".concat(i + fileStartNumber).concat(extensions); | ||
} else if (file$1 instanceof Buffer || typeof file$1 === "string") { | ||
} else if (isBufferInstance(file) || typeof file === "string") { | ||
fileName = "".concat(i + fileStartNumber); | ||
} else if (file$1 && file$1.name && file$1 !== null && file$1 !== void 0 && file$1.data) { | ||
fileData = file$1 === null || file$1 === void 0 ? void 0 : file$1.data; | ||
fileName = "".concat(file$1.name); | ||
} else if (file && file.name && file !== null && file !== void 0 && file.data) { | ||
fileData = file === null || file === void 0 ? void 0 : file.data; | ||
fileName = "".concat(file.name); | ||
} else { | ||
@@ -1478,3 +1484,3 @@ // default behavior | ||
if (val instanceof file.File || val instanceof Buffer) { | ||
if (isFileInstance(val) || isBufferInstance(val)) { | ||
files.push(val); | ||
@@ -1577,3 +1583,2 @@ } else if (_typeof(val) === "object") { | ||
*/ | ||
var RemoteStorage = /*#__PURE__*/function () { | ||
@@ -1675,3 +1680,3 @@ function RemoteStorage(storage) { | ||
if (!(data instanceof file.File || data instanceof Buffer || data.name && data.data && data.data instanceof Buffer)) { | ||
if (!(isFileInstance(data) || isBufferInstance(data) || data.name && data.data && isBufferInstance(data.data))) { | ||
_context2.next = 5; | ||
@@ -1688,6 +1693,6 @@ break; | ||
allFiles = data.filter(function (item) { | ||
return item instanceof file.File || item instanceof Buffer || item.name && item.data && item.data instanceof Buffer; | ||
return isFileInstance(item) || isBufferInstance(item) || item.name && item.data && isBufferInstance(item.data); | ||
}); | ||
allObjects = data.filter(function (item) { | ||
return !(item instanceof file.File) && !(item instanceof Buffer); | ||
return !isFileInstance(item) && !isBufferInstance(item); | ||
}); | ||
@@ -1788,3 +1793,13 @@ | ||
var isBrowser = function isBrowser() { | ||
return typeof window !== "undefined"; | ||
}; | ||
var fileOrBufferUnion = isBrowser() ? [zod.z["instanceof"](File), zod.z.string()] : [zod.z["instanceof"](Buffer), zod.z.string()]; | ||
var FileBufferOrStringSchema = zod.z.union(fileOrBufferUnion); | ||
exports.FileBufferOrStringSchema = FileBufferOrStringSchema; | ||
exports.IpfsStorage = IpfsStorage; | ||
exports.RemoteStorage = RemoteStorage; | ||
exports.isBrowser = isBrowser; | ||
exports.isBufferInstance = isBufferInstance; | ||
exports.isFileInstance = isFileInstance; |
{ | ||
"name": "@thirdweb-dev/storage", | ||
"version": "0.1.0", | ||
"version": "0.1.1-nightly-274afb5", | ||
"main": "dist/thirdweb-dev-storage.cjs.js", | ||
"repository": "https://github.com/thirdweb-dev/storage.git", | ||
"author": "adam-maj <mr.adam.maj@gmail.com>", | ||
"module": "dist/thirdweb-dev-storage.esm.js", | ||
"repository": { | ||
"directory": "packages/storage", | ||
"type": "git", | ||
"url": "https://github.com/thirdweb-dev/js.git" | ||
}, | ||
"author": "thirdweb eng <eng@thirdweb.com>", | ||
"license": "Apache-2.0", | ||
"scripts": { | ||
"build": "tsc --noEmit && preconstruct build", | ||
"build": "tsc && preconstruct build", | ||
"test": "ts-mocha 'test/**/*.ts' --paths -t 120000 -r esm -p tsconfig.testing.json" | ||
@@ -24,3 +29,2 @@ }, | ||
"@preconstruct/cli": "^2.2.1", | ||
"@trivago/prettier-plugin-sort-imports": "^3.3.0", | ||
"@types/chai": "^4.3.3", | ||
@@ -32,10 +36,4 @@ "@types/mocha": "^9.1.1", | ||
"eslint": "^8.22.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-plugin-inclusive-language": "^2.2.0", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"eslint-plugin-tsdoc": "^0.2.16", | ||
"esm": "^3.2.25", | ||
"mocha": "^10.0.0", | ||
"prettier": "^2.7.1", | ||
"ts-mocha": "^10.0.0", | ||
@@ -46,6 +44,6 @@ "tsc": "^2.0.4", | ||
"dependencies": { | ||
"@web-std/file": "^3.0.2", | ||
"cross-fetch": "^3.1.5", | ||
"form-data": "^4.0.0" | ||
"form-data": "^4.0.0", | ||
"zod": "^3.18.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
210026
14
28
4949
1
9
+ Addedzod@^3.18.0
+ Addedzod@3.24.1(transitive)
- Removed@web-std/file@^3.0.2
- Removed@web-std/blob@3.0.5(transitive)
- Removed@web-std/file@3.0.3(transitive)
- Removed@web-std/stream@1.0.0(transitive)
- Removed@zxing/text-encoding@0.9.0(transitive)
- Removedavailable-typed-arrays@1.0.7(transitive)
- Removedcall-bind@1.0.8(transitive)
- Removedcall-bind-apply-helpers@1.0.1(transitive)
- Removedcall-bound@1.0.2(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removeddunder-proto@1.0.0(transitive)
- Removedes-define-property@1.0.1(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedes-object-atoms@1.0.0(transitive)
- Removedfor-each@0.3.3(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-intrinsic@1.2.6(transitive)
- Removedgopd@1.2.0(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-symbols@1.1.0(transitive)
- Removedhas-tostringtag@1.0.2(transitive)
- Removedhasown@2.0.2(transitive)
- Removedinherits@2.0.4(transitive)
- Removedis-arguments@1.2.0(transitive)
- Removedis-callable@1.2.7(transitive)
- Removedis-generator-function@1.0.10(transitive)
- Removedis-typed-array@1.1.13(transitive)
- Removedmath-intrinsics@1.0.0(transitive)
- Removedpossible-typed-array-names@1.0.0(transitive)
- Removedset-function-length@1.2.2(transitive)
- Removedutil@0.12.5(transitive)
- Removedweb-encoding@1.1.5(transitive)
- Removedweb-streams-polyfill@3.3.3(transitive)
- Removedwhich-typed-array@1.1.16(transitive)