@soga/mp4box 1.0.9 → 1.3.7

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/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e,r=Object.create,t=Object.defineProperty,o=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,a=Object.getPrototypeOf,i=Object.prototype.hasOwnProperty,u=(e,r,a,u)=>{if(r&&"object"==typeof r||"function"==typeof r)for(let l of n(r))i.call(e,l)||l===a||t(e,l,{get:()=>r[l],enumerable:!(u=o(r,l))||u.enumerable});return e},l={};((e,r)=>{for(var o in r)t(e,o,{get:r[o],enumerable:!0})})(l,{getMp4boxInfo:()=>d}),module.exports=(e=l,u(t({},"__esModule",{value:!0}),e));var f=require("@soga/error"),s=require("fs-extra"),c=((e,o,n)=>(n=null!=e?r(a(e)):{},u(!o&&e&&e.__esModule?n:t(n,"default",{value:e,enumerable:!0}),e)))(require("mp4box"));async function d(e){try{const r=await new Promise((r,t)=>{const o=c.createFile();let n=0;const a=(0,s.createReadStream)(e,{highWaterMark:41943040});a.on("data",e=>{const r=new Uint8Array(e).buffer;r.fileStart=n,n+=e.byteLength,o.appendBuffer(r)}),a.on("end",()=>{o.flush()}),a.on("error",e=>{t(e)}),o.onError=function(e,r){a.destroy(),o.flush(),t(new Error(r))},o.onReady=function(e){a.destroy(),o.flush(),r(e)}}),t=r.tracks.filter(e=>!!e.audio||"SoundHandler"==e.name),o=r.tracks.filter(e=>!!e.video||"VideoHandler"==e.name);return{duration:r.duration,mime:r.mime,audios:t,videos:o}}catch(r){throw(0,f.buildDError)(r,{message:"Failed to get mp4box info",detail:`Failed to get mp4box info: ${e}`})}}
1
+ var e,t=Object.create,s=Object.defineProperty,a=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,n=Object.prototype.hasOwnProperty,o=(e,t,i,o)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let c of r(t))n.call(e,c)||c===i||s(e,c,{get:()=>t[c],enumerable:!(o=a(t,c))||o.enumerable});return e},c={};((e,t)=>{for(var a in t)s(e,a,{get:t[a],enumerable:!0})})(c,{getMp4boxInfo:()=>f}),module.exports=(e=c,o(s({},"__esModule",{value:!0}),e));var u=class extends Error{rewritable;message;stack;details;cause;constructor(e){super(e.message),this.rewritable=e.rewritable||!1,this.message=e.message||"",this.details=e.detail?[e.detail]:this.message?[this.message]:[],this.stack=e.stack,this.name="DError",this.cause=e.cause}toJson(){return{name:this.name,message:this.message,stack:this.stack,details:this.details,cause:this.cause}}toString(){const e=this.toJson();return JSON.stringify(e,null,2)}},l=(e,t={})=>{if(e instanceof u){if(!e.rewritable)return e;t.message&&(e.message=t.message);const s=t.detail||t.message;return s&&(e.details=e.details?[s,...e.details]:[s]),t.stack&&(e.stack=`${t.stack}\n${e.stack}`),t.cause?e.cause=t.cause:e.cause&&(e.cause=e.cause),e}{const s=new u({message:e.message,stack:e.stack});t.message&&(s.message=t.message);const a=t.detail||t.message;return a&&(s.details=s.details?[a,...s.details]:[a]),t.stack&&(s.stack=`${t.stack}\n${s.stack}`),t.cause?s.cause=t.cause:e.cause&&(s.cause=e.cause),void 0!==t.rewritable&&(s.rewritable=t.rewritable),s}},d=require("fs-extra"),m=((e,a,r)=>(r=null!=e?t(i(e)):{},o(!a&&e&&e.__esModule?r:s(r,"default",{value:e,enumerable:!0}),e)))(require("mp4box"));async function f(e){try{const t=await new Promise((t,s)=>{const a=m.createFile();let r=0;const i=(0,d.createReadStream)(e,{highWaterMark:41943040});i.on("data",e=>{const t=new Uint8Array(e).buffer;t.fileStart=r,r+=e.byteLength,a.appendBuffer(t)}),i.on("end",()=>{a.flush()}),i.on("error",e=>{s(e)}),a.onError=function(e,t){i.destroy(),a.flush(),s(new Error(t))},a.onReady=function(e){i.destroy(),a.flush(),t(e)}}),s=t.tracks.filter(e=>!!e.audio||"SoundHandler"==e.name),a=t.tracks.filter(e=>!!e.video||"VideoHandler"==e.name);return{duration:t.duration,mime:t.mime,audios:s,videos:a}}catch(t){throw l(t,{message:"Failed to get mp4box info",detail:`Failed to get mp4box info: ${e}`})}}
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{buildDError as o}from"@soga/error";import{createReadStream as r}from"fs-extra";import*as e from"mp4box";async function t(t){try{const o=await new Promise((o,n)=>{const a=e.createFile();let i=0;const s=r(t,{highWaterMark:41943040});s.on("data",o=>{const r=new Uint8Array(o).buffer;r.fileStart=i,i+=o.byteLength,a.appendBuffer(r)}),s.on("end",()=>{a.flush()}),s.on("error",o=>{n(o)}),a.onError=function(o,r){s.destroy(),a.flush(),n(new Error(r))},a.onReady=function(r){s.destroy(),a.flush(),o(r)}}),n=o.tracks.filter(o=>!!o.audio||"SoundHandler"==o.name),a=o.tracks.filter(o=>!!o.video||"VideoHandler"==o.name);return{duration:o.duration,mime:o.mime,audios:n,videos:a}}catch(r){throw o(r,{message:"Failed to get mp4box info",detail:`Failed to get mp4box info: ${t}`})}}export{t as getMp4boxInfo};
1
+ var e=class extends Error{rewritable;message;stack;details;cause;constructor(e){super(e.message),this.rewritable=e.rewritable||!1,this.message=e.message||"",this.details=e.detail?[e.detail]:this.message?[this.message]:[],this.stack=e.stack,this.name="DError",this.cause=e.cause}toJson(){return{name:this.name,message:this.message,stack:this.stack,details:this.details,cause:this.cause}}toString(){const e=this.toJson();return JSON.stringify(e,null,2)}};import{createReadStream as s}from"fs-extra";import*as a from"mp4box";async function t(t){try{const e=await new Promise((e,r)=>{const i=a.createFile();let n=0;const o=s(t,{highWaterMark:41943040});o.on("data",e=>{const s=new Uint8Array(e).buffer;s.fileStart=n,n+=e.byteLength,i.appendBuffer(s)}),o.on("end",()=>{i.flush()}),o.on("error",e=>{r(e)}),i.onError=function(e,s){o.destroy(),i.flush(),r(new Error(s))},i.onReady=function(s){o.destroy(),i.flush(),e(s)}}),r=e.tracks.filter(e=>!!e.audio||"SoundHandler"==e.name),i=e.tracks.filter(e=>!!e.video||"VideoHandler"==e.name);return{duration:e.duration,mime:e.mime,audios:r,videos:i}}catch(s){throw((s,a={})=>{if(s instanceof e){if(!s.rewritable)return s;a.message&&(s.message=a.message);const e=a.detail||a.message;return e&&(s.details=s.details?[e,...s.details]:[e]),a.stack&&(s.stack=`${a.stack}\n${s.stack}`),a.cause?s.cause=a.cause:s.cause&&(s.cause=s.cause),s}{const t=new e({message:s.message,stack:s.stack});a.message&&(t.message=a.message);const r=a.detail||a.message;return r&&(t.details=t.details?[r,...t.details]:[r]),a.stack&&(t.stack=`${a.stack}\n${t.stack}`),a.cause?t.cause=a.cause:s.cause&&(t.cause=s.cause),void 0!==a.rewritable&&(t.rewritable=a.rewritable),t}})(s,{message:"Failed to get mp4box info",detail:`Failed to get mp4box info: ${t}`})}}export{t as getMp4boxInfo};
package/package.json CHANGED
@@ -3,15 +3,10 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.0.9",
6
+ "version": "1.3.7",
7
7
  "main": "./dist/index.js",
