From e33a295faf29c5518d0b34a2e9f8a8fe60542f70 Mon Sep 17 00:00:00 2001 From: jardicc <13526959+jardicc@users.noreply.github.com> Date: Sun, 21 Apr 2024 19:12:17 +0200 Subject: [PATCH 01/12] Bump version to 1.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 344de72..b1c9b19 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "uxpvalidator", "displayName": "Validator for UXP", "description": "Validates CSS, LESS & SCSS for UXP. Intellisense and validation for Manifest.json. Please report any issues on GitHub or rate plugin", - "version": "1.0.0", + "version": "1.1.0", "author": "Jaroslav Bereza", "publisher": "JaroslavBereza", "license": "MIT", From 048025c481b19afd20d7fbb597430d2cbd13d9fd Mon Sep 17 00:00:00 2001 From: jardicc <13526959+jardicc@users.noreply.github.com> Date: Sat, 12 Oct 2024 14:36:20 +0200 Subject: [PATCH 02/12] Updates version table --- common/versionTable.ts | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/common/versionTable.ts b/common/versionTable.ts index 95a5f80..c40ed10 100644 --- a/common/versionTable.ts +++ b/common/versionTable.ts @@ -2,7 +2,8 @@ import {THostApp} from "./types"; export const versionTable:TVersionTable = { PS: { - "25.5.0": {uxp: "7.4.0", date: new Date("Feb 2024")}, // February 2024 (version 25.5) release + "26.0.0": {uxp: "8.0.1", date: new Date("Oct 2024")}, // + "25.5.0": {uxp: "7.4.0", date: new Date("Feb 2024")}, // "25.2.0": {uxp: "7.3.0", date: new Date("Now 2023")}, // check the date "25.0.0": {uxp: "7.2.0", date: new Date("Sep 2023")}, "24.6.0": {uxp: "7.1.0", date: new Date("Apr 2023")}, // June 2023 (version 24.6) release @@ -34,6 +35,7 @@ export const versionTable:TVersionTable = { */ }, ID: { + "20.0.0": {uxp: "8.0.1", date: new Date("Oct 2024")}, "19.0.0": {uxp: "7.3.1", date: new Date("Sep 2023")}, "18.5.0": {uxp: "7.1.0", date: new Date("Jun 2023")}, }, @@ -60,11 +62,26 @@ export const versionTable:TVersionTable = { }; +// See https://compat-table.github.io/compat-table/es2016plus/ for overview of ES features + export const v8Versions:IV8Versions = { + "8.0.1": { + v8: "12.2.0.0", // ! only best guess. I can't find the exact version anywhere. Could be higher. + es: "2024", + extraFeatures: [ + "ES2025 - Iterator Helpers", // works + ], + missingFeatures: [ + "ES2025 - Duplicate named capturing groups", + "ES2025 - Set methods", + "ES2025 - RegExp Pattern Modifiers", + // not about Unicode and Regexp + ], + }, // Oct 27 2021 "6.0.0": { v8: "9.4.146.24", es: "2022", - notes: [ + missingFeatures: [ "ES2018 - RegExp Unicode 15 Property Escapes", "ES2018 - RegExp Unicode 15.1 Property Escapes", "ES2022 - RegExp Match Indices (`hasIndices` / `d` flag) > shows up in flags", @@ -74,7 +91,7 @@ export const v8Versions:IV8Versions = { "5.1.0": { v8: "8.9.255.20", es: "2021", - notes: [ + missingFeatures: [ "ES2018 - RegExp Unicode 14 Property Escapes", "ES2018 - RegExp Unicode 15 Property Escapes", "ES2018 - RegExp Unicode 15.1 Property Escapes", @@ -85,7 +102,7 @@ export const v8Versions:IV8Versions = { "5.0.0": { v8: "8.8.278.14", es: "2021", - notes: [ + missingFeatures: [ "ES2018 - RegExp Unicode 14 Property Escapes", "ES2018 - RegExp Unicode 15 Property Escapes", "ES2018 - RegExp Unicode 15.1 Property Escapes", @@ -96,7 +113,7 @@ export const v8Versions:IV8Versions = { "4.3.0": { v8: "8.3.110.13", es: "2020", - notes: [ + missingFeatures: [ "ES2018 - RegExp Unicode 14 Property Escapes", "ES2018 - RegExp Unicode 15 Property Escapes", "ES2018 - RegExp Unicode 15.1 Property Escapes", @@ -124,7 +141,8 @@ export interface IV8Item{ uxp?: string es: string v8: string - notes?: string[] + missingFeatures?: string[] + extraFeatures?: string[] } /* From 3fc45bb4d769ff36c2f5c9edaac470ea6fcdb2dd Mon Sep 17 00:00:00 2001 From: jardicc <13526959+jardicc@users.noreply.github.com> Date: Sat, 12 Oct 2024 14:36:36 +0200 Subject: [PATCH 03/12] Updates schema --- .../manifestValidation/Schemas/V5Schema.ts | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/server/src/manifestValidation/Schemas/V5Schema.ts b/server/src/manifestValidation/Schemas/V5Schema.ts index 0493b4a..717e9ca 100644 --- a/server/src/manifestValidation/Schemas/V5Schema.ts +++ b/server/src/manifestValidation/Schemas/V5Schema.ts @@ -438,7 +438,29 @@ export const V5Schema: JSONSchema = { "enableFillAsCustomAttribute": { "type": "boolean", "default": true, - "markdownDescription": "Added in UXP 7.1.0 - SVGElement: The color of the fill attribute using a CSS variable will resolve as per the variable value. For now, please test this fix by enabling the feature flag in your plugin manifest. This flag will be turned on by default in the next UXP release.", + "markdownDescription": "Added in UXP 7.1.0 - SVGElement: The color of the fill attribute using a CSS variable will resolve as per the variable value. For now, please test this fix by enabling the feature flag in your plugin manifest. This flag will be turned on by default in the next UXP release. \n\n Turned on by default in `UXP 8.0.1`", + }, + "CSSNextSupport": { + + "oneOf": [ + { + "type": "boolean", + "default": true, + }, + { + "type": "array", + "default": ["boxShadow", "transformFunctions", "transformProperties"], + "items": { + "type": "string", + "enum": [ + "boxShadow", + "transformFunctions", + "transformProperties", + ], + }, + }, + ], + "markdownDescription": "Enables new CSS features. \n\n Supported since UXP 8.0.1 \n\n If `enableSWCSupport` is `true`, then this flag is enabled by default.", }, }, "markdownDescription": "A set of feature flags that can be used to enable or disable certain features of the plugin. These flags are used to gate features that are not yet ready for general availability.", @@ -551,6 +573,9 @@ export const V5Schema: JSONSchema = { "unevaluatedProperties": false, }, "webview": { + "required": [ + "domains","allow", + ], "properties": { "domains": { "oneOf": [ @@ -571,8 +596,8 @@ export const V5Schema: JSONSchema = { "markdownDescription": "Enables webview access to the plugin.", }, "allowLocalRendering": { - "type": "string", - "markdownDescription": "If webview is specified, this indicates that the webview can render local content.", + "const": "yes", + "markdownDescription": "If webview is specified, this indicates that the webview can render local content. \n\n Supported since UXP 8.0.1", }, "enableMessageBridge": { "enum": [ @@ -582,7 +607,7 @@ export const V5Schema: JSONSchema = { ], "markdownEnumDescriptions": [ "Enables WebView & the content loaded on WebView to communicate via postMessage regardless of where the content is loaded from locally or remotely.", - "Enables WebView & the content loaded on WebView to communicate via postMessage only if the content on WebView is loaded locally", + "Enables WebView & the content loaded on WebView to communicate via postMessage only if the content on WebView is loaded locally \n\n Supported since UXP 8.0.1", "Not allow WebView & the content loaded on WebView to communicate via postMessage", ], "markdownDescription": "Enables WebView & the content loaded on WebView to communicate via postMessage. \n\n API: `HTMLWebViewElement.postMessage` and `window.uxpHost.postMessage`", From cb5588f2f7aabf1aff13425a8e08b0cadf163815 Mon Sep 17 00:00:00 2001 From: jardicc <13526959+jardicc@users.noreply.github.com> Date: Sat, 12 Oct 2024 14:40:21 +0200 Subject: [PATCH 04/12] Adds new warning --- server/src/manifestValidation/jsonQuirksDetector.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/server/src/manifestValidation/jsonQuirksDetector.ts b/server/src/manifestValidation/jsonQuirksDetector.ts index b25357f..501c69b 100644 --- a/server/src/manifestValidation/jsonQuirksDetector.ts +++ b/server/src/manifestValidation/jsonQuirksDetector.ts @@ -147,6 +147,17 @@ export function handleFlags(node: json.ASTNode, textDocument: json.TextDocument, addProblem(node, `enableAlerts is not supported in UXP version ${uxpVersion}. UXP version should be >=7.0.0`, json.DiagnosticSeverity.Error, diagnostic, textDocument); } } + if (node.type === "property" && node.keyNode.value === "enableFillAsCustomAttribute" && node.valueNode?.value === true) { + const uxpVersion = LSPServer.validator.versionMatcher?.commonUXP?.uxp; + + if (!uxpVersion) { + return; + } + + if (satisfies(uxpVersion, ">=8.0.1")) { + addProblem(node, `enableFillAsCustomAttribute is turned on by default since UXP version 8.0.1. You target minimal UXP version ${uxpVersion}.`, json.DiagnosticSeverity.Warning, diagnostic, textDocument); + } + } } export function handlePermissions(node: json.ASTNode, textDocument: json.TextDocument, diagnostic: json.Diagnostic[]): void { From 3c34eda3a0a4b1c69d787865604ccf22cabca290 Mon Sep 17 00:00:00 2001 From: jardicc <13526959+jardicc@users.noreply.github.com> Date: Sat, 12 Oct 2024 14:42:18 +0200 Subject: [PATCH 05/12] Tracking and adding LFS artifacts --- .gitattributes | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitattributes b/.gitattributes index b63d807..eab3d69 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,4 @@ /media/**/* filter=lfs diff=lfs merge=lfs -text +*.jpg filter=lfs diff=lfs merge=lfs -text +*.psd filter=lfs diff=lfs merge=lfs -text +*.jpeg filter=lfs diff=lfs merge=lfs -text From 4ba6505dc7be1232a31edaf87e752e2541d81539 Mon Sep 17 00:00:00 2001 From: jardicc <13526959+jardicc@users.noreply.github.com> Date: Sat, 12 Oct 2024 14:44:15 +0200 Subject: [PATCH 06/12] Adds icon --- icon-2.psd | 3 +++ icon.jpeg | 3 +++ icon.psd | 3 +++ 3 files changed, 9 insertions(+) create mode 100644 icon-2.psd create mode 100644 icon.jpeg create mode 100644 icon.psd diff --git a/icon-2.psd b/icon-2.psd new file mode 100644 index 0000000..1ca9b9c --- /dev/null +++ b/icon-2.psd @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1640a1d96e7333c0c3fff6d86e1beac4a86b1b7427f47f827008508c2a402e16 +size 3590032 diff --git a/icon.jpeg b/icon.jpeg new file mode 100644 index 0000000..0391a95 --- /dev/null +++ b/icon.jpeg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7ff23aabfc3c2283aaba7ab000186d6fe4d3da42f67708442e993ebf6ff46d56 +size 84397 diff --git a/icon.psd b/icon.psd new file mode 100644 index 0000000..51625d7 --- /dev/null +++ b/icon.psd @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d433f7f1e175d1206ed1cd84d8693aae2c15421ac5f2079fd6bddf2c5755ef8d +size 7948844 From b6f6f7f0ce367a91d6f02f89bc351abae5007670 Mon Sep 17 00:00:00 2001 From: jardicc <13526959+jardicc@users.noreply.github.com> Date: Sat, 12 Oct 2024 15:41:45 +0200 Subject: [PATCH 07/12] Adds more specific manifest rules --- .../manifestValidation/jsonQuirksDetector.ts | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/server/src/manifestValidation/jsonQuirksDetector.ts b/server/src/manifestValidation/jsonQuirksDetector.ts index 501c69b..b846388 100644 --- a/server/src/manifestValidation/jsonQuirksDetector.ts +++ b/server/src/manifestValidation/jsonQuirksDetector.ts @@ -103,6 +103,14 @@ export function handlePSApiVersion(node: json.ASTNode, textDocument: json.TextDo } export function handleFlags(node: json.ASTNode, textDocument: json.TextDocument, diagnostic: json.Diagnostic[]): void { + + // If we are not directly in the featureFlags object, return (nested featureFlags are not supported) + const nodePath = getNodePath(node); + if (!nodePath.includes("featureFlags")) { + return; + } + + /* enableSWCSupport 7.0 */ @@ -126,6 +134,7 @@ export function handleFlags(node: json.ASTNode, textDocument: json.TextDocument, addProblem(node, `enableSWCSupport is not supported in UXP version ${uxpVersion}. UXP version should be >=7.0.0`, json.DiagnosticSeverity.Error, diagnostic, textDocument); } } + // Enable alerts if (node.type === "property" && node.keyNode.value === "enableAlerts" && node.valueNode?.value === true) { const uxpVersion = LSPServer.validator.versionMatcher?.commonUXP?.uxp; const PSversion = LSPServer.validator.versionMatcher?.detectedVersions?.PS; @@ -147,6 +156,7 @@ export function handleFlags(node: json.ASTNode, textDocument: json.TextDocument, addProblem(node, `enableAlerts is not supported in UXP version ${uxpVersion}. UXP version should be >=7.0.0`, json.DiagnosticSeverity.Error, diagnostic, textDocument); } } + // Enable fill as custom attribute if (node.type === "property" && node.keyNode.value === "enableFillAsCustomAttribute" && node.valueNode?.value === true) { const uxpVersion = LSPServer.validator.versionMatcher?.commonUXP?.uxp; @@ -155,9 +165,17 @@ export function handleFlags(node: json.ASTNode, textDocument: json.TextDocument, } if (satisfies(uxpVersion, ">=8.0.1")) { - addProblem(node, `enableFillAsCustomAttribute is turned on by default since UXP version 8.0.1. You target minimal UXP version ${uxpVersion}.`, json.DiagnosticSeverity.Warning, diagnostic, textDocument); + addProblem(node, `You don't need this. \`enableFillAsCustomAttribute\` is turned on by default since UXP version 8.0.1. You target minimal UXP version ${uxpVersion}.`, json.DiagnosticSeverity.Warning, diagnostic, textDocument); } } + // Enable SWC support overrides CSS Next Support + if (node.type === "property" && node.keyNode.value === "CSSNextSupport") { + node.parent?.children?.find((child) => { + if (child.type === "property" && child.keyNode.value === "enableSWCSupport" && child.valueNode?.value === true) { + addProblem(node, `\`CSSNextSupport\` is always enabled when \`enableSWCSupport\` is enabled.`, json.DiagnosticSeverity.Error, diagnostic, textDocument); + } + }); + } } export function handlePermissions(node: json.ASTNode, textDocument: json.TextDocument, diagnostic: json.Diagnostic[]): void { @@ -201,7 +219,28 @@ export function handlePermissions(node: json.ASTNode, textDocument: json.TextDoc addProblem(node, `enableAddon is not supported in UXP version ${psVersion}. UXP version should be >=24.2.0`, json.DiagnosticSeverity.Error, diagnostic, textDocument); } } + if (node.type === "property" && node.keyNode.value === "allowLocalRendering") { + const uxpVersion = LSPServer.validator.versionMatcher?.commonUXP?.uxp; + + if (!uxpVersion) { + return; + } + if (satisfies(uxpVersion, "<8.0.1")) { + addProblem(node, `allowLocalRendering is not supported in UXP version ${uxpVersion}. UXP version should be >=8.0.1`, json.DiagnosticSeverity.Error, diagnostic, textDocument); + } + } + if (node.type === "property" && node.keyNode.value === "enableMessageBridge" && node.valueNode?.value === "localOnly") { + const uxpVersion = LSPServer.validator.versionMatcher?.commonUXP?.uxp; + + if (!uxpVersion) { + return; + } + + if (satisfies(uxpVersion, "<8.0.1")) { + addProblem(node, `"localOnly" value is not supported in UXP version ${uxpVersion}. UXP version should be >=8.0.1`, json.DiagnosticSeverity.Error, diagnostic, textDocument); + } + } } export function handleManifestVersion(node: json.ASTNode, textDocument: json.TextDocument, diagnostic: json.Diagnostic[]): void { From 149963866f504cee496f85dcfb470174a1d54f8e Mon Sep 17 00:00:00 2001 From: jardicc <13526959+jardicc@users.noreply.github.com> Date: Sat, 19 Oct 2024 17:43:04 +0200 Subject: [PATCH 08/12] Sets correct V8 version --- common/versionTable.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/versionTable.ts b/common/versionTable.ts index c40ed10..95600d0 100644 --- a/common/versionTable.ts +++ b/common/versionTable.ts @@ -66,7 +66,7 @@ export const versionTable:TVersionTable = { export const v8Versions:IV8Versions = { "8.0.1": { - v8: "12.2.0.0", // ! only best guess. I can't find the exact version anywhere. Could be higher. + v8: "11.8.172.13", es: "2024", extraFeatures: [ "ES2025 - Iterator Helpers", // works From 809d38b946bd6e7c453b2e9c7272061b8636b268 Mon Sep 17 00:00:00 2001 From: jardicc <13526959+jardicc@users.noreply.github.com> Date: Sat, 19 Oct 2024 19:18:58 +0200 Subject: [PATCH 09/12] Adds rule CSSNextSupport cannot be an array if enableSWCSupport is enabled --- server/src/manifestValidation/jsonQuirksDetector.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/src/manifestValidation/jsonQuirksDetector.ts b/server/src/manifestValidation/jsonQuirksDetector.ts index b846388..048441c 100644 --- a/server/src/manifestValidation/jsonQuirksDetector.ts +++ b/server/src/manifestValidation/jsonQuirksDetector.ts @@ -173,6 +173,11 @@ export function handleFlags(node: json.ASTNode, textDocument: json.TextDocument, node.parent?.children?.find((child) => { if (child.type === "property" && child.keyNode.value === "enableSWCSupport" && child.valueNode?.value === true) { addProblem(node, `\`CSSNextSupport\` is always enabled when \`enableSWCSupport\` is enabled.`, json.DiagnosticSeverity.Error, diagnostic, textDocument); + + // CSSNextSupport cannot be an array if enableSWCSupport is enabled + if (node.valueNode?.type === "array") { + addProblem(node, `\`CSSNextSupport\` cannot be an array and must be set to true or omitted when \`enableSWCSupport\` is enabled.`, json.DiagnosticSeverity.Error, diagnostic, textDocument); + } } }); } From 5bbb2b7dae66044dc5438829fc9f035994f2eb30 Mon Sep 17 00:00:00 2001 From: jardicc <13526959+jardicc@users.noreply.github.com> Date: Sat, 19 Oct 2024 19:19:17 +0200 Subject: [PATCH 10/12] Updates CSS features to UXP8.0 --- server/src/CssService/data/uxpCustomData.ts | 137 +++++++++++--------- 1 file changed, 75 insertions(+), 62 deletions(-) diff --git a/server/src/CssService/data/uxpCustomData.ts b/server/src/CssService/data/uxpCustomData.ts index 6bfb648..89ec147 100644 --- a/server/src/CssService/data/uxpCustomData.ts +++ b/server/src/CssService/data/uxpCustomData.ts @@ -3191,114 +3191,97 @@ export const cssData: UXPCSSDataV1 = { { name: "transform", browsers: ["UXP3.0"], - // ! TODO values: [ + /* { name: "matrix()", - description: - "Specifies a 2D transformation in the form of a transformation matrix of six values. matrix(a,b,c,d,e,f) is equivalent to applying the transformation matrix [a b c d e f]", + description: "Specifies a 2D transformation in the form of a transformation matrix of six values. matrix(a,b,c,d,e,f) is equivalent to applying the transformation matrix [a b c d e f]", }, { name: "matrix3d()", - description: - "Specifies a 3D transformation as a 4x4 homogeneous matrix of 16 values in column-major order.", - }, - { - name: "none", + description: "Specifies a 3D transformation as a 4x4 homogeneous matrix of 16 values in column-major order.", }, { name: "perspective()", description: "Specifies a perspective projection matrix.", }, - { - name: "rotate()", - description: - "Specifies a 2D rotation by the angle specified in the parameter about the origin of the element, as defined by the transform-origin property.", - }, { name: "rotate3d()", - description: - "Specifies a clockwise 3D rotation by the angle specified in last parameter about the [x,y,z] direction vector described by the first 3 parameters.", + description: "Specifies a clockwise 3D rotation by the angle specified in last parameter about the [x,y,z] direction vector described by the first 3 parameters.", }, { name: "rotateX('angle')", - description: - "Specifies a clockwise rotation by the given angle about the X axis.", + description: "Specifies a clockwise rotation by the given angle about the X axis.", }, { name: "rotateY('angle')", - description: - "Specifies a clockwise rotation by the given angle about the Y axis.", + description: "Specifies a clockwise rotation by the given angle about the Y axis.", }, { name: "rotateZ('angle')", - description: - "Specifies a clockwise rotation by the given angle about the Z axis.", + description: "Specifies a clockwise rotation by the given angle about the Z axis.", }, { - name: "scale()", - description: - "Specifies a 2D scale operation by the [sx,sy] scaling vector described by the 2 parameters. If the second parameter is not provided, it is takes a value equal to the first.", + name: "scale3d()", + description: "Specifies a 3D scale operation by the [sx,sy,sz] scaling vector described by the 3 parameters.", }, { - name: "scale3d()", - description: - "Specifies a 3D scale operation by the [sx,sy,sz] scaling vector described by the 3 parameters.", + name: "scaleZ()", + description: "Specifies a scale operation using the [1,1,sz] scaling vector, where sz is given as the parameter.", }, { - name: "scaleX()", - description: - "Specifies a scale operation using the [sx,1] scaling vector, where sx is given as the parameter.", + name: "skew()", + description: "Specifies a skew transformation along the X and Y axes. The first angle parameter specifies the skew on the X axis. The second angle parameter specifies the skew on the Y axis. If the second parameter is not given then a value of 0 is used for the Y angle (ie: no skew on the Y axis).", }, { - name: "scaleY()", - description: - "Specifies a scale operation using the [sy,1] scaling vector, where sy is given as the parameter.", + name: "skewX()", + description: "Specifies a skew transformation along the X axis by the given angle.", }, { - name: "scaleZ()", - description: - "Specifies a scale operation using the [1,1,sz] scaling vector, where sz is given as the parameter.", + name: "skewY()", + description: "Specifies a skew transformation along the Y axis by the given angle.", }, { - name: "skew()", - description: - "Specifies a skew transformation along the X and Y axes. The first angle parameter specifies the skew on the X axis. The second angle parameter specifies the skew on the Y axis. If the second parameter is not given then a value of 0 is used for the Y angle (ie: no skew on the Y axis).", + name: "translate3d()", + description: "Specifies a 3D translation by the vector [tx,ty,tz], with tx, ty and tz being the first, second and third translation-value parameters respectively.", }, { - name: "skewX()", - description: - "Specifies a skew transformation along the X axis by the given angle.", + name: "translateZ()", + description: "Specifies a translation by the given amount in the Z direction. Note that percentage values are not allowed in the translateZ translation-value, and if present are evaluated as 0.", }, + */ { - name: "skewY()", - description: - "Specifies a skew transformation along the Y axis by the given angle.", + name: "none", }, { - name: "translate()", - description: - "Specifies a 2D translation by the vector [tx, ty], where tx is the first translation-value parameter and ty is the optional second translation-value parameter.", + name: "rotate()", + description: "Specifies a 2D rotation by the angle specified in the parameter about the origin of the element, as defined by the transform-origin property.", }, { - name: "translate3d()", - description: - "Specifies a 3D translation by the vector [tx,ty,tz], with tx, ty and tz being the first, second and third translation-value parameters respectively.", + name: "scale()", + description: "Specifies a 2D scale operation by the [sx,sy] scaling vector described by the 2 parameters. If the second parameter is not provided, it is takes a value equal to the first.", }, { - name: "translateX()", - description: - "Specifies a translation by the given amount in the X direction.", + name: "scaleX()", + description: "Specifies a scale operation using the [sx,1] scaling vector, where sx is given as the parameter.", + browsers: ["UXP8.0"], }, { - name: "translateY()", - description: - "Specifies a translation by the given amount in the Y direction.", + name: "scaleY()", + description: "Specifies a scale operation using the [sy,1] scaling vector, where sy is given as the parameter.", + browsers: ["UXP8.0"], }, { - name: "translateZ()", - description: - "Specifies a translation by the given amount in the Z direction. Note that percentage values are not allowed in the translateZ translation-value, and if present are evaluated as 0.", + name: "translate()", + description: "Specifies a 2D translation by the vector [tx, ty], where tx is the first translation-value parameter and ty is the optional second translation-value parameter.", + }, + { + name: "translateX()", + description: "Specifies a translation by the given amount in the X direction.", + }, + { + name: "translateY()", + description: "Specifies a translation by the given amount in the Y direction.", }, ], syntax: "none | ", @@ -3309,10 +3292,40 @@ export const cssData: UXPCSSDataV1 = { url: "https://developer.mozilla.org/docs/Web/CSS/transform", }, ], - description: - "A two-dimensional transformation is applied to an element through the 'transform' property. This property contains a list of transform functions similar to those allowed by SVG.", + description: "A two-dimensional transformation is applied to an element through the 'transform' property. This property contains a list of transform functions similar to those allowed by SVG.", restrictions: ["enum"], }, + { + name: "transform-origin", + browsers: ["UXP8.0"], + syntax: "[ | left | center | right | top | bottom ] | [ [ | left | center | right ] && [ | top | center | bottom ] ] ?", + relevance: 74, + references: [ + { + "name": "MDN Reference", + "url": "https://developer.mozilla.org/docs/Web/CSS/transform-origin", + }, + ], + description: "Establishes the origin of transformation for an element.", + restrictions: [ + "position", + "length", + "percentage", + ], + }, + { + name: "translate", + syntax: "none | [ ? ]?", + relevance: 50, + browsers: ["UXP8.0"], + references: [ + { + "name": "MDN Reference", + "url": "https://developer.mozilla.org/docs/Web/CSS/translate", + }, + ], + description: "The translate CSS property allows you to specify translation transforms individually and independently of the transform property. This maps better to typical user interface usage, and saves having to remember the exact order of transform functions to specify in the transform value.", + }, { name: "vertical-align", browsers: ["UXP3.0"], From 02a736f347a8a79ddd580c21295d0be43363ce28 Mon Sep 17 00:00:00 2001 From: jardicc <13526959+jardicc@users.noreply.github.com> Date: Sat, 19 Oct 2024 20:53:47 +0200 Subject: [PATCH 11/12] Improves function validation --- server/src/CssService/data/uxpCustomData.ts | 138 ++++++++++++++++++-- server/src/CssService/services/lint.ts | 30 ++++- 2 files changed, 155 insertions(+), 13 deletions(-) diff --git a/server/src/CssService/data/uxpCustomData.ts b/server/src/CssService/data/uxpCustomData.ts index 89ec147..124eab8 100644 --- a/server/src/CssService/data/uxpCustomData.ts +++ b/server/src/CssService/data/uxpCustomData.ts @@ -3192,6 +3192,7 @@ export const cssData: UXPCSSDataV1 = { name: "transform", browsers: ["UXP3.0"], values: [ + // ! TODO - these are being checked in "uxpCustomData" in functionNames... not here /* { name: "matrix()", @@ -3492,12 +3493,14 @@ export const cssData: UXPCSSDataV1 = { }, { "name": "box-shadow", - "browsers": ["UXP7.3"], // ! SWC + "browsers": ["UXP7.3"], // ! Might need SWC feature flag. "values": [ + /* { "name": "inset", "description": "Changes the drop shadow from an outer shadow (one that shadows the box onto the canvas, as if it were lifted above the canvas) to an inner shadow (one that shadows the canvas onto the box, as if the box were cut out of the canvas and shifted behind it).", }, + */ { "name": "none", "description": "No shadow.", @@ -4019,6 +4022,22 @@ export const cssData: UXPCSSDataV1 = { browsers: ["UXP3.0"], }, + { + name: "scale", + browsers: ["UXP8.0"], // ? It could been added in UXP 7.3 But it has no documentation. And I am not detective but programmer to waste time with finding out. + }, + { + name: "rotate", + browsers: ["UXP8.0"], // ? It could been added in UXP 7.3 But it has no documentation. And I am not detective but programmer to waste time with finding out. + }, + { + name: "scaleX", + browsers: ["UXP8.0"], + }, + { + name: "scaleY", + browsers: ["UXP8.0"], + }, { name: "translate", browsers: ["UXP3.0"], @@ -4036,7 +4055,7 @@ export const cssData: UXPCSSDataV1 = { browsers: ["UXP2.0"], }, - // ! TODO rotate under SWC flag + // ! TODO rotate and others might need feature flags /* other functions attr() @@ -4044,18 +4063,12 @@ export const cssData: UXPCSSDataV1 = { repeating-radial-gradient() repeating-conic-gradient() conic-gradient() - translateX() - translateY() translateZ() - translate() translate3d() rotateX() rotateY() rotateZ() - rotate() rotate3d() - scaleX() - scaleY() scaleZ() scale() scale3d() @@ -4134,6 +4147,115 @@ export const cssData: UXPCSSDataV1 = { ], }; +export const allKnownFunctionNames: string[] = [ + "translateX", + "translateY", + "translateZ", + "translate", + "translate3d", + "rotateX", + "rotateY", + "rotateZ", + "rotate", + "rotate3d", + "scaleX", + "scaleY", + "scaleZ", + "scale", + "scale3d", + "skewX", + "skewY", + "skew", + "matrix", + "matrix3d", + "perspective", + "calc", + "min", + "max", + "clamp", + "round", + "mod", + "rem", + "sin", + "cos", + "tan", + "asin", + "acos", + "atan", + "atan2", + "pow", + "sqrt", + "hypot", + "log", + "exp", + "abs", + "sign", + "blur", + "brightness", + "contrast", + "drop-shadow", + "grayscale", + "hue-rotate", + "invert", + "opacity", + "saturate", + "sepia", + "rgb", + "hsl", + "hwb", + "lch", + "oklch", + "lab", + "oklab", + "color", + "color-mix", + "color-contrast", + "device-cmyk", + "light-dark", + "linear-gradient", + "radial-gradient", + "conic-gradient", + "repeating-linear-gradient", + "repeating-radial-gradient", + "repeating-conic-gradient", + "image", + "image-set", + "cross-fade", + "element", + "paint", + "counter", + "counters", + "symbols", + "circle", + "ellipse", + "inset", + "rect", + "xywh", + "polygon", + "path", + "shape", + "attr", + "env", + "var", + "fit-content", + "minmax", + "repeat", + "stylistic", + "styleset", + "character-variant", + "swash", + "ornaments", + "annotation", + "linear", + "cubic-bezier", + "steps", + "scroll", + "view", + "anchor", + "anchor-size", + "url", +]; + /* // TODO media types diff --git a/server/src/CssService/services/lint.ts b/server/src/CssService/services/lint.ts index a147c9b..7f333d5 100644 --- a/server/src/CssService/services/lint.ts +++ b/server/src/CssService/services/lint.ts @@ -12,7 +12,7 @@ import {NodeType as NType} from "../../CssServiceOriginal/parser/cssNodes"; import { LintConfigurationSettings, Rule, Rules, Settings } from "./lintRules"; import { Element } from "../../CssServiceOriginal/services/lintUtil"; import {UXPCustomData} from "../UXPCustomData"; -import {cssData} from "../data/uxpCustomData"; +import {allKnownFunctionNames, cssData} from "../data/uxpCustomData"; import {Validator} from "../../Validator"; import {LSPServer} from "../../LSPServer"; @@ -530,13 +530,33 @@ export class LintVisitor implements nodes.IVisitor { private visitFunction(node: nodes.Function): boolean { const fnName = node.getName();//.toLowerCase(); - // Skip function in SCSS and Less - // ! TODO - check how to handle built-in functions - if (this.isLess || this.isScss) { + // Have a list of all possible functions in modern browsers (sadly might need to be updated more often) + // So uxp supported function will be checked same as everything else + // banned functions will always report an error + // everything else will just pass + + const foundFunctionRule = this.uxpCustomData.getValidFunctionName(fnName); + + // You can't have custom functions in classic CSS (at least for now) + // So everything not on our list will be reported as an error + if (!this.isLess && !this.isScss) { + if(!foundFunctionRule) { + this.addEntry( + node, + Rules.UnsupportedFunction, + l10n.t("Function: '{0}' is not supported in {1}", fnName, this.uxpCustomData.versionForDisplay), + ); + } return true; } - if(!this.uxpCustomData.getValidFunctionName(fnName)) { + // In Less and SCSS we have custom functions + // So we need to check if it's a custom function + // We do that by checking if it's in the list of known functions + // If it is built-in function but not in our list, we report an error + // If it is built-in function and in our list, we validate as everything else + // If it's a custom function, we don't report an error + if (!foundFunctionRule && allKnownFunctionNames.includes(fnName)) { this.addEntry( node, Rules.UnsupportedFunction, From 941ff9859b34baa9920a4c057ed64a33180a100e Mon Sep 17 00:00:00 2001 From: jardicc <13526959+jardicc@users.noreply.github.com> Date: Mon, 28 Oct 2024 20:46:12 +0100 Subject: [PATCH 12/12] Bump package version to 1.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b1c9b19..7f7fd81 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "uxpvalidator", "displayName": "Validator for UXP", "description": "Validates CSS, LESS & SCSS for UXP. Intellisense and validation for Manifest.json. Please report any issues on GitHub or rate plugin", - "version": "1.1.0", + "version": "1.2.0", "author": "Jaroslav Bereza", "publisher": "JaroslavBereza", "license": "MIT",