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

@markuplint/types

Package Overview
Dependencies
Maintainers
1
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@markuplint/types - npm Package Compare versions

Comparing version 4.0.0-dev.10 to 4.0.0-dev.12

2

lib/check-multi-types.d.ts
import type { CustomSyntaxCheck, UnmatchedResult } from './types.js';
export declare function checkMultiTypes(value: string, checks: readonly CustomSyntaxCheck[]): import("./types.js").MatchedResult | UnmatchedResult;
export declare function checkMultiTypes(value: string, checks: readonly CustomSyntaxCheck[]): UnmatchedResult | import("./types.js").MatchedResult;
import { fork } from 'css-tree';
import { log } from './debug.js';
import { tokenizers } from './defs.js';
import { tokenizers, overrides } from './defs.js';
import { matched } from './match-result.js';

@@ -55,3 +55,6 @@ const MIMIC_TAG_L = 'mimiccases---';

const lexer = fork({
types: typesExtended,
types: {
...overrides,
...typesExtended,
},
properties: propsExtended,

@@ -58,0 +61,0 @@ }).lexer;

import type { Defs, CssSyntaxTokenizer } from './types.js';
export declare const types: Defs;
export declare const overrides: Record<string, string>;
export declare const tokenizers: Record<string, CssSyntaxTokenizer>;

@@ -408,47 +408,77 @@ import { checkMultiTypes } from './check-multi-types.js';

ref: 'https://html.spec.whatwg.org/multipage/images.html#srcset-attributes',
syntax: {
apply: '<srcset>',
def: {
srcset: '<image-candidate-strings> [, <image-candidate-strings>]*',
'image-candidate-strings': '<valid-non-empty-url> [ <width-descriptor> | <pixel-density-descriptor> ]?',
'valid-non-empty-url'(token, getNextToken) {
if (!token) {
return 0;
}
let willAdoptTokenLength = 0;
do {
if (token.type === 13) {
is(value) {
const images = value.split(',');
for (const image of images) {
// image candidate string
const [url, , descriptor, ...tail] = new TokenCollection(image.trim(), {
disallowToSurroundBySpaces: true,
separator: 'space',
});
if (!url) {
return unmatched(value, 'unexpected-token', {
expects: [
{
type: 'format',
value: 'valid non-empty URL',
},
],
});
}
if (descriptor) {
const { num, unit } = splitUnit(descriptor.value);
switch (unit) {
case 'w': {
if (!isUint(num)) {
return unmatched(value, 'unexpected-token', {
expects: [
{
type: 'format',
value: 'width descriptor',
},
],
});
}
break;
}
willAdoptTokenLength++;
} while ((token = getNextToken(willAdoptTokenLength)));
return willAdoptTokenLength;
},
'width-descriptor'(token) {
if (!token) {
return 0;
case 'x': {
if (!isFloat(num)) {
return unmatched(value, 'unexpected-token', {
expects: [
{
type: 'format',
value: 'pixel density descriptor',
},
],
});
}
break;
}
default: {
return unmatched(value, 'unexpected-token', {
expects: [
{
type: 'format',
value: 'width descriptor',
},
{
type: 'format',
value: 'pixel density descriptor',
},
],
});
}
}
const { num, unit } = splitUnit(token.value);
if (unit !== 'w') {
return 0;
}
if (!isUint(num)) {
return 0;
}
return 1;
},
'pixel-density-descriptor'(token) {
if (!token) {
return 0;
}
const { num, unit } = splitUnit(token.value);
if (unit !== 'x') {
return 0;
}
if (!isFloat(num)) {
return 0;
}
return 1;
},
},
}
if (tail[0]) {
return unmatched(value, 'unexpected-token', {
expects: [
{
type: 'syntax',
value: 'image candidate string',
},
],
});
}
}
return matched();
},

@@ -819,2 +849,23 @@ },

};
export const overrides = {
// Alias
'legacy-length-percentage': '<length> | <percentage> | <svg-length>',
'legacy-angle': '<angle> | <zero> | <number>',
/**
* @see https://www.w3.org/TR/css-transforms-1/#funcdef-transform-translate
*/
'translate()': 'translate( <legacy-length-percentage> , <legacy-length-percentage>? ) | translate( <legacy-length-percentage> <legacy-length-percentage>? )',
/**
* @see https://www.w3.org/TR/css-transforms-1/#funcdef-transform-scale
*/
'scale()': 'scale( [ <number> | <percentage> ]#{1,2} )',
/**
* @see https://www.w3.org/TR/css-transforms-1/#funcdef-transform-rotate
*/
'rotate()': 'rotate( <legacy-angle> )',
/**
* @see https://www.w3.org/TR/css-transforms-1/#funcdef-transform-skew
*/
'skew()': 'skew( <legacy-angle> , <legacy-angle>? ) | skew( <legacy-angle> <legacy-angle>? )',
};
export const tokenizers = {

@@ -821,0 +872,0 @@ // RFC

@@ -5,3 +5,3 @@ import type { FormattedPrimitiveTypeCheck, MatchedResult, UnmatchedResult, UnmatchedResultOptions, UnmatchedResultReason } from './types.js';

readonly reason?: UnmatchedResultReason;
}): (value: string) => MatchedResult | UnmatchedResult;
}): (value: string) => UnmatchedResult | MatchedResult;
export declare function matched(): MatchedResult;