8
8
  "module": "./dist/index.mjs",
9
9
  "types": "./dist/index.d.ts",
10
- "scripts": {
11
- "demo": "tsx ./demo/demo.ts",
12
- "build": "rimraf dist && tsup src/index.ts --format cjs,esm --dts --minify terser",
13
- "prepublishOnly": "npm run build"
14
- },
15
10
  "files": [
16
11
  "dist"
17
12
  ],
@@ -20,15 +15,20 @@
20
15
  "license": "ISC",
21
16
  "description": "",
22
17
  "dependencies": {
23
- "@soga/error": "^1.0.8",
24
- "fs-extra": "^11.3.0",
25
- "mp4box": "^1.4.4"
18
+ "fs-extra": "^11.3.2",
19
+ "mp4box": "^1.4.4",
20
+ "@soga/error": "^1.3.7"
26
21
  },
27
22
  "devDependencies": {
28
23
  "@types/fs-extra": "^11.0.4",
29
24
  "rimraf": "^6.0.1",
30
25
  "terser": "^5.43.1",
31
26
  "tsup": "^8.5.0",
32
- "tsx": "^4.20.3"
27
+ "tsx": "^4.20.6",
28
+ "@soga/typescript-config": "^1.3.7"
29
+ },
30
+ "scripts": {
31
+ "demo": "tsx ./demo/demo.ts",
32
+ "build": "rimraf dist && tsup src/index.ts --format cjs,esm --dts --minify terser"
33
33
  }
34
- }
34
+ }