mirror of
https://github.com/slint-ui/slint.git
synced 2025-07-07 13:15:23 +00:00
Update to Biome 2.0 (#8730)
This commit is contained in:
parent
a7a22e11bc
commit
6d21c7b7ff
28 changed files with 296 additions and 194 deletions
|
@ -30,7 +30,7 @@ test.serial("merged event loops with networking", async (t) => {
|
|||
|
||||
await runEventLoop(() => {
|
||||
const server = http.createServer(listener);
|
||||
server.listen(async () => {
|
||||
server.listen(() => {
|
||||
const host = "localhost";
|
||||
const port = (server.address() as any).port;
|
||||
console.log(`server ready at ${host}:${port}`);
|
||||
|
|
|
@ -1,27 +1,39 @@
|
|||
{
|
||||
"extends": ["../../biome.json"],
|
||||
"formatter": {
|
||||
"ignore": ["rust-module.d.cts", "rust-module.cjs", "dist/", "docs/"]
|
||||
"root": false,
|
||||
"extends": "//",
|
||||
"files": {
|
||||
"includes": [
|
||||
"**",
|
||||
"!**/docs/",
|
||||
"!rust-module.d.cts",
|
||||
"!rust-module.cjs"
|
||||
]
|
||||
},
|
||||
"linter": {
|
||||
"ignore": ["dist/", "docs/"],
|
||||
"rules": {
|
||||
"complexity": {
|
||||
"useArrowFunction": "off",
|
||||
"noForEach": "off"
|
||||
"noForEach": "off",
|
||||
"noArguments": "off"
|
||||
},
|
||||
"style": {
|
||||
"noNonNullAssertion": "off",
|
||||
"noUnusedTemplateLiteral": "off",
|
||||
"useTemplate": "off",
|
||||
"noArguments": "off",
|
||||
"noVar": "off",
|
||||
"noInferrableTypes": "off",
|
||||
"noParameterAssign": "off"
|
||||
"noParameterAssign": "off",
|
||||
"useAsConstAssertion": "error",
|
||||
"useDefaultParameterLast": "error",
|
||||
"useEnumInitializers": "error",
|
||||
"useSelfClosingElements": "error",
|
||||
"useSingleVarDeclarator": "error",
|
||||
"useNumberNamespace": "error",
|
||||
"noUselessElse": "error"
|
||||
},
|
||||
"suspicious": {
|
||||
"noExplicitAny": "off",
|
||||
"noAssignInExpressions": "off"
|
||||
"noAssignInExpressions": "off",
|
||||
"noVar": "off"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
"description": "Slint is a declarative GUI toolkit to build native user interfaces for desktop and embedded applications.",
|
||||
"devDependencies": {
|
||||
"@ava/typescript": "5.0.0",
|
||||
"@biomejs/biome": "1.9.4",
|
||||
"@biomejs/biome": "2.0.0",
|
||||
"@types/capture-console": "1.0.5",
|
||||
"@types/node": "20.16.10",
|
||||
"ava": "6.4.0",
|
||||
|
|
30
biome.json
30
biome.json
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
|
||||
"$schema": "https://biomejs.dev/schemas/2.0.0/schema.json",
|
||||
"formatter": {
|
||||
"enabled": true,
|
||||
"formatWithErrors": false,
|
||||
|
@ -7,21 +7,26 @@
|
|||
"indentWidth": 4,
|
||||
"lineEnding": "lf",
|
||||
"attributePosition": "auto",
|
||||
"ignore": [
|
||||
"./node_modules",
|
||||
"**/.vscode/**",
|
||||
"*.json",
|
||||
"**/dist/**",
|
||||
"!biome.json",
|
||||
"editors/vscode/out/**"
|
||||
"includes": [
|
||||
"**",
|
||||
"!**/.vscode/**",
|
||||
"!**/*.json",
|
||||
"!**/dist/**",
|
||||
"!**/build/**",
|
||||
"!**/!biome.json",
|
||||
"!**/editors/vscode/out/**"
|
||||
]
|
||||
},
|
||||
"organizeImports": {
|
||||
"enabled": false
|
||||
"assist": {
|
||||
"actions": {
|
||||
"source": {
|
||||
"organizeImports": "off"
|
||||
}
|
||||
}
|
||||
},
|
||||
"linter": {
|
||||
"enabled": true,
|
||||
"ignore": ["api/node/docs/assets/**", "**/dist/**"],
|
||||
"includes": ["**", "!**/dist/**"],
|
||||
"rules": {
|
||||
"recommended": false,
|
||||
"complexity": {
|
||||
|
@ -35,6 +40,9 @@
|
|||
"useImportType": "error",
|
||||
"useNodejsImportProtocol": "error"
|
||||
},
|
||||
"nursery": {
|
||||
"noFloatingPromises": "error"
|
||||
},
|
||||
"suspicious": {
|
||||
"noDoubleEquals": "error",
|
||||
"noRedundantUseStrict": "warn",
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"main": "main.js",
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"@biomejs/biome": "1.9.4",
|
||||
"@biomejs/biome": "2.0.0",
|
||||
"slint-ui": "workspace:*"
|
||||
},
|
||||
"scripts": {
|
||||
|
|
|
@ -1,14 +1,29 @@
|
|||
{
|
||||
"extends": ["../../biome.json"],
|
||||
"formatter": {
|
||||
"ignore": ["archive/**", ".astro"]
|
||||
"root": false,
|
||||
"extends": "//",
|
||||
"files": {
|
||||
"includes": ["**", "!**/.astro/**", "**/*.astro"]
|
||||
},
|
||||
"formatter": {},
|
||||
"linter": {
|
||||
"ignore": ["archive/**", ".astro"]
|
||||
"rules": {
|
||||
"style": {
|
||||
"noParameterAssign": "error",
|
||||
"useAsConstAssertion": "error",
|
||||
"useDefaultParameterLast": "error",
|
||||
"useEnumInitializers": "error",
|
||||
"useSelfClosingElements": "error",
|
||||
"useSingleVarDeclarator": "error",
|
||||
"noUnusedTemplateLiteral": "error",
|
||||
"useNumberNamespace": "error",
|
||||
"noInferrableTypes": "error",
|
||||
"noUselessElse": "error"
|
||||
}
|
||||
}
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"include": ["*.astro"],
|
||||
"includes": ["**/*.astro"],
|
||||
"linter": {
|
||||
"rules": {
|
||||
"style": {
|
||||
|
|
|
@ -1,6 +1,18 @@
|
|||
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import linkMapData from "../../../../internal/core-macros/link-data.json" with {
|
||||
type: "json",
|
||||
};
|
||||
|
||||
type LinkMapType = {
|
||||
[K: string]: {
|
||||
href: string;
|
||||
};
|
||||
};
|
||||
|
||||
export const linkMap: Readonly<LinkMapType> = linkMapData;
|
||||
|
||||
export async function getEnumContent(enumName: string | undefined) {
|
||||
if (enumName) {
|
||||
try {
|
||||
|
@ -188,7 +200,7 @@ export function extractLines(
|
|||
.join("\n");
|
||||
}
|
||||
|
||||
export function removeLeadingSpaces(input: string, spaces: number = 4): string {
|
||||
export function removeLeadingSpaces(input: string, spaces = 4): string {
|
||||
const lines = input.split("\n");
|
||||
const modifiedLines = lines.map((line) => {
|
||||
const leadingSpaces = line.match(/^ */)?.[0].length ?? 0;
|
||||
|
@ -199,14 +211,3 @@ export function removeLeadingSpaces(input: string, spaces: number = 4): string {
|
|||
});
|
||||
return modifiedLines.join("\n");
|
||||
}
|
||||
|
||||
type LinkMapType = {
|
||||
[K: string]: {
|
||||
href: string;
|
||||
};
|
||||
};
|
||||
|
||||
import linkMapData from "../../../../internal/core-macros/link-data.json" assert {
|
||||
type: "json",
|
||||
};
|
||||
export const linkMap: Readonly<LinkMapType> = linkMapData;
|
||||
|
|
|
@ -1,9 +1,30 @@
|
|||
{
|
||||
"extends": ["../../biome.json"],
|
||||
"formatter": {
|
||||
"ignore": ["**/.vscode/**"]
|
||||
"root": false,
|
||||
"extends": "//",
|
||||
"files": {
|
||||
"includes": [
|
||||
"**",
|
||||
"!**/.vscode/**",
|
||||
"!**/webviews/**",
|
||||
"!**/.vscode/**",
|
||||
"!**/build/**",
|
||||
"!**/out/**"
|
||||
]
|
||||
},
|
||||
"linter": {
|
||||
"ignore": ["webviews/**", "**/.vscode/**", "**/build/**", "**/out/**"]
|
||||
"rules": {
|
||||
"style": {
|
||||
"noParameterAssign": "error",
|
||||
"useAsConstAssertion": "error",
|
||||
"useDefaultParameterLast": "error",
|
||||
"useEnumInitializers": "error",
|
||||
"useSelfClosingElements": "error",
|
||||
"useSingleVarDeclarator": "error",
|
||||
"noUnusedTemplateLiteral": "error",
|
||||
"useNumberNamespace": "error",
|
||||
"noInferrableTypes": "error",
|
||||
"noUselessElse": "error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -231,7 +231,7 @@
|
|||
"vscode-languageserver": "9.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "1.9.4",
|
||||
"@biomejs/biome": "2.0.0",
|
||||
"@rauschma/env-var": "1.0.1",
|
||||
"@types/fs-extra": "11.0.4",
|
||||
"@types/node": "18.11.9",
|
||||
|
|
|
@ -119,7 +119,7 @@ export function languageClientOptions(
|
|||
async provideCodeLenses(document, token, next) {
|
||||
const lenses = await next(document, token);
|
||||
if (lenses && lenses.length > 0) {
|
||||
maybeSendStartupTelemetryEvent(telemetryLogger);
|
||||
await maybeSendStartupTelemetryEvent(telemetryLogger);
|
||||
}
|
||||
return lenses;
|
||||
},
|
||||
|
@ -299,9 +299,8 @@ function helpBaseUrl(context: vscode.ExtensionContext): string {
|
|||
context.extension.packageJSON.name.endsWith("-nightly")
|
||||
) {
|
||||
return "https://snapshots.slint.dev/master/docs/slint/reference/";
|
||||
} else {
|
||||
return `https://releases.slint.dev/${context.extension.packageJSON.version}/docs/slint/reference/`;
|
||||
}
|
||||
return `https://releases.slint.dev/${context.extension.packageJSON.version}/docs/slint/reference/`;
|
||||
}
|
||||
|
||||
function getHelpUrlForElement(
|
||||
|
|
|
@ -40,7 +40,8 @@ function lspPlatform(): Platform | null {
|
|||
return {
|
||||
program_name: "Slint Live Preview.app/Contents/MacOS/slint-lsp",
|
||||
};
|
||||
} else if (process.platform === "linux") {
|
||||
}
|
||||
if (process.platform === "linux") {
|
||||
let remote_env_options = null;
|
||||
if (typeof vscode.env.remoteName !== "undefined") {
|
||||
remote_env_options = {
|
||||
|
@ -54,14 +55,16 @@ function lspPlatform(): Platform | null {
|
|||
env: remote_env_options,
|
||||
},
|
||||
};
|
||||
} else if (process.arch === "arm") {
|
||||
}
|
||||
if (process.arch === "arm") {
|
||||
return {
|
||||
program_name: "slint-lsp-armv7-unknown-linux-gnueabihf",
|
||||
options: {
|
||||
env: remote_env_options,
|
||||
},
|
||||
};
|
||||
} else if (process.arch === "arm64") {
|
||||
}
|
||||
if (process.arch === "arm64") {
|
||||
return {
|
||||
program_name: "slint-lsp-aarch64-unknown-linux-gnu",
|
||||
options: {
|
||||
|
@ -74,11 +77,10 @@ function lspPlatform(): Platform | null {
|
|||
return {
|
||||
program_name: "slint-lsp-aarch64-pc-windows-msvc.exe",
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
program_name: "slint-lsp-x86_64-pc-windows-msvc.exe",
|
||||
};
|
||||
}
|
||||
return {
|
||||
program_name: "slint-lsp-x86_64-pc-windows-msvc.exe",
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
86
pnpm-lock.yaml
generated
86
pnpm-lock.yaml
generated
|
@ -22,8 +22,8 @@ importers:
|
|||
specifier: 5.0.0
|
||||
version: 5.0.0
|
||||
'@biomejs/biome':
|
||||
specifier: 1.9.4
|
||||
version: 1.9.4
|
||||
specifier: 2.0.0
|
||||
version: 2.0.0
|
||||
'@types/capture-console':
|
||||
specifier: 1.0.5
|
||||
version: 1.0.5
|
||||
|
@ -49,8 +49,8 @@ importers:
|
|||
demos/home-automation/node:
|
||||
dependencies:
|
||||
'@biomejs/biome':
|
||||
specifier: 1.9.4
|
||||
version: 1.9.4
|
||||
specifier: 2.0.0
|
||||
version: 2.0.0
|
||||
slint-ui:
|
||||
specifier: workspace:*
|
||||
version: link:../../../api/node
|
||||
|
@ -123,8 +123,8 @@ importers:
|
|||
version: 9.0.1
|
||||
devDependencies:
|
||||
'@biomejs/biome':
|
||||
specifier: 1.9.4
|
||||
version: 1.9.4
|
||||
specifier: 2.0.0
|
||||
version: 2.0.0
|
||||
'@rauschma/env-var':
|
||||
specifier: 1.0.1
|
||||
version: 1.0.1
|
||||
|
@ -251,8 +251,8 @@ importers:
|
|||
tools/slintpad:
|
||||
devDependencies:
|
||||
'@biomejs/biome':
|
||||
specifier: 1.9.4
|
||||
version: 1.9.4
|
||||
specifier: 2.0.0
|
||||
version: 2.0.0
|
||||
'@codingame/monaco-vscode-api':
|
||||
specifier: ~8.0.4
|
||||
version: 8.0.4
|
||||
|
@ -528,55 +528,55 @@ packages:
|
|||
resolution: {integrity: sha512-ETyHEk2VHHvl9b9jZP5IHPavHYk57EhanlRRuae9XCpb/j5bDCbPPMOBfCWhnl/7EDJz0jEMCi/RhccCE8r1+Q==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
|
||||
'@biomejs/biome@1.9.4':
|
||||
resolution: {integrity: sha512-1rkd7G70+o9KkTn5KLmDYXihGoTaIGO9PIIN2ZB7UJxFrWw04CZHPYiMRjYsaDvVV7hP1dYNRLxSANLaBFGpog==}
|
||||
'@biomejs/biome@2.0.0':
|
||||
resolution: {integrity: sha512-BlUoXEOI/UQTDEj/pVfnkMo8SrZw3oOWBDrXYFT43V7HTkIUDkBRY53IC5Jx1QkZbaB+0ai1wJIfYwp9+qaJTQ==}
|
||||
engines: {node: '>=14.21.3'}
|
||||
hasBin: true
|
||||
|
||||
'@biomejs/cli-darwin-arm64@1.9.4':
|
||||
resolution: {integrity: sha512-bFBsPWrNvkdKrNCYeAp+xo2HecOGPAy9WyNyB/jKnnedgzl4W4Hb9ZMzYNbf8dMCGmUdSavlYHiR01QaYR58cw==}
|
||||
'@biomejs/cli-darwin-arm64@2.0.0':
|
||||
resolution: {integrity: sha512-QvqWYtFFhhxdf8jMAdJzXW+Frc7X8XsnHQLY+TBM1fnT1TfeV/v9vsFI5L2J7GH6qN1+QEEJ19jHibCY2Ypplw==}
|
||||
engines: {node: '>=14.21.3'}
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
|
||||
'@biomejs/cli-darwin-x64@1.9.4':
|
||||
resolution: {integrity: sha512-ngYBh/+bEedqkSevPVhLP4QfVPCpb+4BBe2p7Xs32dBgs7rh9nY2AIYUL6BgLw1JVXV8GlpKmb/hNiuIxfPfZg==}
|
||||
'@biomejs/cli-darwin-x64@2.0.0':
|
||||
resolution: {integrity: sha512-5JFhls1EfmuIH4QGFPlNpxJQFC6ic3X1ltcoLN+eSRRIPr6H/lUS1ttuD0Fj7rPgPhZqopK/jfH8UVj/1hIsQw==}
|
||||
engines: {node: '>=14.21.3'}
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
|
||||
'@biomejs/cli-linux-arm64-musl@1.9.4':
|
||||
resolution: {integrity: sha512-v665Ct9WCRjGa8+kTr0CzApU0+XXtRgwmzIf1SeKSGAv+2scAlW6JR5PMFo6FzqqZ64Po79cKODKf3/AAmECqA==}
|
||||
'@biomejs/cli-linux-arm64-musl@2.0.0':
|
||||
resolution: {integrity: sha512-Bxsz8ki8+b3PytMnS5SgrGV+mbAWwIxI3ydChb/d1rURlJTMdxTTq5LTebUnlsUWAX6OvJuFeiVq9Gjn1YbCyA==}
|
||||
engines: {node: '>=14.21.3'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
|
||||
'@biomejs/cli-linux-arm64@1.9.4':
|
||||
resolution: {integrity: sha512-fJIW0+LYujdjUgJJuwesP4EjIBl/N/TcOX3IvIHJQNsAqvV2CHIogsmA94BPG6jZATS4Hi+xv4SkBBQSt1N4/g==}
|
||||
'@biomejs/cli-linux-arm64@2.0.0':
|
||||
resolution: {integrity: sha512-BAH4QVi06TzAbVchXdJPsL0Z/P87jOfes15rI+p3EX9/EGTfIjaQ9lBVlHunxcmoptaA5y1Hdb9UYojIhmnjIw==}
|
||||
engines: {node: '>=14.21.3'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
|
||||
'@biomejs/cli-linux-x64-musl@1.9.4':
|
||||
resolution: {integrity: sha512-gEhi/jSBhZ2m6wjV530Yy8+fNqG8PAinM3oV7CyO+6c3CEh16Eizm21uHVsyVBEB6RIM8JHIl6AGYCv6Q6Q9Tg==}
|
||||
'@biomejs/cli-linux-x64-musl@2.0.0':
|
||||
resolution: {integrity: sha512-tiQ0ABxMJb9I6GlfNp0ulrTiQSFacJRJO8245FFwE3ty3bfsfxlU/miblzDIi+qNrgGsLq5wIZcVYGp4c+HXZA==}
|
||||
engines: {node: '>=14.21.3'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
|
||||
'@biomejs/cli-linux-x64@1.9.4':
|
||||
resolution: {integrity: sha512-lRCJv/Vi3Vlwmbd6K+oQ0KhLHMAysN8lXoCI7XeHlxaajk06u7G+UsFSO01NAs5iYuWKmVZjmiOzJ0OJmGsMwg==}
|
||||
'@biomejs/cli-linux-x64@2.0.0':
|
||||
resolution: {integrity: sha512-09PcOGYTtkopWRm6mZ/B6Mr6UHdkniUgIG/jLBv+2J8Z61ezRE+xQmpi3yNgUrFIAU4lPA9atg7mhvE/5Bo7Wg==}
|
||||
engines: {node: '>=14.21.3'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
|
||||
'@biomejs/cli-win32-arm64@1.9.4':
|
||||
resolution: {integrity: sha512-tlbhLk+WXZmgwoIKwHIHEBZUwxml7bRJgk0X2sPyNR3S93cdRq6XulAZRQJ17FYGGzWne0fgrXBKpl7l4M87Hg==}
|
||||
'@biomejs/cli-win32-arm64@2.0.0':
|
||||
resolution: {integrity: sha512-vrTtuGu91xNTEQ5ZcMJBZuDlqr32DWU1r14UfePIGndF//s2WUAmer4FmgoPgruo76rprk37e8S2A2c0psXdxw==}
|
||||
engines: {node: '>=14.21.3'}
|
||||
cpu: [arm64]
|
||||
os: [win32]
|
||||
|
||||
'@biomejs/cli-win32-x64@1.9.4':
|
||||
resolution: {integrity: sha512-8Y5wMhVIPaWe6jw2H+KlEm4wP/f7EW3810ZLmDlrEEy5KvBsb9ECEfu/kMWD484ijfQ8+nIi0giMgu9g1UAuuA==}
|
||||
'@biomejs/cli-win32-x64@2.0.0':
|
||||
resolution: {integrity: sha512-2USVQ0hklNsph/KIR72ZdeptyXNnQ3JdzPn3NbjI4Sna34CnxeiYAaZcZzXPDl5PYNFBivV4xmvT3Z3rTmyDBg==}
|
||||
engines: {node: '>=14.21.3'}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
@ -6100,39 +6100,39 @@ snapshots:
|
|||
'@babel/helper-string-parser': 7.27.1
|
||||
'@babel/helper-validator-identifier': 7.27.1
|
||||
|
||||
'@biomejs/biome@1.9.4':
|
||||
'@biomejs/biome@2.0.0':
|
||||
optionalDependencies:
|
||||
'@biomejs/cli-darwin-arm64': 1.9.4
|
||||
'@biomejs/cli-darwin-x64': 1.9.4
|
||||
'@biomejs/cli-linux-arm64': 1.9.4
|
||||
'@biomejs/cli-linux-arm64-musl': 1.9.4
|
||||
'@biomejs/cli-linux-x64': 1.9.4
|
||||
'@biomejs/cli-linux-x64-musl': 1.9.4
|
||||
'@biomejs/cli-win32-arm64': 1.9.4
|
||||
'@biomejs/cli-win32-x64': 1.9.4
|
||||
'@biomejs/cli-darwin-arm64': 2.0.0
|
||||
'@biomejs/cli-darwin-x64': 2.0.0
|
||||
'@biomejs/cli-linux-arm64': 2.0.0
|
||||
'@biomejs/cli-linux-arm64-musl': 2.0.0
|
||||
'@biomejs/cli-linux-x64': 2.0.0
|
||||
'@biomejs/cli-linux-x64-musl': 2.0.0
|
||||
'@biomejs/cli-win32-arm64': 2.0.0
|
||||
'@biomejs/cli-win32-x64': 2.0.0
|
||||
|
||||
'@biomejs/cli-darwin-arm64@1.9.4':
|
||||
'@biomejs/cli-darwin-arm64@2.0.0':
|
||||
optional: true
|
||||
|
||||
'@biomejs/cli-darwin-x64@1.9.4':
|
||||
'@biomejs/cli-darwin-x64@2.0.0':
|
||||
optional: true
|
||||
|
||||
'@biomejs/cli-linux-arm64-musl@1.9.4':
|
||||
'@biomejs/cli-linux-arm64-musl@2.0.0':
|
||||
optional: true
|
||||
|
||||
'@biomejs/cli-linux-arm64@1.9.4':
|
||||
'@biomejs/cli-linux-arm64@2.0.0':
|
||||
optional: true
|
||||
|
||||
'@biomejs/cli-linux-x64-musl@1.9.4':
|
||||
'@biomejs/cli-linux-x64-musl@2.0.0':
|
||||
optional: true
|
||||
|
||||
'@biomejs/cli-linux-x64@1.9.4':
|
||||
'@biomejs/cli-linux-x64@2.0.0':
|
||||
optional: true
|
||||
|
||||
'@biomejs/cli-win32-arm64@1.9.4':
|
||||
'@biomejs/cli-win32-arm64@2.0.0':
|
||||
optional: true
|
||||
|
||||
'@biomejs/cli-win32-x64@1.9.4':
|
||||
'@biomejs/cli-win32-x64@2.0.0':
|
||||
optional: true
|
||||
|
||||
'@capsizecss/unpack@2.4.0':
|
||||
|
|
|
@ -183,22 +183,26 @@ async function followChainToConcreteValue(
|
|||
b: concreteValue.b,
|
||||
a: "a" in concreteValue ? concreteValue.a : 1,
|
||||
});
|
||||
} else if (
|
||||
}
|
||||
if (
|
||||
originalVariable.resolvedType === "FLOAT" &&
|
||||
typeof concreteValue === "number"
|
||||
) {
|
||||
return `${concreteValue}px`;
|
||||
} else if (
|
||||
}
|
||||
if (
|
||||
originalVariable.resolvedType === "STRING" &&
|
||||
typeof concreteValue === "string"
|
||||
) {
|
||||
return `"${concreteValue}"`;
|
||||
} else if (
|
||||
}
|
||||
if (
|
||||
originalVariable.resolvedType === "BOOLEAN" &&
|
||||
typeof concreteValue === "boolean"
|
||||
) {
|
||||
return concreteValue ? "true" : "false";
|
||||
} else if (typeof concreteValue === "string") {
|
||||
}
|
||||
if (typeof concreteValue === "string") {
|
||||
return concreteValue;
|
||||
}
|
||||
}
|
||||
|
@ -617,7 +621,7 @@ function generateStructsAndInstances(
|
|||
function generateInstanceCode(
|
||||
instance: PropertyInstance,
|
||||
path: string[] = [],
|
||||
indent: string = " ",
|
||||
indent = " ",
|
||||
) {
|
||||
let result = "";
|
||||
const isRoot = indent === " ";
|
||||
|
@ -774,7 +778,7 @@ function generateStructsAndInstances(
|
|||
for (const field of struct.fields) {
|
||||
structsCode += ` ${field.name}: ${field.type},\n`;
|
||||
}
|
||||
structsCode += `}\n\n`;
|
||||
structsCode += "}\n\n";
|
||||
}
|
||||
|
||||
// Generate property instances
|
||||
|
@ -809,7 +813,7 @@ interface CollectionData {
|
|||
// For Figma Plugin - Export function with hierarchical structure
|
||||
// Export each collection to a separate virtual file
|
||||
export async function exportFigmaVariablesToSeparateFiles(
|
||||
exportAsSingleFile: boolean = false,
|
||||
exportAsSingleFile = false,
|
||||
): Promise<Array<{ name: string; content: string }>> {
|
||||
const exportInfo = {
|
||||
renamedVariables: new Set<string>(),
|
||||
|
@ -1326,7 +1330,7 @@ export async function exportFigmaVariablesToSeparateFiles(
|
|||
for (const mode of collectionData.modes) {
|
||||
modeEnum += ` ${mode},\n`;
|
||||
}
|
||||
modeEnum += `}\n\n`;
|
||||
modeEnum += "}\n\n";
|
||||
|
||||
// Generate Scheme Structs/Instances
|
||||
const hasRootModeVariable = variableTree.children.has("mode");
|
||||
|
@ -1360,7 +1364,7 @@ export async function exportFigmaVariablesToSeparateFiles(
|
|||
content += instances; // Add the generated instance code lines
|
||||
content += schemeInstance; // Add scheme instance code (if generated)
|
||||
content += currentSchemeInstance; // Add current instance code (if generated)
|
||||
content += `}\n`; // Close global block (removed extra \n\n)
|
||||
content += "}\n"; // Close global block (removed extra \n\n)
|
||||
|
||||
// Store the fully assembled content for this collection
|
||||
generatedFiles.push({
|
||||
|
@ -1387,28 +1391,30 @@ export async function exportFigmaVariablesToSeparateFiles(
|
|||
|
||||
// Look at surrounding context to determine appropriate replacement
|
||||
if (
|
||||
file.content.includes(`brush,\n`) &&
|
||||
file.content.includes("brush,\n") &&
|
||||
file.content.includes(reference)
|
||||
) {
|
||||
return "#808080"; // Default color
|
||||
} else if (
|
||||
file.content.includes(`length,\n`) &&
|
||||
}
|
||||
if (
|
||||
file.content.includes("length,\n") &&
|
||||
file.content.includes(reference)
|
||||
) {
|
||||
return "0px"; // Default length
|
||||
} else if (
|
||||
file.content.includes(`string,\n`) &&
|
||||
}
|
||||
if (
|
||||
file.content.includes("string,\n") &&
|
||||
file.content.includes(reference)
|
||||
) {
|
||||
return '""'; // Default string
|
||||
} else if (
|
||||
file.content.includes(`bool,\n`) &&
|
||||
}
|
||||
if (
|
||||
file.content.includes("bool,\n") &&
|
||||
file.content.includes(reference)
|
||||
) {
|
||||
return "false"; // Default boolean
|
||||
} else {
|
||||
return "#808080"; // Default fallback
|
||||
}
|
||||
return "#808080"; // Default fallback
|
||||
},
|
||||
);
|
||||
}
|
||||
|
@ -1533,7 +1539,7 @@ function generateSchemeStructs(
|
|||
for (const field of struct.fields) {
|
||||
schemeStruct += ` ${field.name}: ${field.type},\n`;
|
||||
}
|
||||
schemeStruct += `}\n\n`;
|
||||
schemeStruct += "}\n\n";
|
||||
}
|
||||
|
||||
// Main scheme struct is special - it gets top-level fields
|
||||
|
@ -1552,7 +1558,7 @@ function generateSchemeStructs(
|
|||
}
|
||||
}
|
||||
|
||||
mainSchemeStruct += `}\n\n`;
|
||||
mainSchemeStruct += "}\n\n";
|
||||
|
||||
// Generate the mode struct
|
||||
const schemeModeName = `${collectionData.formattedName}-Scheme-Mode`;
|
||||
|
@ -1562,7 +1568,7 @@ function generateSchemeStructs(
|
|||
schemeModeStruct += ` ${mode}: ${schemeName},\n`;
|
||||
}
|
||||
|
||||
schemeModeStruct += `}\n\n`;
|
||||
schemeModeStruct += "}\n\n";
|
||||
|
||||
// Generate the instance initialization
|
||||
let schemeInstance = ` out property <${schemeModeName}> mode: {\n`;
|
||||
|
@ -1574,7 +1580,7 @@ function generateSchemeStructs(
|
|||
function addHierarchicalValues(
|
||||
node: VariableNode = variableTree,
|
||||
path: string[] = [],
|
||||
currentIndent: string = " ",
|
||||
currentIndent = " ",
|
||||
) {
|
||||
for (const [childName, childNode] of node.children.entries()) {
|
||||
const currentPath = [...path, childName];
|
||||
|
@ -1604,11 +1610,11 @@ function generateSchemeStructs(
|
|||
}
|
||||
// Build the mode instance
|
||||
addHierarchicalValues();
|
||||
schemeInstance += ` },\n`;
|
||||
schemeInstance += " },\n";
|
||||
}
|
||||
|
||||
// Close the mode instance
|
||||
schemeInstance += ` };\n`;
|
||||
schemeInstance += " };\n";
|
||||
|
||||
// Generate the current scheme property with current-mode toggle
|
||||
let currentSchemeInstance = ` in-out property <${collectionData.formattedName}Mode> current-mode: ${[...collectionData.modes][0]};\n`;
|
||||
|
@ -1622,7 +1628,7 @@ function generateSchemeStructs(
|
|||
const modeArray = [...collectionData.modes];
|
||||
if (modeArray.length === 0) {
|
||||
// No modes - empty object
|
||||
currentSchemeInstance += `{};\n\n`;
|
||||
currentSchemeInstance += "{};\n\n";
|
||||
} else if (modeArray.length === 1) {
|
||||
// One mode - direct reference
|
||||
currentSchemeInstance += `root.${modePropertyName}.${modeArray[0]};\n\n`;
|
||||
|
@ -1674,7 +1680,7 @@ function collectMultiModeStructs(
|
|||
for (const mode of collectionData.modes) {
|
||||
structDef += ` ${mode}: ${slintType},\n`;
|
||||
}
|
||||
structDef += `}\n\n`;
|
||||
structDef += "}\n\n";
|
||||
|
||||
structDefinitions.push(structDef);
|
||||
}
|
||||
|
@ -1693,7 +1699,7 @@ function collectMultiModeStructs(
|
|||
for (const mode of collectionData.modes) {
|
||||
structDef += ` ${mode}: ${slintType},\n`;
|
||||
}
|
||||
structDef += `}\n\n`;
|
||||
structDef += "}\n\n";
|
||||
|
||||
structDefinitions.push(structDef);
|
||||
}
|
||||
|
|
|
@ -362,11 +362,10 @@ async function getVariablePathString(
|
|||
}
|
||||
|
||||
return resultPath;
|
||||
} else {
|
||||
console.warn(
|
||||
`[getVariablePathString] Collection not found for variable ID: ${variableId}`,
|
||||
);
|
||||
}
|
||||
console.warn(
|
||||
`[getVariablePathString] Collection not found for variable ID: ${variableId}`,
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -1102,7 +1101,7 @@ export async function generateTextSnippet(
|
|||
typeof sceneNode.textAlignHorizontal === "string"
|
||||
) {
|
||||
let slintValue: string | null = null;
|
||||
let comment: string = "";
|
||||
let comment = "";
|
||||
switch (sceneNode.textAlignHorizontal) {
|
||||
case "LEFT":
|
||||
slintValue = "left";
|
||||
|
|
|
@ -1,9 +1,23 @@
|
|||
{
|
||||
"extends": ["../../biome.json"],
|
||||
"formatter": {
|
||||
"ignore": ["figma_output.json", ".tmp"]
|
||||
"root": false,
|
||||
"extends": "//",
|
||||
"files": {
|
||||
"includes": ["**", "!**/tests/figma_output.json", "!**/.tmp"]
|
||||
},
|
||||
"linter": {
|
||||
"ignore": ["figma_output.json", ".tmp"]
|
||||
"rules": {
|
||||
"style": {
|
||||
"noParameterAssign": "error",
|
||||
"useAsConstAssertion": "error",
|
||||
"useDefaultParameterLast": "error",
|
||||
"useEnumInitializers": "error",
|
||||
"useSelfClosingElements": "error",
|
||||
"useSingleVarDeclarator": "error",
|
||||
"noUnusedTemplateLiteral": "error",
|
||||
"useNumberNamespace": "error",
|
||||
"noInferrableTypes": "error",
|
||||
"noUselessElse": "error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,8 +50,8 @@ function DialogFrame({ children }: DialogFrameProps) {
|
|||
}}
|
||||
onResize={(_e, _dir, refToElement) => {
|
||||
resizeWindow(
|
||||
parseInt(refToElement.style.width),
|
||||
parseInt(refToElement.style.height),
|
||||
Number.parseInt(refToElement.style.width),
|
||||
Number.parseInt(refToElement.style.height),
|
||||
);
|
||||
}}
|
||||
>
|
||||
|
|
|
@ -79,7 +79,7 @@ export const App = () => {
|
|||
fill-rule="evenodd"
|
||||
d="M10 6h4v1h-4zM9 6a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1 2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2m0 1a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V8a1 1 0 0 0-1-1 1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1m1 3.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5m.5 2.5a.5.5 0 0 0 0 1h3a.5.5 0 0 0 0-1z"
|
||||
clip-rule="evenodd"
|
||||
></path>
|
||||
/>
|
||||
</svg>
|
||||
<span
|
||||
style={{
|
||||
|
|
|
@ -5,8 +5,8 @@ import { dispatchTS, listenTS } from "./bolt-utils";
|
|||
import { downloadZipFile, writeTextToClipboard } from "./utils.js";
|
||||
|
||||
export enum ExportType {
|
||||
SeparateFiles,
|
||||
SingleFile,
|
||||
SeparateFiles = 0,
|
||||
SingleFile = 1,
|
||||
}
|
||||
|
||||
interface StoreState {
|
||||
|
|
|
@ -23,9 +23,8 @@ export function writeTextToClipboard(str: string): boolean {
|
|||
const successful = document.execCommand("copy");
|
||||
if (!successful) {
|
||||
throw new Error("Copy command failed");
|
||||
} else {
|
||||
copySuccessful = true;
|
||||
}
|
||||
copySuccessful = true;
|
||||
} catch (e: unknown) {
|
||||
const errorMessage = e instanceof Error ? e.message : String(e);
|
||||
console.error("Failed to copy text: " + errorMessage);
|
||||
|
|
|
@ -286,9 +286,15 @@ test("handles self-referential structs (struct members referencing each other)",
|
|||
mockCollection,
|
||||
]);
|
||||
mockFigma.variables.getVariableByIdAsync.mockImplementation((id) => {
|
||||
if (id === "var1") return Promise.resolve(mockVariable1);
|
||||
if (id === "var2") return Promise.resolve(mockVariable2);
|
||||
if (id === "var3") return Promise.resolve(mockVariable3);
|
||||
if (id === "var1") {
|
||||
return Promise.resolve(mockVariable1);
|
||||
}
|
||||
if (id === "var2") {
|
||||
return Promise.resolve(mockVariable2);
|
||||
}
|
||||
if (id === "var3") {
|
||||
return Promise.resolve(mockVariable3);
|
||||
}
|
||||
return Promise.resolve(null);
|
||||
});
|
||||
|
||||
|
@ -854,8 +860,12 @@ test("reproduces 'Missing data for mode' issue with hierarchical variables", asy
|
|||
mockCollection,
|
||||
]);
|
||||
mockFigma.variables.getVariableByIdAsync.mockImplementation((id) => {
|
||||
if (id === "var1") return Promise.resolve(mockVariable1);
|
||||
if (id === "var2") return Promise.resolve(mockVariable2);
|
||||
if (id === "var1") {
|
||||
return Promise.resolve(mockVariable1);
|
||||
}
|
||||
if (id === "var2") {
|
||||
return Promise.resolve(mockVariable2);
|
||||
}
|
||||
return Promise.resolve(null);
|
||||
});
|
||||
|
||||
|
|
|
@ -1,17 +1,31 @@
|
|||
{
|
||||
"extends": ["../../biome.json"],
|
||||
"formatter": {
|
||||
"ignore": ["dist/**", "**/playwright-report/**", "**/test-results/**"]
|
||||
"root": false,
|
||||
"extends": "//",
|
||||
"files": {
|
||||
"includes": [
|
||||
"**",
|
||||
"!**/webviews/**",
|
||||
"!**/.vscode/**",
|
||||
"!**/build/**",
|
||||
"!**/out/**",
|
||||
"!**/playwright-report/**",
|
||||
"!**/test-results/**"
|
||||
]
|
||||
},
|
||||
"linter": {
|
||||
"ignore": [
|
||||
"dist/**",
|
||||
"webviews/**",
|
||||
"**/.vscode/**",
|
||||
"**/build/**",
|
||||
"**/out/**",
|
||||
"**/playwright-report/**",
|
||||
"**/test-results/**"
|
||||
]
|
||||
"rules": {
|
||||
"style": {
|
||||
"noParameterAssign": "error",
|
||||
"useAsConstAssertion": "error",
|
||||
"useDefaultParameterLast": "error",
|
||||
"useEnumInitializers": "error",
|
||||
"useSelfClosingElements": "error",
|
||||
"useSingleVarDeclarator": "error",
|
||||
"noUnusedTemplateLiteral": "error",
|
||||
"useNumberNamespace": "error",
|
||||
"noInferrableTypes": "error",
|
||||
"noUselessElse": "error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
"keywords": [],
|
||||
"author": "",
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "1.9.4",
|
||||
"@biomejs/biome": "2.0.0",
|
||||
"@codingame/monaco-vscode-configuration-service-override": "~8.0.4",
|
||||
"@codingame/monaco-vscode-files-service-override": "~8.0.4",
|
||||
"@codingame/monaco-vscode-keybindings-service-override": "~8.0.4",
|
||||
|
|
|
@ -108,6 +108,7 @@ export function report_export_url_dialog(...urls: string[]) {
|
|||
modal_dialog("report_export_url", elements);
|
||||
}
|
||||
|
||||
// biome-ignore lint/suspicious/useAwait: <This old style of async/await is used in the codebase>
|
||||
export async function export_gist_dialog(
|
||||
exporter: (_description: string, _is_public: boolean) => void,
|
||||
) {
|
||||
|
|
|
@ -242,9 +242,8 @@ export class KnownUrlMapper implements UrlMapper {
|
|||
monaco.Uri.parse(mapped_url) ??
|
||||
monaco.Uri.parse("file:///broken_url")
|
||||
);
|
||||
} else {
|
||||
return uri;
|
||||
}
|
||||
return uri;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -325,7 +324,7 @@ class EditorPaneWidget extends Widget {
|
|||
model_ref.object.textEditorModel?.uri,
|
||||
);
|
||||
this.title.closable = false;
|
||||
this.title.caption = `Slint Code Editor`;
|
||||
this.title.caption = "Slint Code Editor";
|
||||
}
|
||||
|
||||
get editor(): monaco.editor.IStandaloneCodeEditor {
|
||||
|
@ -378,7 +377,7 @@ export class EditorWidget extends Widget {
|
|||
|
||||
this.title.label = "Editor";
|
||||
this.title.closable = false;
|
||||
this.title.caption = `Slint code editor`;
|
||||
this.title.caption = "Slint code editor";
|
||||
|
||||
this.#layout = new BoxLayout({ spacing: 0 });
|
||||
super.layout = this.#layout;
|
||||
|
@ -393,6 +392,7 @@ export class EditorWidget extends Widget {
|
|||
|
||||
this.clear_editors();
|
||||
|
||||
// biome-ignore lint/nursery/noFloatingPromises: <explanation>
|
||||
this.open_default_content();
|
||||
}
|
||||
|
||||
|
@ -414,11 +414,11 @@ export class EditorWidget extends Widget {
|
|||
code,
|
||||
),
|
||||
);
|
||||
} else if (load_url) {
|
||||
return await this.project_from_url(load_url);
|
||||
} else {
|
||||
return await this.set_demo(load_demo ?? "");
|
||||
}
|
||||
if (load_url) {
|
||||
return await this.project_from_url(load_url);
|
||||
}
|
||||
return await this.set_demo(load_demo ?? "");
|
||||
}
|
||||
|
||||
private clear_editors() {
|
||||
|
@ -609,9 +609,8 @@ export class EditorWidget extends Widget {
|
|||
return this.project_from_url(
|
||||
`https://raw.githubusercontent.com/slint-ui/slint/${tag}/${location}`,
|
||||
);
|
||||
} else {
|
||||
return Promise.resolve(this.open_hello_world());
|
||||
}
|
||||
return Promise.resolve(this.open_hello_world());
|
||||
}
|
||||
|
||||
public get open_document_urls(): string[] {
|
||||
|
|
|
@ -16,7 +16,7 @@ export function has_github_access_token(): boolean {
|
|||
return token != null && token !== "";
|
||||
}
|
||||
|
||||
export async function manage_github_access(): Promise<boolean | null> {
|
||||
export function manage_github_access(): Promise<boolean | null> {
|
||||
return new Promise((resolve, _) => {
|
||||
let result: boolean | null = null;
|
||||
|
||||
|
@ -218,30 +218,29 @@ export async function export_to_gist(
|
|||
return Promise.reject(
|
||||
"Failed to publish to Github:\n" + body.message,
|
||||
);
|
||||
} else if (body.html_url == null) {
|
||||
}
|
||||
if (body.html_url == null) {
|
||||
return Promise.reject(
|
||||
"Failed to retrieve URL after publishing to Github",
|
||||
);
|
||||
} else {
|
||||
return Promise.resolve(body.html_url);
|
||||
}
|
||||
} else {
|
||||
let extra = "";
|
||||
if (response.status === 422) {
|
||||
if (data.length > 50000) {
|
||||
extra = "\n\nYour project too big to create a Gist from.";
|
||||
} else {
|
||||
extra = "\n\nIs your project too big for a Gist?";
|
||||
}
|
||||
}
|
||||
return Promise.reject(
|
||||
"Failed to publish a Gist to Github with status code:" +
|
||||
response.status +
|
||||
"\n" +
|
||||
response.statusText +
|
||||
extra,
|
||||
);
|
||||
return Promise.resolve(body.html_url);
|
||||
}
|
||||
let extra = "";
|
||||
if (response.status === 422) {
|
||||
if (data.length > 50000) {
|
||||
extra = "\n\nYour project too big to create a Gist from.";
|
||||
} else {
|
||||
extra = "\n\nIs your project too big for a Gist?";
|
||||
}
|
||||
}
|
||||
return Promise.reject(
|
||||
"Failed to publish a Gist to Github with status code:" +
|
||||
response.status +
|
||||
"\n" +
|
||||
response.statusText +
|
||||
extra,
|
||||
);
|
||||
}
|
||||
|
||||
async function _process_gist_url(
|
||||
|
@ -344,9 +343,8 @@ function _process_github_url(url: URL): Promise<[string, null, null]> {
|
|||
null,
|
||||
null,
|
||||
]);
|
||||
} else {
|
||||
return Promise.resolve([url.toString(), null, null]);
|
||||
}
|
||||
return Promise.resolve([url.toString(), null, null]);
|
||||
}
|
||||
|
||||
export function open_url(
|
||||
|
|
|
@ -52,6 +52,7 @@ function create_settings_menu(): Menu {
|
|||
label: "Manage Github login",
|
||||
iconClass: "fa-brands fa-github",
|
||||
execute: () => {
|
||||
// biome-ignore lint/nursery/noFloatingPromises: <explanation>
|
||||
manage_github_access();
|
||||
},
|
||||
});
|
||||
|
@ -74,6 +75,7 @@ function create_project_menu(
|
|||
mnemonic: 1,
|
||||
execute: () => {
|
||||
const url = prompt("Please enter the URL to open");
|
||||
// biome-ignore lint/nursery/noFloatingPromises: <explanation>
|
||||
editor.project_from_url(url);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
||||
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
|
||||
|
||||
/** biome-ignore-all lint/nursery/noFloatingPromises: <explanation> */
|
||||
|
||||
import slint_init, * as slint from "@interpreter/slint_wasm_interpreter.js";
|
||||
|
||||
(async function () {
|
||||
|
|
|
@ -41,9 +41,10 @@ export class PreviewWidget extends Widget {
|
|||
this.addClass("content");
|
||||
this.addClass("preview");
|
||||
this.title.label = "Preview";
|
||||
this.title.caption = `Slint Viewer`;
|
||||
this.title.caption = "Slint Viewer";
|
||||
this.title.closable = true;
|
||||
|
||||
// biome-ignore lint/nursery/noFloatingPromises: <explanation>
|
||||
lsp.previewer(resource_url_mapper, style).then((p) => {
|
||||
this.#previewer = p;
|
||||
|
||||
|
@ -63,9 +64,8 @@ export class PreviewWidget extends Widget {
|
|||
public current_style(): string {
|
||||
if (this.#previewer) {
|
||||
return this.#previewer.current_style();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
protected onResize(msg: Widget.ResizeMessage): void {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue