Comparing version 0.0.39 to 0.0.40
@@ -195,3 +195,2 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
const { currentIndex, direction } = this.state; | ||
debugger; | ||
return html ` | ||
@@ -198,0 +197,0 @@ <ul class="list" role="region"> |
@@ -125,3 +125,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
></dy-divider> | ||
<dy-compartment .content=${currentContent}></dy-compartment> | ||
<dy-compartment | ||
.content=${html ` | ||
<style> | ||
dy-tab-panel::-webkit-scrollbar { | ||
width: 0; | ||
} | ||
</style> | ||
${currentContent} | ||
`} | ||
></dy-compartment> | ||
`; | ||
@@ -128,0 +137,0 @@ }; |
export declare function b64ToUtf8(str: string): string; | ||
export declare function base64ToArrayBuffer(str: string): ArrayBufferLike; | ||
export declare function utf8ToB64(str: string): string; | ||
export declare function arrayBufferToBase64(arrayBuffer: ArrayBuffer): string; | ||
export declare function base64ToArrayBuffer(s: string): ArrayBufferLike; | ||
export declare function hash(strOrAb: string | ArrayBuffer, options?: 'string'): Promise<string>; | ||
export declare function hash(strOrAb: string | ArrayBuffer, output: 'arrayBuffer'): Promise<ArrayBuffer>; | ||
//# sourceMappingURL=encode.d.ts.map |
@@ -0,7 +1,8 @@ | ||
function safaUrlToBase64Str(str) { | ||
return str.replaceAll('-', '+').replaceAll('_', '/'); | ||
} | ||
// https://developer.mozilla.org/en-US/docs/Glossary/Base64#solution_1_%E2%80%93_escaping_the_string_before_encoding_it | ||
export function b64ToUtf8(str) { | ||
return decodeURIComponent(window | ||
.atob( | ||
// Compatible with jwt | ||
str.replace(/-/g, '+').replace(/_/g, '/')) | ||
.atob(safaUrlToBase64Str(str)) | ||
.split('') | ||
@@ -11,12 +12,15 @@ .map((c) => '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)) | ||
} | ||
export function base64ToArrayBuffer(str) { | ||
return new Uint8Array([...window.atob(safaUrlToBase64Str(str))].map((char) => char.charCodeAt(0))).buffer; | ||
} | ||
function base64ToSafeUrl(str) { | ||
return str.replaceAll('+', '-').replaceAll('/', '_').replaceAll('=', ''); | ||
} | ||
export function utf8ToB64(str) { | ||
return window.btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, (_, p1) => String.fromCharCode(Number(`0x${p1}`)))); | ||
return base64ToSafeUrl(window.btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, (_, p1) => String.fromCharCode(Number(`0x${p1}`))))); | ||
} | ||
// https://github.com/tc39/proposal-arraybuffer-base64 | ||
export function arrayBufferToBase64(arrayBuffer) { | ||
return window.btoa(String.fromCharCode(...new Uint8Array(arrayBuffer))); | ||
return base64ToSafeUrl(window.btoa(String.fromCharCode(...new Uint8Array(arrayBuffer)))); | ||
} | ||
export function base64ToArrayBuffer(s) { | ||
return new Uint8Array([...window.atob(s)].map((char) => char.charCodeAt(0))).buffer; | ||
} | ||
export async function hash(strOrAb, output = 'string') { | ||
@@ -23,0 +27,0 @@ const ab = typeof strOrAb === 'string' ? new TextEncoder().encode(strOrAb) : strOrAb; |
{ | ||
"name": "duoyun-ui", | ||
"version": "0.0.39", | ||
"version": "0.0.40", | ||
"description": "WebComponts UI", | ||
@@ -5,0 +5,0 @@ "exports": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1290072
20420