Skip to content

Commit bcd764d

Browse files
committed
style: change linter settings & change copyright to SPDX
1 parent 0f7cb1a commit bcd764d

11 files changed

+6942
-7094
lines changed

PlatformAutoGen.d.ts

+6,023-5,978
Large diffs are not rendered by default.

biome.json

+25-38
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,27 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/1.7.3/schema.json",
3-
"vcs": {
4-
"enabled": true,
5-
"clientKind": "git",
6-
"useIgnoreFile": true
7-
},
8-
"linter": {
9-
"enabled": true,
10-
"rules": {
11-
"recommended": true,
12-
"suspicious": {
13-
"noExplicitAny": "off"
14-
},
15-
"security": {
16-
"noDangerouslySetInnerHtml": "off"
17-
},
18-
"style": {
19-
"noParameterAssign": "off",
20-
"noNonNullAssertion": "off"
21-
}
22-
}
23-
},
24-
"formatter": {
25-
"enabled": true,
26-
"formatWithErrors": true,
27-
"indentStyle": "space",
28-
"indentWidth": 3,
29-
"lineWidth": 112
30-
},
31-
"organizeImports": {
32-
"enabled": true
33-
},
34-
"javascript": {
35-
"formatter": {
36-
"arrowParentheses": "asNeeded",
37-
"trailingComma": "all"
38-
}
39-
}
2+
"$schema": "https://biomejs.dev/schemas/1.7.3/schema.json",
3+
"vcs": {
4+
"enabled": true,
5+
"clientKind": "git",
6+
"useIgnoreFile": true
7+
},
8+
"linter": {
9+
"enabled": false
10+
},
11+
"formatter": {
12+
"enabled": true,
13+
"formatWithErrors": true,
14+
"indentStyle": "tab",
15+
"indentWidth": 2,
16+
"lineWidth": 100
17+
},
18+
"organizeImports": {
19+
"enabled": true
20+
},
21+
"javascript": {
22+
"formatter": {
23+
"arrowParentheses": "asNeeded",
24+
"trailingComma": "all"
25+
}
26+
}
4027
}

index.ts

+8-20
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,17 @@
1-
/* Copyright © 2024
2-
* Delusoire <[email protected]>
3-
*
4-
* This file is part of bespoke/hooks.
5-
*
6-
* bespoke/hooks is free software: you can redistribute it and/or modify
7-
* it under the terms of the GNU General Public License as published by
8-
* the Free Software Foundation, either version 3 of the License, or
9-
* (at your option) any later version.
10-
*
11-
* bespoke/hooks is distributed in the hope that it will be useful,
12-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14-
* GNU General Public License for more details.
15-
*
16-
* You should have received a copy of the GNU General Public License
17-
* along with bespoke/hooks. If not, see <https://www.gnu.org/licenses/>.
1+
/*
2+
* Copyright (C) 2024 Delusoire
3+
* SPDX-License-Identifier: GPL-3.0-or-later
184
*/
195

206
import mixin, { applyTransforms } from "./mixins.js";
217
import { MixinLoader, Module } from "./module.js";
228

23-
await mixin( MixinLoader.INTERNAL.transformer );
9+
await mixin(MixinLoader.INTERNAL.transformer);
2410
await Module.enableAllLoadableMixins();
2511

26-
await Promise.all( [ "/vendor~xpui.js", "/xpui.js" ].map( applyTransforms ).map( async p => import( await p ) ) );
12+
await Promise.all(
13+
["/vendor~xpui.js", "/xpui.js"].map(applyTransforms).map(async p => import(await p)),
14+
);
2715

28-
await Promise.all( MixinLoader.INTERNAL.awaitedMixins );
16+
await Promise.all(MixinLoader.INTERNAL.awaitedMixins);
2917
await Module.enableAllLoadable();

mixins.ts

+86-97
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
1-
/* Copyright © 2024
2-
* Delusoire <[email protected]>
3-
*
4-
* This file is part of bespoke/hooks.
5-
*
6-
* bespoke/hooks is free software: you can redistribute it and/or modify
7-
* it under the terms of the GNU General Public License as published by
8-
* the Free Software Foundation, either version 3 of the License, or
9-
* (at your option) any later version.
10-
*
11-
* bespoke/hooks is distributed in the hope that it will be useful,
12-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14-
* GNU General Public License for more details.
15-
*
16-
* You should have received a copy of the GNU General Public License
17-
* along with bespoke/hooks. If not, see <https://www.gnu.org/licenses/>.
1+
/*
2+
* Copyright (C) 2024 Delusoire
3+
* SPDX-License-Identifier: GPL-3.0-or-later
184
*/
195

206
import { nsUrlHandlers } from "./protocol.js";
@@ -23,100 +9,103 @@ import { sources, type Transformer } from "./transform.js";
239
import { matchLast } from "./util.js";
2410

2511
declare global {
26-
var __applyTransforms: typeof applyTransforms;
27-
var __interceptNavigationControlMessage: typeof interceptNavigationControlMessage;
12+
var __applyTransforms: typeof applyTransforms;
13+
var __interceptNavigationControlMessage: typeof interceptNavigationControlMessage;
2814
}
2915

30-
export const applyTransforms = ( path: string ) => {
31-
const i = Paths.indexOf( path as any );
32-
const source = sources[ i ];
33-
console.info( "loadResource", { path, source } );
34-
if ( !source ) return path;
35-
return source.getObjectURL();
16+
export const applyTransforms = (path: string) => {
17+
const i = Paths.indexOf(path as any);
18+
const source = sources[i];
19+
console.info("loadResource", { path, source });
20+
if (!source) return path;
21+
return source.getObjectURL();
3622
};
3723

3824
globalThis.__applyTransforms = applyTransforms;
3925

4026
const rpc = "spotify:app:rpc:";
41-
function interceptNavigationControlMessage( e: Event ): boolean {
42-
const uri: string = ( e as any ).data.data;
43-
if ( !uri.startsWith( rpc ) ) {
44-
return true;
45-
}
46-
const trimmedUri = uri.slice( rpc.length );
47-
if ( trimmedUri === "reload" ) {
48-
document.location.reload();
49-
}
50-
{
51-
const hash = trimmedUri.slice( 0, 47 );
52-
nsUrlHandlers.get( hash )?.( trimmedUri );
53-
}
54-
return false;
27+
function interceptNavigationControlMessage(e: Event): boolean {
28+
const uri: string = (e as any).data.data;
29+
if (!uri.startsWith(rpc)) {
30+
return true;
31+
}
32+
const trimmedUri = uri.slice(rpc.length);
33+
if (trimmedUri === "reload") {
34+
document.location.reload();
35+
}
36+
{
37+
const hash = trimmedUri.slice(0, 47);
38+
nsUrlHandlers.get(hash)?.(trimmedUri);
39+
}
40+
return false;
5541
}
5642

5743
globalThis.__interceptNavigationControlMessage = interceptNavigationControlMessage;
5844

59-
export default async function ( transformer: Transformer ) {
60-
transformer(
61-
emit => str => {
62-
str = str.replace(
63-
/(([a-zA-Z_\$][\w\$]*)=([a-zA-Z_\$][\w\$]*)\.p\+\3\.u\([a-zA-Z_\$][\w\$]*\))/,
64-
"$1,$2=await __applyTransforms($2)",
65-
);
66-
const i = str.search( '"Loading chunk "' );
67-
const { index } = matchLast( str.slice( 0, i ), /=\([a-zA-Z_\$][\w\$]*,[a-zA-Z_\$][\w\$]*\)=>\{/g );
68-
str = `${ str.slice( 0, index! + 1 ) }async${ str.slice( index! + 1 ) }`;
45+
export default async function (transformer: Transformer) {
46+
transformer(
47+
emit => str => {
48+
str = str.replace(
49+
/(([a-zA-Z_\$][\w\$]*)=([a-zA-Z_\$][\w\$]*)\.p\+\3\.u\([a-zA-Z_\$][\w\$]*\))/,
50+
"$1,$2=await __applyTransforms($2)",
51+
);
52+
const i = str.search('"Loading chunk "');
53+
const { index } = matchLast(
54+
str.slice(0, i),
55+
/=\([a-zA-Z_\$][\w\$]*,[a-zA-Z_\$][\w\$]*\)=>\{/g,
56+
);
57+
str = `${str.slice(0, index! + 1)}async${str.slice(index! + 1)}`;
6958

70-
str = str.replace(
71-
/(new Promise\(\()(\([a-zA-Z_\$][\w\$]*,[a-zA-Z_\$][\w\$]*\)=>\{var ([a-zA-Z_\$][\w\$]*)=([a-zA-Z_\$][\w\$]*)\.miniCssF\([a-zA-Z_\$][\w\$]*\),([a-zA-Z_\$][\w\$]*)=\4\.p\+\3)/,
72-
"$1async$2,$5=await __applyTransforms($5)",
73-
);
59+
str = str.replace(
60+
/(new Promise\(\()(\([a-zA-Z_\$][\w\$]*,[a-zA-Z_\$][\w\$]*\)=>\{var ([a-zA-Z_\$][\w\$]*)=([a-zA-Z_\$][\w\$]*)\.miniCssF\([a-zA-Z_\$][\w\$]*\),([a-zA-Z_\$][\w\$]*)=\4\.p\+\3)/,
61+
"$1async$2,$5=await __applyTransforms($5)",
62+
);
7463

75-
emit();
76-
return str;
77-
},
78-
{
79-
glob: /^\/xpui\.js/,
80-
},
81-
);
64+
emit();
65+
return str;
66+
},
67+
{
68+
glob: /^\/xpui\.js/,
69+
},
70+
);
8271

83-
transformer(
84-
emit => str => {
85-
str = str.replace( /(\("[^"]+sentry.io)/, ",$1" );
86-
emit();
87-
return str;
88-
},
89-
{
90-
glob: /^\/xpui\.js/,
91-
},
92-
);
72+
transformer(
73+
emit => str => {
74+
str = str.replace(/(\("[^"]+sentry.io)/, ",$1");
75+
emit();
76+
return str;
77+
},
78+
{
79+
glob: /^\/xpui\.js/,
80+
},
81+
);
9382

94-
transformer(
95-
emit => str => {
96-
str = str.replace( /("incognito-enabled":[a-zA-Z_\$][\w\$]*)/, '$1,employee:"1"' );
97-
str = str.replace(
98-
/([a-zA-Z_\$][\w\$]*)\("app\.enable-developer-mode",([a-zA-Z_\$][\w\$]*)\)/,
99-
'$1("app.enable-developer-mode",$2);$1("app-developer",$2?2:0)',
100-
);
101-
emit();
102-
return str;
103-
},
104-
{
105-
glob: /^\/xpui\.js/,
106-
},
107-
);
83+
transformer(
84+
emit => str => {
85+
str = str.replace(/("incognito-enabled":[a-zA-Z_\$][\w\$]*)/, '$1,employee:"1"');
86+
str = str.replace(
87+
/([a-zA-Z_\$][\w\$]*)\("app\.enable-developer-mode",([a-zA-Z_\$][\w\$]*)\)/,
88+
'$1("app.enable-developer-mode",$2);$1("app-developer",$2?2:0)',
89+
);
90+
emit();
91+
return str;
92+
},
93+
{
94+
glob: /^\/xpui\.js/,
95+
},
96+
);
10897

109-
transformer(
110-
emit => str => {
111-
str = str.replace(
112-
/(([a-zA-Z_\$][\w\$]*)\.data\.type===(?:[a-zA-Z_\$][\w\$]*\.){2}NAVIGATION&&)/,
113-
"$1__interceptNavigationControlMessage($2)&&",
114-
);
115-
emit();
116-
return str;
117-
},
118-
{
119-
glob: /^\/xpui\.js/,
120-
},
121-
);
98+
transformer(
99+
emit => str => {
100+
str = str.replace(
101+
/(([a-zA-Z_\$][\w\$]*)\.data\.type===(?:[a-zA-Z_\$][\w\$]*\.){2}NAVIGATION&&)/,
102+
"$1__interceptNavigationControlMessage($2)&&",
103+
);
104+
emit();
105+
return str;
106+
},
107+
{
108+
glob: /^\/xpui\.js/,
109+
},
110+
);
122111
}

0 commit comments

Comments
 (0)