-
Notifications
You must be signed in to change notification settings - Fork 279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(utils): delete the renderless/common directory and adjust all reference paths. #2849
Changes from 1 commit
00dd4c5
39901e7
6e7aacd
dba8c92
538736f
ed9307f
10f847f
97c1f84
cb2d4b7
3119781
ea19a56
63ec0f0
19c771b
338eef3
1ca41ba
5586ff3
7302c1c
ba298b5
d249b84
54e95a7
035da89
0b0c263
c6d2cc6
aaacca6
7064e5b
1baade3
6f68ab9
44b3da9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,10 @@ | ||
import { getWindow } from '../globalConfig' | ||
|
||
/** 生成字节流或字符串的sha256编码 */ | ||
export async function sha256(message: ArrayBuffer | string) { | ||
export function sha256(message: ArrayBuffer | string) { | ||
const isArrayBuffer = Object.prototype.toString.call(message) === '[object ArrayBuffer]' | ||
const msgUint8 = isArrayBuffer ? message : new TextEncoder().encode(message as string) // 编码为(utf-8)Uint8Array | ||
const hashBuffer = await getWindow().crypto.subtle.digest('SHA-256', msgUint8) // 计算消息的哈希值 | ||
const hashBuffer = globalThis.crypto.subtle.digest('SHA-256', msgUint8) // 计算消息的哈希值 | ||
const hashArray = Array.from(new Uint8Array(hashBuffer)) // 将缓冲区转换为字节数组 | ||
const hashHex = hashArray.map((b) => b.toString(16).padStart(2, '0')).join('') // 将字节数组转换为十六进制字符串 | ||
|
||
return hashHex | ||
} | ||
|
||
export default { sha256 } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
import xss from './xss' | ||
import logger from './logger' | ||
import crypt from './crypt' | ||
import ResizeObserver from './resize-observer' | ||
|
||
export { xss, logger, crypt, ResizeObserver } | ||
export { xss, logger, ResizeObserver } | ||
|
||
export { sha256 } from './crypt' | ||
export { globalConfig, getViewportWindow } from './globalConfig' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Breaking change detected in mobile utils The export reorganization is properly implemented, but there's one breaking change that needs to be addressed:
🔗 Analysis chainExport reorganization looks good but needs documentation. The reorganization of exports and separation of 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Check for potential breaking changes impact
# Search for direct imports of the removed crypt module
echo "Checking for imports of the removed crypt module..."
rg "import.*from ['\"]@opentiny/vue-utils/crypt['\"]" || echo "No direct crypt imports found"
# Search for destructured imports of getWindow and isWeb
echo -e "\nChecking for imports of removed getWindow and isWeb utilities..."
rg "import.*\{.*(getWindow|isWeb).*\}.*from ['\"]@opentiny/vue-utils['\"]" || echo "No getWindow/isWeb imports found"
Length of output: 542 Script: #!/bin/bash
# Check for TypeScript references and indirect usages
# Check for type references
echo "Checking for TypeScript type references..."
rg "import type.*\{.*(getWindow|isWeb).*\}.*from ['\"]@opentiny/vue-utils['\"]" || echo "No type references found"
# Check implementation of new exports
echo -e "\nVerifying new exports implementation..."
ast-grep --pattern 'export { sha256 } from "./crypt"'
ast-grep --pattern 'export { globalConfig, getViewportWindow } from "./globalConfig"'
# Check for any references to these functions in the codebase
echo -e "\nChecking for any function references..."
rg "getWindow\s*\(" || echo "No getWindow function calls found"
rg "isWeb\s*\(" || echo "No isWeb function calls found"
Length of output: 753 Script: #!/bin/bash
# Verify the actual implementation files
echo "Checking crypt.ts content..."
fd -e ts crypt.ts --exec cat {}
echo -e "\nChecking globalConfig.ts content..."
fd -e ts globalConfig.ts --exec cat {}
echo -e "\nChecking if getViewportWindow is the replacement for getWindow..."
rg "getViewportWindow" -A 3
Length of output: 3041 |
||
|
||
export { getWindow, isWeb, globalConfig, getViewportWindow } from './globalConfig' | ||
export { getDays, getWeek, lastMonth, nextMonth, getCalendar, transformArray, parseDate } from './calendar' | ||
|
||
export { | ||
isLeapYear, | ||
toDate, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removal of
await
from thesha256
function suggests thatcrypto.subtle.digest
is now expected to be synchronous, which is incorrect.crypto.subtle.digest
returns a Promise, so the function should remain asynchronous, andawait
should be used here.