11// @ts -nocheck
22/* eslint-disable */
33
4- const detectPageTechnologies = ( ruleConfig : Record < string , unknown > = { } ) => {
4+ const yieldToMainThread = ( ) => new Promise ( resolve => setTimeout ( resolve , 0 ) )
5+
6+ const detectPageTechnologies = async ( ruleConfig : Record < string , unknown > = { } ) => {
57 const technologies = [ ]
68 const ruleRegexCache = new WeakMap ( )
79 const ruleCombinedCache = new WeakMap ( )
@@ -47,14 +49,19 @@ const detectPageTechnologies = (ruleConfig: Record<string, unknown> = {}) => {
4749 ] . map ( normalizeRuleName )
4850 )
4951
52+ await yieldToMainThread ( )
5053 detectFrontendFrameworks ( add , resources , classTokens , documentHtmlSample , globalKeys , ruleConfig . frontendFrameworks || [ ] )
5154 detectUiFrameworks ( add , resources , classTokens , cssVariables , documentHtmlSample , ruleConfig . uiFrameworks || [ ] )
5255 detectAdditionalFrontendTechnologies ( add , resources , classTokens , documentHtmlSample , ruleConfig . frontendExtra || [ ] )
5356 detectMinifiedScriptFallback ( add , resources , technologies )
57+
58+ await yieldToMainThread ( )
5459 detectBuildAndRuntime ( add , resources , documentHtmlSample , globalKeys , ruleConfig . buildRuntime || [ ] )
5560 detectCdnAndHosting ( add , resources , ruleConfig . cdnProviders || [ ] )
5661 detectBackendFrameworkHints ( add , resources , documentHtmlSample , ruleConfig . backendHints || [ ] )
5762 detectCmsAndCommerce ( add , resources , documentHtmlSample , ruleConfig . websitePrograms || [ ] )
63+
64+ await yieldToMainThread ( )
5865 detectWebsitePrograms ( add , resources , documentHtmlSample , globalKeys , ruleConfig . websitePrograms || [ ] )
5966 detectCmsThemesAndSource (
6067 add ,
@@ -67,10 +74,14 @@ const detectPageTechnologies = (ruleConfig: Record<string, unknown> = {}) => {
6774 )
6875 detectProbeTools ( add , resources , documentHtmlSample , globalKeys , ruleConfig . probes || [ ] )
6976 detectProgrammingLanguages ( add , resources , documentHtmlSample , globalKeys , ruleConfig . languages || [ ] )
77+
78+ await yieldToMainThread ( )
7079 inferLanguagesFromDetectedTechnologies ( add , technologies )
7180 detectFeeds ( add , resources , documentHtmlSample , ruleConfig . feeds || [ ] )
7281 detectSaasServices ( add , resources , documentHtmlSample , globalKeys , ruleConfig . saasServices || [ ] )
7382 detectThirdPartyLogins ( add , resources , documentHtmlSample , globalKeys , ruleConfig . thirdPartyLogins || [ ] )
83+
84+ await yieldToMainThread ( )
7485 detectPaymentSystems ( add , resources , documentHtmlSample , globalKeys , ruleConfig . paymentSystems || [ ] )
7586 detectAnalytics ( add , resources , documentHtmlSample , globalKeys , ruleConfig . analyticsProviders || [ ] )
7687 detectCustomRules ( add , resources , documentHtmlSample , globalKeys , ruleConfig . customRules || [ ] )
@@ -1346,21 +1357,23 @@ ${html}`
13461357const __spRules = ( window as any ) . __SP_RULES__ ?? { }
13471358; ( window as any ) . __SP_RULES__ = undefined
13481359const __spStart = performance . now ( )
1349- const __spResult = detectPageTechnologies ( __spRules )
1350- try {
1351- if ( localStorage . getItem ( '__sp_observer_debug__' ) === '1' ) {
1352- const __spDuration = performance . now ( ) - __spStart
1353- console . log (
1354- '[StackPrism page-detector] 耗时' ,
1355- __spDuration . toFixed ( 1 ) + 'ms' ,
1356- '| 识别' ,
1357- __spResult ?. technologies ?. length || 0 ,
1358- '项 |' ,
1359- 'resources' ,
1360- __spResult ?. resources ?. total || 0
1361- )
1360+ const __spResult = detectPageTechnologies ( __spRules ) . then ( result => {
1361+ try {
1362+ if ( localStorage . getItem ( '__sp_observer_debug__' ) === '1' ) {
1363+ const __spDuration = performance . now ( ) - __spStart
1364+ console . log (
1365+ '[StackPrism page-detector] 耗时' ,
1366+ __spDuration . toFixed ( 1 ) + 'ms' ,
1367+ '| 识别' ,
1368+ result ?. technologies ?. length || 0 ,
1369+ '项 |' ,
1370+ 'resources' ,
1371+ result ?. resources ?. total || 0
1372+ )
1373+ }
1374+ } catch {
1375+ // ignore
13621376 }
1363- } catch {
1364- // ignore
1365- }
1377+ return result
1378+ } )
13661379export default __spResult
0 commit comments