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