Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@stylable/language-service

Package Overview
Dependencies
Maintainers
6
Versions
165
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stylable/language-service - npm Package Compare versions

Comparing version 3.10.1 to 3.11.0

4

cjs/lib/completion-providers.d.ts

@@ -1,2 +0,2 @@

import postcss from 'postcss';
import * as postcss from 'postcss';
import { CSSResolve, ResolvedElement, SRule, Stylable, StylableMeta } from '@stylable/core';

@@ -15,3 +15,3 @@ import { IFileSystem } from '@file-services/types';

parentSelector: SRule | null;
astAtCursor: postcss.NodeBase;
astAtCursor: postcss.Node;
lineChunkAtCursor: string;

@@ -18,0 +18,0 @@ lastSelectoid: string;

import { IFileSystem } from '@file-services/types';
import postcss from 'postcss';
import * as postcss from 'postcss';
import { TextDocument } from 'vscode-languageserver-textdocument';

@@ -4,0 +4,0 @@ import { Color, ColorInformation, ColorPresentation, CompletionItem, Diagnostic, Hover, Location, Position, Range } from 'vscode-languageserver-types';

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createRange = exports.createDiagnosis = void 0;
const core_1 = require("@stylable/core");
const vscode_languageserver_types_1 = require("vscode-languageserver-types");

