zmp-sdk 2.37.4-0 → 2.37.5

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.
@@ -0,0 +1 @@
1
+ import o,{object as e}from'./../external/zod/lib/index.mjs.js';import{functionHandler as n}from"../utils/decorator.js";import{ZMACameraImp as i}from"../media/zmaCamera.js";var t=e({play:o.function(),pause:o.function()}).refine((function(o){return"play"in o&&"pause"in o}),{message:"Invalid HTMLVideoElement"}),a=[e({videoElement:t,mediaConstraints:o.object({width:o.number().min(100).optional(),height:o.number().min(100).optional(),facingMode:o.string().optional(),audio:o.boolean().optional(),video:o.boolean().optional(),deviceId:o.string().optional(),mirrored:o.boolean().optional()}).nullish()}).optional()];function r(o){return n("createCameraContext",a,[o],(function(o){return console.log("createCameraContext",o),new i(o.videoElement,o.mediaConstraints)}))}export{r as createCameraContext};
@@ -0,0 +1 @@
1
+ import r from'./../external/@swc/helpers/src/_async_to_generator.mjs.js';import o,{object as e}from'./../external/zod/lib/index.mjs.js';import t from"../appEnv/index.js";import n from"../common/notFound.js";import{functionHandler as s}from"../utils/decorator.js";import i from"../common/apis/general/saveFile.js";import{__generator as m}from'./../external/tslib/tslib.es6.js';var u=[e({url:o.string()}).optional()];function l(r){return a.apply(this,arguments)}function a(){return a=r((function(o){return m(this,(function(e){return[2,s("downloadFile",u,[o],(l=r((function(r){var o;return m(this,(function(e){switch(e.label){case 0:return t.isMp?(o=r.url,[4,i(o)]):[3,2];case 1:return[2,e.sent()];case 2:return t.isMpWeb?[2,Promise.resolve()]:[2,Promise.reject(n("saveFile",{}))]}}))})),function(r){return l.apply(this,arguments)}))];var l}))})),a.apply(this,arguments)}export{l as downloadFile};
@@ -0,0 +1 @@
1
+ import e from'./../external/@swc/helpers/src/_async_to_generator.mjs.js';import t,{object as o}from'./../external/zod/lib/index.mjs.js';import r from"../appEnv/index.js";import i from"../common/notFound.js";import{functionHandler as n}from"../utils/decorator.js";import s from"../common/apis/general/getFileInfo.js";import{__generator as m}from'./../external/tslib/tslib.es6.js';var l=[o({filePath:t.string(),digestAlgorithm:t.enum(["sha1","md5"])}).optional()];function p(e){return u.apply(this,arguments)}function u(){return u=e((function(t){return m(this,(function(o){return[2,n("getFileInfo",l,[t],(p=e((function(e){return m(this,(function(t){switch(t.label){case 0:return r.isMp?[4,s(e.filePath,e.digestAlgorithm)]:[3,2];case 1:return[2,t.sent()];case 2:return r.isMpWeb?[2,Promise.resolve({size:"",digest:"",type:""})]:[2,Promise.reject(i("getFileInfo",{}))]}}))})),function(e){return p.apply(this,arguments)}))];var p}))})),u.apply(this,arguments)}export{p as getFileInfo};
@@ -0,0 +1 @@
1
+ import e from'./../external/@swc/helpers/src/_async_to_generator.mjs.js';import t from"../appEnv/index.js";import r from"../common/notFound.js";import{functionHandler as o}from"../utils/decorator.js";import s from"../common/apis/general/getSavedFileList.js";import{__generator as n}from'./../external/tslib/tslib.es6.js';function i(e){return m.apply(this,arguments)}function m(){return m=e((function(i){return n(this,(function(m){return[2,o("getSavedFileList",[],[i],(u=e((function(e){return n(this,(function(e){switch(e.label){case 0:return t.isMp?[4,s()]:[3,2];case 1:return[2,e.sent()];case 2:return t.isMpWeb?[2,Promise.resolve()]:[2,Promise.reject(r("getSavedFileList",{}))]}}))})),function(e){return u.apply(this,arguments)}))];var u}))})),m.apply(this,arguments)}export{i as getSavedFileList};
@@ -0,0 +1 @@
1
+ import e from'./../external/@swc/helpers/src/_async_to_generator.mjs.js';import r,{object as o}from'./../external/zod/lib/index.mjs.js';import t from"../appEnv/index.js";import n from"../common/notFound.js";import{functionHandler as i}from"../utils/decorator.js";import s from"../common/apis/general/removeSavedFile.js";import{__generator as m}from'./../external/tslib/tslib.es6.js';var a=[o({filePath:r.string()}).optional()];function l(e){return p.apply(this,arguments)}function p(){return p=e((function(r){return m(this,(function(o){return[2,i("removeSavedFile",a,[r],(l=e((function(e){return m(this,(function(r){switch(r.label){case 0:return t.isMp?[4,s(e.filePath)]:[3,2];case 1:return[2,r.sent()];case 2:return t.isMpWeb?[2,Promise.resolve()]:[2,Promise.reject(n("removeSavedFile",{}))]}}))})),function(e){return l.apply(this,arguments)}))];var l}))})),p.apply(this,arguments)}export{l as removeSavedFile};
@@ -0,0 +1 @@
1
+ import r from'./../external/@swc/helpers/src/_async_to_generator.mjs.js';import e,{object as o}from'./../external/zod/lib/index.mjs.js';import t from"../appEnv/index.js";import s from"../common/notFound.js";import{functionHandler as n}from"../utils/decorator.js";import i from"../common/apis/general/lfsSaveFile.js";import{__generator as m}from'./../external/tslib/tslib.es6.js';var a=[o({filePath:e.string()}).optional()];function l(r){return p.apply(this,arguments)}function p(){return p=r((function(e){return m(this,(function(o){return[2,n("saveFile",a,[e],(l=r((function(r){var e;return m(this,(function(o){switch(o.label){case 0:return t.isMp?(e=r.filePath,[4,i(e)]):[3,2];case 1:return[2,o.sent()];case 2:return t.isMpWeb?[2,Promise.resolve()]:[2,Promise.reject(s("saveFile",{}))]}}))})),function(r){return l.apply(this,arguments)}))];var l}))})),p.apply(this,arguments)}export{l as saveFile};
@@ -0,0 +1 @@
1
+ import t from'./../../../external/@swc/helpers/src/_async_to_generator.mjs.js';import n from"../../call/index.js";import{__generator as o}from'./../../../external/tslib/tslib.es6.js';var s,e=(s=t((function(t,s){return o(this,(function(o){return[2,new Promise((function(o,e){n("LFS_FILE_INFO",{file_path:t,digest_algorithm:s},{success:function(t){o(t)},fail:function(t){e(t)}},{})}))]}))})),function(t,n){return s.apply(this,arguments)});export{e as default};
@@ -0,0 +1 @@
1
+ import e from'./../../../external/@swc/helpers/src/_async_to_generator.mjs.js';import t from'./../../../external/@swc/helpers/src/_object_spread.mjs.js';import r from"../../call/index.js";import{__generator as s}from'./../../../external/tslib/tslib.es6.js';var o=e((function(){return s(this,(function(e){return[2,new Promise((function(e,s){r("LFS_LIST",{},{success:function(r){var s=r.map((function(e){var r=t({},e);try{r.filePath=r.file_path,r.createTime=r.created_time,delete r.file_path,delete r.created_time}catch(e){}return r}));e({list:s})},fail:function(e){s(e)}},{})}))]}))}));export{o as default};
@@ -1 +1 @@
1
- import e from'./../../../external/@swc/helpers/src/_async_to_generator.mjs.js';import t from"../../token.js";import{APIS as n}from"../../../constants.js";import{__generator as s}from'./../../../external/tslib/tslib.es6.js';var i,r=(i=e((function(i){var r,o;return s(this,(function(c){switch(c.label){case 0:return[4,t.getAccessToken(!0)];case 1:return r=c.sent(),o="id,name,user_id_by_oa,is_sensitive",o=i?"".concat(o,",picture.type(").concat(i,")"):"".concat(o,",picture"),[4,fetch("".concat(n.GET_USER_INFO,"?fields=").concat(o),{headers:{access_token:r||""}}).then(function(){var t=e((function(e){var t,n,i,r;return s(this,(function(s){switch(s.label){case 0:return[4,e.json()];case 1:return i=s.sent(),r=null==i?void 0:i.user_id_by_oa,[2,{id:null==i?void 0:i.id,name:(null==i?void 0:i.name)||"",avatar:(null==i||null===(t=i.picture)||void 0===t||null===(n=t.data)||void 0===n?void 0:n.url)||"",idByOA:r,followedOA:!!r,isSensitive:null==i?void 0:i.is_sensitive}]}}))}));return function(e){return t.apply(this,arguments)}}())];case 2:return[2,c.sent()]}}))})),function(e){return i.apply(this,arguments)});export{r as default};
1
+ import e from'./../../../external/@swc/helpers/src/_async_to_generator.mjs.js';import t from"../../token.js";import{APIS as n}from"../../../constants.js";import{canUseAccessTokenByDefault as s}from"../../../utils/common.js";import{__generator as r}from'./../../../external/tslib/tslib.es6.js';var i,o=(i=e((function(i){var o,c,a;return r(this,(function(u){switch(u.label){case 0:return[4,s()];case 1:return o=!u.sent(),[4,t.getAccessToken(o)];case 2:return c=u.sent(),a="id,name,user_id_by_oa,is_sensitive",a=i?"".concat(a,",picture.type(").concat(i,")"):"".concat(a,",picture"),[4,fetch("".concat(n.GET_USER_INFO,"?fields=").concat(a),{headers:{access_token:c||""}}).then(function(){var t=e((function(e){var t,n,s,i;return r(this,(function(r){switch(r.label){case 0:return[4,e.json()];case 1:return s=r.sent(),i=null==s?void 0:s.user_id_by_oa,[2,{id:null==s?void 0:s.id,name:(null==s?void 0:s.name)||"",avatar:(null==s||null===(t=s.picture)||void 0===t||null===(n=t.data)||void 0===n?void 0:n.url)||"",idByOA:i,followedOA:!!i,isSensitive:null==s?void 0:s.is_sensitive}]}}))}));return function(e){return t.apply(this,arguments)}}())];case 3:return[2,u.sent()]}}))})),function(e){return i.apply(this,arguments)});export{o as default};
@@ -0,0 +1 @@
1
+ import t from'./../../../external/@swc/helpers/src/_async_to_generator.mjs.js';import n from"../../call/index.js";import{__generator as s}from'./../../../external/tslib/tslib.es6.js';var e,o=(e=t((function(t){return s(this,(function(s){return[2,new Promise((function(s,e){n("LFS_FILE_SAVE",{file_path:t},{success:function(t){s({savedPath:t})},fail:function(t){e(t)}},{})}))]}))})),function(t){return e.apply(this,arguments)});export{o as default};
@@ -0,0 +1 @@
1
+ import e from'./../../../../external/@swc/helpers/src/_async_to_generator.mjs.js';import t from'./../../../../external/@swc/helpers/src/_class_call_check.mjs.js';import i from'./../../../../external/@swc/helpers/src/_create_class.mjs.js';import{MPEEmitter as n}from"../../../eventEmitter.js";import{__generator as s}from'./../../../../external/tslib/tslib.es6.js';var a="image/png",o=function(){function o(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"user",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,s=this;t(this,o),this.tick=function(){if(console.log("DUNGNN tick",s._userRequestFrameCallback,s.haveVideoStream()),s.haveVideoStream()&&s._userRequestFrameCallback){var e=s.getCanvas();s.drawFrame(),e?(e.toDataURL("image/png"),requestAnimationFrame(s.tick)):console.log("canvas not found")}},console.log("DUNGNN constructor",e,i,n),this._videoElement=e,this._videoElement.width=this._videoElement.width||640,this._videoElement.height=this._videoElement.height||360,this._facingMode=null!=i?i:"user",this._cameraList=[],this._streamList=[],this._selectedDeviceId="",this._canvasElement=n,this._ctx=null,this._hasUserMedia=!1,this._userRequestFrameCallback=!1,console.log("DUNGNN end const")}var r=o.prototype;return r.on=function(e,t){console.log("DUNGNN on",n,e,t)},r.off=function(e){console.log("DUNGNN off",n,e)},r.getQualityNumber=function(e){switch(e){case"high":return.8;case"normal":default:return.5;case"low":return.2}},r.getVideoInputs=function(e){var t=this;return this._cameraList=[],e.forEach((function(e){"videoinput"===e.kind&&t._cameraList.push(e)})),1==this._cameraList.length&&(this._facingMode="user"),this._cameraList},r.getMediaConstraints=function(){var e={};return""==this._selectedDeviceId?e.facingMode=this._facingMode:e.deviceId={exact:this._selectedDeviceId},e.width={exact:this._videoElement.width},e.height={exact:this._videoElement.height},{video:e,audio:!1}},r.selectCamera=function(){var e=!0,t=!1,i=void 0;try{for(var n,s=this._cameraList[Symbol.iterator]();!(e=(n=s.next()).done);e=!0){var a=n.value;if("user"==this._facingMode&&a.label.toLowerCase().includes("front")||"environment"==this._facingMode&&a.label.toLowerCase().includes("back")){this._selectedDeviceId=a.deviceId;break}}}catch(e){t=!0,i=e}finally{try{e||null==s.return||s.return()}finally{if(t)throw i}}},r.flip=function(){this._facingMode="user"==this._facingMode?"environment":"user",this._videoElement.style.transform="",this.selectCamera()},r.start=function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],i=this;return e((function(){return s(this,(function(e){return[2,new Promise((function(e,n){i.stop(),navigator.mediaDevices.getUserMedia(i.getMediaConstraints()).then((function(s){console.log("DUNGNN callback stream",s),i._streamList.push(s),i.info().then((function(s){console.log("DUNGNN info",s),i.selectCamera(),t?i.stream().then((function(t){e(i._facingMode)})).catch((function(e){n(e)})):e(i._selectedDeviceId)})).catch((function(e){n(e)}))})).catch((function(e){i._hasUserMedia=!1,n(e)}))}))]}))}))()},r.info=function(){var t=this;return e((function(){return s(this,(function(e){return[2,new Promise((function(e,i){navigator.mediaDevices.enumerateDevices().then((function(i){t.getVideoInputs(i),e(t._cameraList)})).catch((function(e){i(e)}))}))]}))}))()},r.stream=function(){var t=this;return e((function(){return s(this,(function(e){return[2,new Promise((function(e,i){navigator.mediaDevices.getUserMedia(t.getMediaConstraints()).then((function(i){t._streamList.push(i),t._videoElement.srcObject=i,"user"==t._facingMode&&(t._videoElement.style.transform="scale(-1,1)"),t._videoElement.play(),t._hasUserMedia=!0,t._userRequestFrameCallback&&t.tick(),e(t._facingMode)})).catch((function(e){t._hasUserMedia=!1,i(e)}))}))]}))}))()},r.stop=function(){this._streamList.forEach((function(e){e.getTracks().forEach((function(e){e.stop()}))})),this._hasUserMedia=!1},r.takePhoto=function(e){if(!this._hasUserMedia)return null;var t=e||{};console.log("DUNGNN takePhoto",t);var i,n=this.getCanvas(t);return this.drawFrame(t),n&&n.toDataURL(null!==(i=t.format)&&void 0!==i?i:a,this.getQualityNumber(t.quality))},r.haveVideoStream=function(){var e=this._videoElement;return e&&e.videoHeight>0&&this._hasUserMedia},r.getCanvas=function(e){var t=this._videoElement,i=e||{};if(!this.haveVideoStream())return null;if(!this._ctx){var n=t.videoWidth,s=t.videoHeight;if(!i.useVideoSourceSize){var a=n/s;s=(n=i.minScreenshotWidth||t.clientWidth)/a,i.minScreenshotHeight&&s<i.minScreenshotHeight&&(n=(s=i.minScreenshotHeight)*a)}this._canvasElement=document.createElement("canvas"),this._canvasElement.width=(null==i?void 0:i.width)||n,this._canvasElement.height=(null==i?void 0:i.height)||s,this._ctx=this._canvasElement.getContext("2d")}return this._canvasElement},r.drawFrame=function(e){var t=this._videoElement,i=e||{};if(t&&this._ctx&&this._canvasElement){var n=this._canvasElement,s=this._ctx;n.width=(null==i?void 0:i.width)||n.width,n.height=(null==i?void 0:i.height)||n.height,(null==i?void 0:i.mirrored)&&(s.translate(n.width,0),s.scale(-1,1)),s.clearRect(0,0,n.width,n.height),s.drawImage(t,0,0,n.width,n.height),(null==i?void 0:i.mirrored)&&(s.scale(-1,1),s.translate(-n.width,0))}},i(o,[{key:"facingMode",get:function(){return this._facingMode},set:function(e){this._facingMode=e}},{key:"cameraList",get:function(){return this._cameraList}},{key:"cameraCount",get:function(){return this._cameraList.length}},{key:"selectedDeviceId",get:function(){return this._selectedDeviceId}}]),o}();export{o as default};
@@ -1 +1 @@
1
- import e from'./../../../external/@swc/helpers/src/_async_to_generator.mjs.js';import n from'./../../../external/@swc/helpers/src/_object_spread.mjs.js';import r from'./../../../external/@swc/helpers/src/_object_spread_props.mjs.js';import t from"../../call/index.js";import i from"../../token.js";import{ZAPP_ID as o,APP_ID as l,ZALO_SUPPORT_SHARE_MULTI_IMAGE_VERSION as s}from"../../../constants.js";import a from"./getZMPShareInfo.js";import{__generator as u}from'./../../../external/tslib/tslib.es6.js';import{ShareSheetType as d}from"../../../types/enum.js";import c from"../../../appEnv/getEnv.js";var m,p=(m=e((function(e,m){var p,h,v,f,g,_,j,U,b,w;return u(this,(function(u){switch(u.label){case 0:switch(p={},h=e,e){case"image":return[3,1];case"gif":return[3,2];case"video":return[3,3];case"link":return[3,4];case"oa":return[3,5];case"zmp":return[3,6];case"zmp_deep_link":return[3,9]}return[3,12];case 1:return _=[],j=(null===(f=c())||void 0===f?void 0:f.zaloVersion)||0,U=(null===(g=c())||void 0===g?void 0:g.platformName)||"unknown",Number(j)>=s[U]&&(h="multi_image"),Array.isArray(null==m?void 0:m.imageUrls)&&(null==m?void 0:m.imageUrls.length)>0?_=null==m?void 0:m.imageUrls:_.push(null==m?void 0:m.imageUrl),p={photoUrls:_,photoUrl:null==m?void 0:m.imageUrl,caption:null==m?void 0:m.caption},[3,13];case 2:return p={photoUrl:null==m?void 0:m.imageUrl,gifUrl:null==m?void 0:m.gifUrl,width:null==m?void 0:m.width,height:null==m?void 0:m.height},[3,13];case 3:return p={videoThumb:null==m?void 0:m.videoThumb,videoUrl:null==m?void 0:m.videoUrl,width:null==m?void 0:m.width,height:null==m?void 0:m.height},[3,13];case 4:return p={link:null==m?void 0:m.link,chatOnly:(null==m?void 0:m.chatOnly)?1:0},[3,13];case 5:return p={uid:null==m?void 0:m.id},[3,13];case 6:case 9:return[4,i.getAccessToken()];case 7:case 10:return v=u.sent(),[4,a(l,v||"",(null==m?void 0:m.title)||"",(null==m?void 0:m.description)||"",(null==m?void 0:m.thumbnail)||"",null==m?void 0:m.path)];case 8:return b=u.sent(),p={data:{ZInstantAPIInfo:{url:"".concat(b.zinstantApi),zinstantdata_id:"templateId=".concat(b.ztemplateId,"&appId=").concat(l,"&shareId=").concat(b.shareId)},previewMsgText:{msg:{en:"Zalo Mini Program",vi:"Chương trình nhỏ"}},enableReactions:1}},[3,13];case 11:return w=u.sent().shareableLink,p={link:w,chatOnly:0},[3,13];case 12:return[3,13];case 13:return[2,new Promise((function(e,i){t("OPEN_SHARESHEET",r(n({type:d[h]},p),{zapp:o}),{success:function(n){e({status:null==n?void 0:n.status,shareType:null==n?void 0:n.share_type,numberOfUser:null==n?void 0:n.uid_to_size})},fail:function(e){i(e)}},{timeout:!1})}))]}}))})),function(e,n){return m.apply(this,arguments)});export{p as default};
1
+ import e from'./../../../external/@swc/helpers/src/_async_to_generator.mjs.js';import r from'./../../../external/@swc/helpers/src/_object_spread.mjs.js';import n from'./../../../external/@swc/helpers/src/_object_spread_props.mjs.js';import t from"../../call/index.js";import i from"../../token.js";import{ZAPP_ID as l,APP_ID as s,ZALO_SUPPORT_SHARE_MULTI_IMAGE_VERSION as o}from"../../../constants.js";import a from"./getZMPShareInfo.js";import{__generator as u}from'./../../../external/tslib/tslib.es6.js';import{ShareSheetType as d}from"../../../types/enum.js";import c from"../../../appEnv/getEnv.js";var m,h=(m=e((function(e,m){var h,p,v,f,g,_,j,U,w,b,I,y;return u(this,(function(u){switch(u.label){case 0:switch(h={},p=e,e){case"image":return[3,1];case"gif":return[3,2];case"video":return[3,3];case"link":return[3,4];case"oa":return[3,5];case"zmp":return[3,6];case"zmp_deep_link":return[3,9]}return[3,12];case 1:return _=[],j=(null===(f=c())||void 0===f?void 0:f.zaloVersion)||0,U=(null===(g=c())||void 0===g?void 0:g.platformName)||"unknown",Number(j)>=o[U]&&(p="multi_image"),Array.isArray(null==m?void 0:m.imageUrls)&&(null==m?void 0:m.imageUrls.length)>0?_=null==m?void 0:m.imageUrls:_.push(null==m?void 0:m.imageUrl),h={photoUrls:_,photoUrl:null==m?void 0:m.imageUrl,caption:null==m?void 0:m.caption},[3,13];case 2:return h={photoUrl:null==m?void 0:m.imageUrl,gifUrl:null==m?void 0:m.gifUrl,width:null==m?void 0:m.width,height:null==m?void 0:m.height},[3,13];case 3:return h={videoThumb:null==m?void 0:m.videoThumb,videoUrl:null==m?void 0:m.videoUrl,width:null==m?void 0:m.width,height:null==m?void 0:m.height},[3,13];case 4:return h={link:null==m?void 0:m.link,chatOnly:(null==m?void 0:m.chatOnly)?1:0},[3,13];case 5:return h={uid:null==m?void 0:m.id},[3,13];case 6:case 9:return[4,i.getAccessToken()];case 7:case 10:return v=u.sent(),[4,a(s,v||"",(null==m?void 0:m.title)||"",(null==m?void 0:m.description)||"",(null==m?void 0:m.thumbnail)||"",null==m?void 0:m.path)];case 8:return w=u.sent(),h={data:{ZInstantAPIInfo:{url:"".concat(w.zinstantApi),zinstantdata_id:"templateId=".concat(w.ztemplateId,"&appId=").concat(s,"&shareId=").concat(w.shareId)},previewMsgText:{msg:{en:"Zalo Mini Program",vi:"Chương trình nhỏ"}},enableReactions:1}},[3,13];case 11:return b=u.sent().shareableLink,I=new URL(b),y=I.searchParams.getAll("zshareId"),I.searchParams.delete("zshareId"),y.length>0&&I.searchParams.append("zshareId",y[0]),h={link:I.href,chatOnly:0},[3,13];case 12:return[3,13];case 13:return[2,new Promise((function(e,i){t("OPEN_SHARESHEET",n(r({type:d[p]},h),{zapp:l}),{success:function(r){e({status:null==r?void 0:r.status,shareType:null==r?void 0:r.share_type,numberOfUser:null==r?void 0:r.uid_to_size})},fail:function(e){i(e)}},{timeout:!1})}))]}}))})),function(e,r){return m.apply(this,arguments)});export{h as default};
@@ -1 +1 @@
1
- import e from'./../../../../external/@swc/helpers/src/_async_to_generator.mjs.js';import t from'./../../../../external/@swc/helpers/src/_object_spread.mjs.js';import o from'./../../../../external/@swc/helpers/src/_object_spread_props.mjs.js';import r from"../../../token.js";import n from"../../../../utils/query-string.js";import{apiResponse as s}from"../../../../utils/response.js";import{PAYMENT_H5_URL as a,PAYMENT_APIS as i,APP_ID as p}from"../../../../constants.js";import c from"../openWebview.js";import{MPEEmitter as d}from"../../../eventEmitter.js";import m from"./checkTransaction.js";import{__generator as u}from'./../../../../external/tslib/tslib.es6.js';import{Events as f}from"../../../../types/enum.js";var l,h=(l=e((function(l,h,j,w,y,g,b){var I,_,C,R,O,v,S,P,A,E,N,T,U,k,z,J,q;return u(this,(function(x){switch(x.label){case 0:I=p,(_=new URLSearchParams).append("amount",l.toString()),_.append("item",encodeURIComponent(JSON.stringify(h))),_.append("appId",I),j&&_.append("desc",encodeURIComponent(j)),w&&(C=w,"object"==typeof w&&(C=JSON.stringify(w)),_.append("extradata",encodeURIComponent(C))),y&&(R=y,"object"==typeof y&&(R=JSON.stringify(y)),_.append("payload",encodeURIComponent(R))),g&&("string"==typeof g?(_.append("method",g),_.append("isCustom","false")):"object"==typeof g&&(_.append("method",g.id),_.append("isCustom",JSON.stringify(g.isCustom)))),b&&_.append("mac",b),O={headers:{"Content-Type":"application/x-www-form-urlencoded",authorization:"Bearer "}},x.label=1;case 1:return x.trys.push([1,6,,7]),[4,r.getAccessToken().catch((function(){throw s.error.loginRequired}))];case 2:return v=x.sent(),O.headers.authorization="Bearer ".concat(v),[4,fetch(i.CREATE_ORDER,o(t({method:"POST"},O),{body:_}))];case 3:return[4,x.sent().json()];case 4:if(!(S=x.sent()).data||0!==S.err)throw s.error.badRequest(S.msg);return P=S.data.id,A=S.data.jwt,E=window.APP_VERSION,N=window.APP_ENV,T={miniAppId:I,orderId:P},U=S.data.method,k=S.data.isCustom,A&&(T.token=A),E&&(T.version=E),N&&(T.env=N),U&&(T.method=U),k&&(T.isCustom=k),z=n.encode(T),J=new URL("?".concat(z),a).toString(),[4,c(J).then((function(){var r=!1;d.getInstance().once(f.WebviewClosed,(function(){setTimeout(e((function(){var e;return u(this,(function(n){switch(n.label){case 0:return r?[3,2]:[4,m({zmpOrderId:P})];case 1:(e=n.sent()).err>=0&&!e.isCustom&&d.getInstance().emit(f.PaymentClose,e.err,o(t({},e),{zmpOrderId:P})),n.label=2;case 2:return[2]}}))})),500)})),d.getInstance().once(f.OpenApp,(function(){r=!0}))}))];case 5:return x.sent(),[2,{orderId:P}];case 6:throw q=x.sent(),console.log("Internal error"),q;case 7:return[2]}}))})),function(e,t,o,r,n,s,a){return l.apply(this,arguments)});export{h as default};
1
+ import e from'./../../../../external/@swc/helpers/src/_async_to_generator.mjs.js';import t from'./../../../../external/@swc/helpers/src/_object_spread.mjs.js';import o from'./../../../../external/@swc/helpers/src/_object_spread_props.mjs.js';import r from"../../../token.js";import n from"../../../../utils/query-string.js";import{apiResponse as s}from"../../../../utils/response.js";import{PAYMENT_H5_URL as a,PAYMENT_APIS as i,APP_ID as p}from"../../../../constants.js";import m from"../openWebview.js";import{MPEEmitter as d}from"../../../eventEmitter.js";import c from"./checkTransaction.js";import{getZaloVersionCode as u}from"../../../utils.js";import{__generator as f}from'./../../../../external/tslib/tslib.es6.js';import l from"../../../../appEnv/getEnv.js";import{Events as h}from"../../../../types/enum.js";var j,w=(j=e((function(j,w,y,g,b,C,I){var _,v,R,O,S,E,N,P,A,T,U,k,z,J,q,x,L,B,V,W;return f(this,(function(D){switch(D.label){case 0:_=p,(v=new URLSearchParams).append("amount",j.toString()),v.append("item",encodeURIComponent(JSON.stringify(w))),v.append("appId",_),y&&v.append("desc",encodeURIComponent(y)),g&&(R=g,"object"==typeof g&&(R=JSON.stringify(g)),v.append("extradata",encodeURIComponent(R))),b&&(O=b,"object"==typeof b&&(O=JSON.stringify(b)),v.append("payload",encodeURIComponent(O))),C&&("string"==typeof C?(v.append("method",C),v.append("isCustom","false")):"object"==typeof C&&(v.append("method",C.id),v.append("isCustom",JSON.stringify(C.isCustom)))),I&&v.append("mac",I),S={headers:{"Content-Type":"application/x-www-form-urlencoded",authorization:"Bearer "}},D.label=1;case 1:return D.trys.push([1,6,,7]),[4,r.getAccessToken().catch((function(){throw s.error.loginRequired}))];case 2:return N=D.sent(),S.headers.authorization="Bearer ".concat(N),[4,fetch(i.CREATE_ORDER,o(t({method:"POST"},S),{body:v}))];case 3:return[4,D.sent().json()];case 4:if(!(P=D.sent()).data||0!==P.err)throw s.error.badRequest(P.msg);return A=P.data.id,T=P.data.jwt,U=window.APP_VERSION,k=window.APP_ENV,z={miniAppId:_,orderId:A},J=P.data.method,q=P.data.isCustom,T&&(z.token=T),U&&(z.version=U),k&&(z.env=k),J&&(z.method=J),q&&(z.isCustom=q),x=n.encode(z),L=new URL("?".concat(x),a).toString(),B=u(),V=((null===(E=l())||void 0===E?void 0:E.platformName)||"").toLowerCase(),[4,m(L,{style:"android"===V&&B<742?"normal":"bottomSheet"}).then((function(){var r=!1;d.getInstance().once(h.WebviewClosed,(function(){setTimeout(e((function(){var e;return f(this,(function(n){switch(n.label){case 0:return r?[3,2]:[4,c({zmpOrderId:A})];case 1:(e=n.sent()).err>=0&&!e.isCustom&&d.getInstance().emit(h.PaymentClose,e.err,o(t({},e),{zmpOrderId:A})),n.label=2;case 2:return[2]}}))})),500)})),d.getInstance().once(h.OpenApp,(function(){r=!0}))}))];case 5:return D.sent(),[2,{orderId:A}];case 6:throw W=D.sent(),console.log("Internal error"),W;case 7:return[2]}}))})),function(e,t,o,r,n,s,a){return j.apply(this,arguments)});export{w as default};
@@ -0,0 +1 @@
1
+ import n from'./../../../external/@swc/helpers/src/_async_to_generator.mjs.js';import t from"../../call/index.js";import{__generator as o}from'./../../../external/tslib/tslib.es6.js';var s,e=(s=n((function(n){return o(this,(function(o){return[2,new Promise((function(o,s){t("LFS_FILE_REMOVE",{file_path:n},{success:function(n){o(n)},fail:function(n){s(n)}},{})}))]}))})),function(n){return s.apply(this,arguments)});export{e as default};
@@ -0,0 +1 @@
1
+ import n from'./../../../external/@swc/helpers/src/_async_to_generator.mjs.js';import s from"../../call/index.js";import{__generator as t}from'./../../../external/tslib/tslib.es6.js';var e,o=(e=n((function(n){return t(this,(function(t){return[2,new Promise((function(t,e){s("SAVE_FILE",{fileUrl:n},{success:function(n){t({saved_path:n})},fail:function(n){e(n)}},{})}))]}))})),function(n){return e.apply(this,arguments)});export{o as default};
@@ -0,0 +1 @@
1
+ var o;!function(o){o.VIDEO="video",o.AUDIO="audio"}(o||(o={}));export{o as StreamType};
@@ -0,0 +1 @@
1
+ import e from'./../external/@swc/helpers/src/_async_to_generator.mjs.js';import t from'./../external/@swc/helpers/src/_class_call_check.mjs.js';import{MPEEmitter as i}from"../common/eventEmitter.js";import n from"../utils/lodash.js";import{CameraEvents as a,FacingMode as r,PhotoFormat as s,PhotoQuality as o,StreamType as c}from"../types/media.js";import{__generator as l}from'./../external/tslib/tslib.es6.js';import{Events as d}from"../types/enum.js";var u="ZMACameraImp",h={format:s.JPEG,quality:o.NORMAL,mirrored:!1,useVideoSourceSize:!1},m={width:1024,height:768,facingMode:r.FRONT,mirrored:!1,audio:!1,video:!0},v=function(){function o(e){var n,r,c,l,d,h=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,v=this;t(this,o),this._videoEnabled=!0,this._audioEnabled=null,this.tick=function(){if(v.haveVideoStream()&&v._userRequestFrameCallback){var e=v.getCanvas();if(v.drawFrame(),e){var t={data:e.toDataURL(s.PNG),width:e.width,height:e.height};i.getInstance().emit(a.OnFrameCallback,0,t),requestAnimationFrame(v.tick)}}},this._videoElement=e,this._mediaConstraints=null!=h?h:null,this._facingMode=null!==(n=null==h?void 0:h.facingMode)&&void 0!==n?n:m.facingMode,console.log("".concat(u," ZMACameraImp"),h,this._facingMode),this._cameraList=[],this._stream=null,this._selectedDeviceId=null!==(r=null==h?void 0:h.deviceId)&&void 0!==r?r:"",this._canvasElement=null,this._ctx=null,this._hasUserMedia=!1,this._mirror=null!==(c=null==h?void 0:h.mirrored)&&void 0!==c?c:m.mirrored,this._userRequestFrameCallback=!1,this._audioEnabled=null!==(l=null==h?void 0:h.audio)&&void 0!==l?l:m.audio,this._videoEnabled=null!==(d=null==h?void 0:h.video)&&void 0!==d?d:m.video}var v=o.prototype;return v.on=function(e,t){i.getInstance().on(e,(function(e){t(e)})),e===a.OnFrameCallback&&(this._userRequestFrameCallback=!0,this.tick())},v.off=function(e){i.getInstance().off(e),e===a.OnFrameCallback&&(this._userRequestFrameCallback=!1)},v.getQualityNumber=function(e){switch(e){case"high":return.9;case"normal":default:return.6;case"low":return.2}},v.getFacingMode=function(){return this._facingMode},v.getCameraList=function(){return this._cameraList},v.getCameraCount=function(){return this._cameraList.length},v.getSelectedDeviceId=function(){return this._selectedDeviceId},v.setDeviceId=function(t){var i=this;return e((function(){return l(this,(function(e){switch(e.label){case 0:return i._selectedDeviceId=t,i._hasUserMedia?[4,i.stream()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))()},v.getVideoInputs=function(e){var t=this;return this._cameraList=[],e.forEach((function(e){"videoinput"===e.kind&&t._cameraList.push(e)})),this._cameraList},v.updateMediaConstraints=function(t){var i=this;return e((function(){var e,a,r,s,o,c;return l(this,(function(l){switch(l.label){case 0:return n.isEmpty(t)?(console.log("".concat(u," constraints empty")),[2]):JSON.stringify(t)!==JSON.stringify(i._mediaConstraints)?(console.log("".concat(u," updateMediaConstraints"),JSON.stringify(i._mediaConstraints),JSON.stringify(t)),i._mediaConstraints=t,i._facingMode=null!==(e=null==t?void 0:t.facingMode)&&void 0!==e?e:i._facingMode,i._selectedDeviceId=null!==(a=null==t?void 0:t.deviceId)&&void 0!==a?a:i._selectedDeviceId,i._mirror=null!==(r=null==t?void 0:t.mirrored)&&void 0!==r?r:i._mirror,i._audioEnabled=null!==(s=null==t?void 0:t.audio)&&void 0!==s?s:i._audioEnabled,i._videoEnabled=null!==(o=null==t?void 0:t.video)&&void 0!==o?o:i._videoEnabled,i._selectedDeviceId=null!==(c=null==t?void 0:t.deviceId)&&void 0!==c?c:i._selectedDeviceId,i._hasUserMedia?[4,i.stream()]:[3,2]):(console.log("".concat(u," constraints not changed")),[2]);case 1:l.sent(),l.label=2;case 2:return[2]}}))}))()},v.getCurrentMediaConstraints=function(){var e=this._mediaConstraints,t={};this._videoElement.width=(null==e?void 0:e.width)||this._videoElement.width||m.width,this._videoElement.height=(null==e?void 0:e.height)||this._videoElement.height||m.height;var i=!1!==this._videoEnabled,n=!1!==this._audioEnabled;return i&&(""==this._selectedDeviceId&&null!==this._facingMode?t.facingMode=this._facingMode:t.deviceId={exact:this._selectedDeviceId},t.width={exact:this._videoElement.width},t.height={exact:this._videoElement.height}),{video:!!i&&t,audio:n}},v.selectCamera=function(){var e=!0,t=!1,i=void 0;try{for(var n,a=this._cameraList[Symbol.iterator]();!(e=(n=a.next()).done);e=!0){var s=n.value;if(this._facingMode==r.FRONT&&s.label.toLowerCase().includes("front")||this._facingMode==r.BACK&&s.label.toLowerCase().includes("back")){this._selectedDeviceId=s.deviceId;break}}}catch(e){t=!0,i=e}finally{try{e||null==a.return||a.return()}finally{if(t)throw i}}},v.flip=function(){var t=this;return e((function(){return l(this,(function(e){switch(e.label){case 0:return t._facingMode=t._facingMode==r.FRONT?r.BACK:r.FRONT,t._videoElement.style.transform="",t.selectCamera(),t._hasUserMedia?[4,t.stream()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))()},v.start=function(){var t=this;return e((function(){var n,r;return l(this,(function(s){return n=i.getInstance(),r=function(e){try{t._hasUserMedia&&t.stop()}catch(e){}},n.off(d.AppPaused,r),n.on(d.AppPaused,r),[2,new Promise((o=e((function(e,n){var r;return l(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,t.stream()];case 1:return s.sent(),i.getInstance().emit(a.OnStartCallback,0),e(t._selectedDeviceId),[3,3];case 2:return r=s.sent(),n(r),[3,3];case 3:return[2]}}))})),function(e,t){return o.apply(this,arguments)}))];var o}))}))()},v.info=function(){var t=this;return e((function(){return l(this,(function(e){return[2,new Promise((function(e,i){navigator.mediaDevices.enumerateDevices().then((function(i){t.getVideoInputs(i),e(t._cameraList)})).catch((function(e){i(e)}))}))]}))}))()},v.stream=function(){var t=this;return e((function(){return l(this,(function(i){return[2,new Promise((function(i,n){try{t._stop();var a=t.getCurrentMediaConstraints();if(console.log("".concat(u," stream"),a),!1===a.video&&!a.audio)return void i(t._facingMode);navigator.mediaDevices.getUserMedia(a).then((r=e((function(e){return l(this,(function(n){switch(n.label){case 0:return[4,t.info()];case 1:return n.sent(),t.selectCamera(),t.handleUserMedia(null,e),i(t._facingMode),[2]}}))})),function(e){return r.apply(this,arguments)})).catch((function(e){console.log("".concat(u," DUNGNN 2"),e),t.handleUserMedia(e),n(e)}))}catch(e){n(e)}var r}))]}))}))()},v.handleUserMedia=function(e,t){var i=this;if(!e&&t){this._stream=t;try{this._videoElement&&(this._videoElement.srcObject=t,(this._facingMode==r.FRONT||this._mirror)&&(this._videoElement.style.transform="scale(-1,1)"),this._videoElement.onloadedmetadata=function(){i._userRequestFrameCallback&&i.tick()},this._videoElement.play().then((function(){i._hasUserMedia=!0})).catch((function(e){console.log("".concat(u," DUNGNN 3"),e),i._hasUserMedia=!1})))}catch(e){console.log("".concat(u," DUNGNN 1"),e),this._hasUserMedia=!1}}else this._hasUserMedia=!1},v.updateTrackEnable=function(t,i){var n=this;return e((function(){return l(this,(function(e){switch(e.label){case 0:if(t===c.VIDEO){if(n._videoEnabled===i)return[2];n._videoEnabled=i}else{if(n._audioEnabled===i)return[2];n._audioEnabled=i}return[4,n.stream()];case 1:return e.sent(),[2]}}))}))()},v.pause=function(t){var i=this;return e((function(){return l(this,(function(e){switch(e.label){case 0:return[4,i.updateTrackEnable(t,!1)];case 1:return e.sent(),[2]}}))}))()},v.resume=function(t){var i=this;return e((function(){return l(this,(function(e){switch(e.label){case 0:return[4,i.updateTrackEnable(t,!0)];case 1:return e.sent(),[2]}}))}))()},v.isUsing=function(){return this._hasUserMedia},v.stop=function(){this._stop(),i.getInstance().emit(a.OnStopCallback,0)},v._stop=function(){o.stopMediaStream(this._stream),this._hasUserMedia=!1},v.setFacingMode=function(e){this._facingMode=e},v.setMirror=function(e){this._mirror=e,this._videoElement&&(this._videoElement.style.transform=e?"scale(-1,1)":"")},v.takePhoto=function(e){if(!this._hasUserMedia)return null;var t=e||{},i=this.getCanvas(t);if(this.drawFrame(t),i){var n=t.format||h.format;return{data:i.toDataURL(n,this.getQualityNumber(t.quality)),width:i.width,height:i.height}}return null},v.haveVideoStream=function(){var e=this._videoElement;return e&&e.videoHeight>0&&this._hasUserMedia},v.getCanvas=function(e){var t=this._videoElement,i=e||{};if(!this.haveVideoStream())return null;if(!this._ctx){var n=t.videoWidth,a=t.videoHeight;if(!i.useVideoSourceSize){var r=n/a;a=(n=i.minScreenshotWidth||t.clientWidth)/r,i.minScreenshotHeight&&a<i.minScreenshotHeight&&(n=(a=i.minScreenshotHeight)*r)}this._canvasElement=document.createElement("canvas"),this._canvasElement.width=(null==i?void 0:i.width)||n,this._canvasElement.height=(null==i?void 0:i.height)||a,this._ctx=this._canvasElement.getContext("2d")}return this._canvasElement},v.drawFrame=function(e){var t=this._videoElement,i=e||{};if(t&&this._ctx&&this._canvasElement){var n=this._canvasElement,a=this._ctx;n.width=(null==i?void 0:i.width)||n.width,n.height=(null==i?void 0:i.height)||n.height,((null==i?void 0:i.mirrored)||this._mirror||this._facingMode===r.FRONT)&&(a.translate(n.width,0),a.scale(-1,1)),console.log("".concat(u," drawFrame ").concat(n.width,"x").concat(n.height)),a.drawImage(t,0,0,n.width,n.height),((null==i?void 0:i.mirrored)||this._mirror||this._facingMode===r.FRONT)&&(a.scale(-1,1),a.translate(-n.width,0))}},o.stopMediaStream=function(e){e&&e.getTracks().map((function(t){e.removeTrack(t),t.stop()}))},o}();export{v as ZMACameraImp};
@@ -1 +1 @@
1
- var r="2.37.4-0";export{r as version};
1
+ var r="2.37.5";export{r as version};
@@ -0,0 +1 @@
1
+ var a,e,n,t,o;!function(a){a.OnFrameCallback="h5.event.camera.frame",a.OnStartCallback="h5.event.camera.start",a.OnStopCallback="h5.event.camera.stop"}(a||(a={})),function(a){a.FRONT="user",a.BACK="environment"}(e||(e={})),function(a){a.WEBP="image/webp",a.PNG="image/png",a.JPEG="image/jpeg"}(n||(n={})),function(a){a.HIGH="high",a.NORMAL="normal",a.LOW="low"}(t||(t={})),function(a){a.VIDEO="video",a.AUDIO="audio"}(o||(o={}));export{a as CameraEvents,e as FacingMode,n as PhotoFormat,t as PhotoQuality,o as StreamType};