@@ -8,0 +8,0 @@ export declare function unmatched(value: string, reason?: UnmatchedResultReason, options?: UnmatchedResultOptions & {

@@ -27,3 +27,3 @@ import type { TokenValue } from './types.js';

cache?: boolean;
}): import("../types.js").MatchedResult | UnmatchedResult;
}): UnmatchedResult | import("../types.js").MatchedResult;
chunk(split: number): TokenCollection[];

@@ -30,0 +30,0 @@ compareTokens(callback: (prev: Readonly<Token>, current: Readonly<Token>) => Readonly<Token> | null | void): Readonly<Token> | null | undefined;

@@ -23,3 +23,3 @@ import type { TokenValue } from './types.js';

static getLine(value: string, offset: number): number;
static getType(value: string, separators?: readonly string[]): 1 | 13 | 18;
static getType(value: string, separators?: readonly string[]): 1 | 18 | 13;
static shiftLocation(token: Readonly<Token>, offset: number): {

@@ -26,0 +26,0 @@ offset: number;

{
"name": "@markuplint/types",
"version": "4.0.0-dev.10+b28398ab",
"version": "4.0.0-dev.12+2275fbeb0",
"description": "Type declaration and value checker",

@@ -25,3 +25,7 @@ "repository": "git@github.com:markuplint/markuplint.git",

"clean": "tsc --build --clean",
"schema": "ts-node './gen/types.ts'; json2ts './types.schema.json' > './src/types.schema.ts'; prettier './src/types.schema.ts' './types.schema.json' --write; eslint './src/types.schema.ts' --fix; tsc;"
"schema": "run-s schema:types schema:schema build schema:prettier schema:eslint schema:prettier",
"schema:types": "node --loader ts-node/esm \"./gen/types.ts\"",
"schema:schema": "json2ts \"./types.schema.json\" > \"./src/types.schema.ts\"",
"schema:eslint": "eslint --fix \"./src/types.schema.ts\"",
"schema:prettier": "prettier --write \"./src/types.schema.ts\" \"./types.schema.json\" --log-level warn"
},

@@ -36,6 +40,6 @@ "dependencies": {

"leven": "^4.0.0",
"type-fest": "^4.8.3",
"type-fest": "^4.9.0",
"whatwg-mimetype": "^4.0.0"
},
"gitHead": "b28398ab9c8f0ad790f2915ad5da8f3a80e9b8d6"
"gitHead": "2275fbeb053605b636f080f4fafd7cd4fc57a9a3"
}

Sorry, the diff of this file is not supported yet

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