@@ -10,11 +9,3 @@ function createDiagnosis(content, version, filePath, stylable, cssService) {

}
const docPostCSSRoot = core_1.safeParse(content, { from: filePath });
if (docPostCSSRoot.source) {
const { input } = docPostCSSRoot.source;
// postcss runs path.resolve, which messes up in-memory fs implementation on windows
Object.defineProperty(input, 'from', { value: filePath });
input.file = filePath;
}
const meta = core_1.process(docPostCSSRoot);
stylable.fileProcessor.add(filePath, meta);
const meta = stylable.fileProcessor.processContent(content, filePath);
try {

@@ -24,3 +15,3 @@ stylable.transform(meta);

catch {
/**/
/*TODO: report this failure to transform */
}

@@ -27,0 +18,0 @@ const cleanDoc = cssService.createSanitizedDocument(meta.rawAst, filePath, version);

import ts from 'typescript';
import postcss from 'postcss';
import * as postcss from 'postcss';
import { IFileSystem } from '@file-services/types';

@@ -4,0 +4,0 @@ import { CSSResolve, Stylable, StylableMeta } from '@stylable/core';

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -9,3 +28,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

const typescript_1 = __importDefault(require("typescript"));
const postcss_1 = __importDefault(require("postcss"));
const postcss = __importStar(require("postcss"));
const postcss_value_parser_1 = __importDefault(require("postcss-value-parser"));

@@ -505,3 +524,3 @@ const css_selector_tokenizer_1 = __importDefault(require("css-selector-tokenizer"));

chunkStrings[0];
const expandedLine = core_1.expandCustomSelectors(postcss_1.default.rule({ selector: lineChunkAtCursor }), meta.customSelectors)
const expandedLine = core_1.expandCustomSelectors(postcss.rule({ selector: lineChunkAtCursor }), meta.customSelectors)
.split(' ')

@@ -776,3 +795,4 @@ .pop(); // TODO: replace with selector parser

// Variable definition
if (decl.parent.type === 'rule' &&
if (decl.parent &&
decl.parent.type === 'rule' &&
decl.parent.selector === ':vars' &&

@@ -916,2 +936,3 @@ !!decl.source &&

if (d.prop === core_1.valueMapping.named &&
d.parent &&
d.parent.nodes.find((n) => {

@@ -1038,3 +1059,3 @@ return (n.prop === core_1.valueMapping.from &&

if (node.type === 'decl') {
const r = postcss_1.default.rule({ selector: node.prop + ':' + node.value });
const r = postcss.rule({ selector: node.prop + ':' + node.value });
r.source = node.source;

@@ -1047,3 +1068,3 @@ node.replaceWith(r);

if (ast.raws.after && ast.raws.after.trim()) {
const r = postcss_1.default.rule({ selector: ast.raws.after.trim() });
const r = postcss.rule({ selector: ast.raws.after.trim() });
ast.append(r);

@@ -1341,3 +1362,3 @@ fakes.push(r);

});
const expandedLine = core_1.expandCustomSelectors(postcss_1.default.rule({ selector: lineChunkAtCursor }), meta.customSelectors)
const expandedLine = core_1.expandCustomSelectors(postcss.rule({ selector: lineChunkAtCursor }), meta.customSelectors)
.split(' ')

@@ -1344,0 +1365,0 @@ .pop(); // TODO: replace with selector parser

@@ -1,4 +0,4 @@

import { IFileSystem } from '@file-services/types';
import { IFileSystemSync } from '@file-services/types';
import { ExtendedTsLanguageService } from './types';
export declare function typescriptSupport(fileSystem: IFileSystem): ExtendedTsLanguageService;
export declare function typescriptSupport(fileSystem: IFileSystemSync): ExtendedTsLanguageService;
//# sourceMappingURL=typescript-support.d.ts.map

@@ -1,14 +0,14 @@

import postcss from 'postcss';
import * as postcss from 'postcss';
import { ProviderPosition } from '../completion-providers';
export declare function isInNode(position: ProviderPosition, node: postcss.NodeBase, includeSelector?: boolean): boolean;
export declare function isBeforeRuleset(position: ProviderPosition, node: postcss.NodeBase): boolean;
export declare function isAfterRuleset(position: ProviderPosition, node: postcss.NodeBase): boolean;
export declare function isContainer(node: postcss.NodeBase): node is postcss.ContainerBase;
export declare function isSelector(node: postcss.NodeBase): node is postcss.Rule;
export declare function isVars(node: postcss.NodeBase): boolean;
export declare function isDeclaration(node: postcss.NodeBase): node is postcss.Declaration;
export declare function isComment(node: postcss.NodeBase): node is postcss.Comment;
export declare function isRoot(node: postcss.NodeBase): node is postcss.Root;
export declare function pathFromPosition(ast: postcss.NodeBase, position: ProviderPosition, res?: postcss.NodeBase[], includeSelector?: boolean): postcss.NodeBase[];
export declare function isInNode(position: ProviderPosition, node: postcss.Node, includeSelector?: boolean): boolean;
export declare function isBeforeRuleset(position: ProviderPosition, node: postcss.Node): boolean;
export declare function isAfterRuleset(position: ProviderPosition, node: postcss.Node): boolean;
export declare function isContainer(node: postcss.Node): node is postcss.Container;
export declare function isSelector(node: postcss.Node): node is postcss.Rule;
export declare function isVars(node: postcss.Node): boolean;
export declare function isDeclaration(node: postcss.Node): node is postcss.Declaration;
export declare function isComment(node: postcss.Node): node is postcss.Comment;
export declare function isRoot(node: postcss.Node): node is postcss.Root;
export declare function pathFromPosition(ast: postcss.Node, position: ProviderPosition, res?: postcss.Node[], includeSelector?: boolean): postcss.Node[];
export declare function getPositionInSrc(src: string, position: ProviderPosition): number;
//# sourceMappingURL=postcss-ast-utils.d.ts.map

@@ -38,4 +38,4 @@ "use strict";

function isBeforeRuleset(position, node) {
const part = node.source.input.css
.split('\n')
const part = node
.source.input.css.split('\n')
.slice(node.source.start.line - 1, node.source.end ? node.source.end.line : undefined);

@@ -52,4 +52,4 @@ if (part.findIndex((s) => s.includes('{')) + node.source.start.line > position.line) {

function isAfterRuleset(position, node) {
const part = node.source.input.css
.split('\n')
const part = node
.source.input.css.split('\n')
.slice(node.source.start.line - 1, node.source.end.line);

@@ -56,0 +56,0 @@ if (part.findIndex((s) => s.includes('}')) + node.source.start.line < position.line) {

{
"name": "@stylable/language-service",
"version": "3.10.1",
"version": "3.11.0",
"description": "Stylable Language Services - syntax highlighting, completions, hinting and more for the Stylable CSS preprocessor.",

@@ -17,10 +17,10 @@ "main": "./cjs/index.js",

"dependencies": {
"@file-services/node": "^3.1.1",
"@file-services/typescript": "^3.1.1",
"@stylable/core": "^3.10.1",
"@file-services/types": "^4.0.0",
"@file-services/typescript": "^4.0.0",
"@stylable/core": "^3.11.0",
"css-selector-tokenizer": "^0.7.3",
"js-beautify": "^1.13.0",
"postcss": "^7.0.32",
"postcss": "^8.0.8",
"postcss-value-parser": "^4.1.0",
"vscode-css-languageservice": "^4.3.3",
"vscode-css-languageservice": "^4.3.4",
"vscode-languageserver": "^6.1.1",

@@ -27,0 +27,0 @@ "vscode-languageserver-textdocument": "^1.0.1",

import path from 'path';
import postcss from 'postcss';
import * as postcss from 'postcss';
import postcssValueParser from 'postcss-value-parser';

@@ -69,3 +69,3 @@ import ts from 'typescript';

parentSelector: SRule | null;
astAtCursor: postcss.NodeBase; // candidate for removal
astAtCursor: postcss.Node; // candidate for removal
lineChunkAtCursor: string;

@@ -209,3 +209,3 @@ lastSelectoid: string; // candidate for removal

if (
parentSelector.nodes!.every(
parentSelector.nodes.every(
(n: any) =>

@@ -250,3 +250,3 @@ (isDeclaration(n) && importDirectives[name] !== n.prop) || isComment(n)

if (
parentSelector.nodes!.every(
parentSelector.nodes.every(
(n: any) =>

@@ -269,4 +269,4 @@ (isDeclaration(n) && rulesetDirectives.mixin !== n.prop) || isComment(n)

if (
parentSelector.nodes!.every(
(n: any) =>
parentSelector.nodes.every(
(n) =>
(isDeclaration(n) && rulesetDirectives[name] !== n.prop) ||

@@ -717,5 +717,5 @@ isComment(n)

(astAtCursor as postcss.Rule).nodes &&
(astAtCursor as postcss.Rule).nodes!.length
(astAtCursor as postcss.Rule).nodes.length
) {
importName = ((astAtCursor as postcss.Rule).nodes!.find(
importName = ((astAtCursor as postcss.Rule).nodes.find(
(n) => (n as postcss.Declaration).prop === valueMapping.from

@@ -1202,3 +1202,3 @@ ) as postcss.Declaration).value.replace(/'|"/g, '');

let acc: Completion[] = [];
const ast = astAtCursor as postcss.Node;
const ast = astAtCursor;

@@ -1205,0 +1205,0 @@ if (!lineChunkAtCursor.endsWith('::') && (ast.type === 'root' || ast.type === 'atrule')) {

import { IFileSystem } from '@file-services/types';
import path from 'path';
import postcss from 'postcss';
import * as postcss from 'postcss';
import { getCSSLanguageService, Stylesheet } from 'vscode-css-languageservice';

@@ -5,0 +5,0 @@ import { TextDocument } from 'vscode-languageserver-textdocument';

@@ -1,2 +0,2 @@

import { Diagnostic as StylableDiagnostic, process, safeParse, Stylable } from '@stylable/core';
import { Diagnostic as StylableDiagnostic, Stylable } from '@stylable/core';
import { Diagnostic, Range } from 'vscode-languageserver-types';

@@ -15,20 +15,9 @@ import { CssService } from './css-service';

}
const docPostCSSRoot = safeParse(content, { from: filePath });
if (docPostCSSRoot.source) {
const { input } = docPostCSSRoot.source;
const meta = stylable.fileProcessor.processContent(content, filePath);
// postcss runs path.resolve, which messes up in-memory fs implementation on windows
Object.defineProperty(input, 'from', { value: filePath });
input.file = filePath;
}
const meta = process(docPostCSSRoot);
stylable.fileProcessor.add(filePath, meta);
try {
stylable.transform(meta);
} catch {
/**/
/*TODO: report this failure to transform */
}

@@ -35,0 +24,0 @@

@@ -1,2 +0,2 @@

import { IFileSystem } from '@file-services/types';
import { IFileSystemSync } from '@file-services/types';
import { createBaseHost, createLanguageServiceHost } from '@file-services/typescript';

@@ -6,3 +6,3 @@ import ts from 'typescript';

export function typescriptSupport(fileSystem: IFileSystem) {
export function typescriptSupport(fileSystem: IFileSystemSync) {
let openedFiles: string[] = [];

@@ -9,0 +9,0 @@ const baseHost = createBaseHost(fileSystem);

@@ -1,2 +0,2 @@

import postcss from 'postcss';
import * as postcss from 'postcss';
import { ProviderPosition } from '../completion-providers';

@@ -6,3 +6,3 @@

position: ProviderPosition,
node: postcss.NodeBase,
node: postcss.Node,
includeSelector = false

@@ -25,4 +25,4 @@ ): boolean {

!isBeforeRuleset(position, node) ||
(!!(node as postcss.ContainerBase).nodes &&
!!((node as postcss.ContainerBase).nodes!.length > 0))
(!!(node as postcss.Container).nodes &&
!!((node as postcss.Container).nodes.length > 0))
);

@@ -45,5 +45,5 @@ }

export function isBeforeRuleset(position: ProviderPosition, node: postcss.NodeBase) {
const part = ((node.source!.input as any).css as string)
.split('\n')
export function isBeforeRuleset(position: ProviderPosition, node: postcss.Node) {
const part = node
.source!.input.css.split('\n')
.slice(node.source!.start!.line - 1, node.source!.end ? node.source!.end.line : undefined);

@@ -59,5 +59,5 @@ if (part.findIndex((s) => s.includes('{')) + node.source!.start!.line > position.line) {

export function isAfterRuleset(position: ProviderPosition, node: postcss.NodeBase) {
const part = ((node.source!.input as any).css as string)
.split('\n')
export function isAfterRuleset(position: ProviderPosition, node: postcss.Node) {
const part = node
.source!.input.css.split('\n')
.slice(node.source!.start!.line - 1, node.source!.end!.line);

@@ -78,23 +78,23 @@ if (part.findIndex((s) => s.includes('}')) + node.source!.start!.line < position.line) {

export function isContainer(node: postcss.NodeBase): node is postcss.ContainerBase {
export function isContainer(node: postcss.Node): node is postcss.Container {
return hasOwnProperty.call(node, 'nodes');
}
export function isSelector(node: postcss.NodeBase): node is postcss.Rule {
export function isSelector(node: postcss.Node): node is postcss.Rule {
return hasOwnProperty.call(node, 'selector');
}
export function isVars(node: postcss.NodeBase) {
export function isVars(node: postcss.Node) {
return hasOwnProperty.call(node, 'selector') && (node as postcss.Rule).selector === ':vars';
}
export function isDeclaration(node: postcss.NodeBase): node is postcss.Declaration {
export function isDeclaration(node: postcss.Node): node is postcss.Declaration {
return hasOwnProperty.call(node, 'prop');
}
export function isComment(node: postcss.NodeBase): node is postcss.Comment {
export function isComment(node: postcss.Node): node is postcss.Comment {
return hasOwnProperty.call(node, 'type') && (node as postcss.Comment).type === 'comment';
}
export function isRoot(node: postcss.NodeBase): node is postcss.Root {
export function isRoot(node: postcss.Node): node is postcss.Root {
return hasOwnProperty.call(node, 'type') && (node as postcss.Root).type === 'root';

@@ -104,10 +104,10 @@ }

export function pathFromPosition(
ast: postcss.NodeBase,
ast: postcss.Node,
position: ProviderPosition,
res: postcss.NodeBase[] = [],
res: postcss.Node[] = [],
includeSelector = false
): postcss.NodeBase[] {
): postcss.Node[] {
res.push(ast);
if (isContainer(ast) && ast.nodes) {
const childNode = ast.nodes.find((node: postcss.NodeBase) => {
const childNode = ast.nodes.find((node: postcss.Node) => {
return isInNode(position, node, includeSelector);

@@ -114,0 +114,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc