From 80f5a209f676fbf3df82752d4c3b4c935014c77c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 30 May 2024 16:25:20 -0700 Subject: [PATCH] Parse Deprecation.forVersion on compiler side (#299) --- lib/src/deprecations.ts | 20 ++------------------ lib/src/legacy/index.ts | 2 -- lib/src/version.ts | 3 +++ package.json | 2 +- 4 files changed, 6 insertions(+), 21 deletions(-) diff --git a/lib/src/deprecations.ts b/lib/src/deprecations.ts index e30527c4..26341d82 100644 --- a/lib/src/deprecations.ts +++ b/lib/src/deprecations.ts @@ -2,26 +2,12 @@ // MIT-style license that can be found in the LICENSE file or at // https://opensource.org/licenses/MIT. -import {deprecations} from './vendor/deprecations'; -import {Deprecation, DeprecationOrId} from './vendor/sass'; +import {DeprecationOrId} from './vendor/sass'; import {Version} from './version'; export {deprecations} from './vendor/deprecations'; export {Deprecation, DeprecationOrId, DeprecationStatus} from './vendor/sass'; -/** - * Returns whether the given deprecation was active in the given version. - */ -function isActiveIn(deprecation: Deprecation, version: Version) { - const deprecatedIn = deprecation.deprecatedIn; - if (deprecation.status !== 'active' || !deprecatedIn) return false; - if (version.major > deprecatedIn.major) return true; - if (version.major < deprecatedIn.major) return false; - if (version.minor > deprecatedIn.minor) return true; - if (version.minor < deprecatedIn.minor) return false; - return version.patch >= deprecatedIn.patch; -} - /** * Converts a mixed array of deprecations, IDs, and versions to an array of IDs * that's ready to include in a CompileRequest. @@ -31,9 +17,7 @@ export function getDeprecationIds( ): string[] { return arr.flatMap(item => { if (item instanceof Version) { - return Object.values(deprecations) - .filter(deprecation => isActiveIn(deprecation, item)) - .map(deprecation => deprecation.id); + return arr.map(item => item.toString()); } else if (typeof item === 'string') { return item; } diff --git a/lib/src/legacy/index.ts b/lib/src/legacy/index.ts index d7543e35..d5001e7b 100644 --- a/lib/src/legacy/index.ts +++ b/lib/src/legacy/index.ts @@ -32,8 +32,6 @@ import { LegacyStringOptions, Options, StringOptions, - Importer, - FileImporter, } from '../vendor/sass'; import {wrapFunction} from './value/wrap'; import {endOfLoadProtocol, LegacyImporterWrapper} from './importer'; diff --git a/lib/src/version.ts b/lib/src/version.ts index 772b8258..79f61371 100644 --- a/lib/src/version.ts +++ b/lib/src/version.ts @@ -21,4 +21,7 @@ export class Version implements api.Version { parseInt(match[3]) ); } + toString(): string { + return `${this.major}.${this.minor}.${this.patch}`; + } } diff --git a/package.json b/package.json index b2f836a1..bc5eea39 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "sass-embedded", "version": "1.77.3", - "protocol-version": "2.7.0", + "protocol-version": "2.7.1", "compiler-version": "1.77.3", "description": "Node.js library that communicates with Embedded Dart Sass using the Embedded Sass protocol", "repository": "sass/embedded-host-node",