@cssints/css-grammar 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,4 @@
1
1
  import { Condition } from "./query.mjs";
2
- //#region src/api-query.d.ts
3
2
  export declare const media: Condition<"media", string>;
4
3
  export declare const container: Condition<"container", string>;
5
- export declare const supports: Condition<"supports", string>;
6
- //#endregion
4
+ export declare const supports: Condition<"supports", string>;
@@ -1,7 +1,6 @@
1
1
  import { properties } from "./mdn.mjs";
2
2
  import { Sentinel, Valid } from "./css.mjs";
3
3
  import { CSSStyleValue } from "./values.mjs";
4
- //#region src/api-typed.d.ts
5
4
  type Part = string | CSSStyleValue;
6
5
  type Text<P> = P extends string ? P : P extends CSSStyleValue<infer T> ? Sentinel<T> : never;
7
6
  export type Join<A extends readonly Part[]> = A extends readonly [infer H, ...infer R extends readonly Part[]] ? R extends readonly [] ? Text<H> : `${Text<H>} ${Join<R>}` : "";
@@ -15,4 +14,4 @@ export declare const border: TypedPropertyFn<"border">;
15
14
  export declare const color: TypedPropertyFn<"color">;
16
15
  export declare const opacity: TypedPropertyFn<"opacity">;
17
16
  export declare const fontSize: TypedPropertyFn<"font-size">;
18
- //#endregion
17
+ export {};
package/dist/api.d.mts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { PropertyFn } from "./css.mjs";
2
- //#region src/api.d.ts
3
2
  export declare const padding: PropertyFn<"padding">;
4
3
  export declare const margin: PropertyFn<"margin">;
5
4
  export declare const width: PropertyFn<"width">;
@@ -9,5 +8,4 @@ export declare const color: PropertyFn<"color">;
9
8
  export declare const alignItems: PropertyFn<"align-items">;
10
9
  export declare const display: PropertyFn<"display">;
11
10
  export declare const borderRadius: PropertyFn<"border-radius">;
12
- export declare const fontSize: PropertyFn<"font-size">;
13
- //#endregion
11
+ export declare const fontSize: PropertyFn<"font-size">;
@@ -1,5 +1,3 @@
1
1
  import { BrowsersError } from "./errors.mjs";
2
2
  import { Effect } from "effect";
3
- //#region src/browsers.d.ts
4
- export declare const browsers: (query?: string | undefined, path?: string | undefined) => Effect.Effect<string[], BrowsersError, never>;
5
- //#endregion
3
+ export declare const browsers: (query?: string | undefined, path?: string | undefined) => Effect.Effect<string[], BrowsersError, never>;
package/dist/browsers.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { BrowsersError } from "./errors.mjs";
2
2
  import { Effect } from "effect";
3
- //#region src/browsers.ts
3
+ // src/browsers.ts
4
4
  const browserslist = process.getBuiltinModule("node:module").createRequire(import.meta.url)("browserslist");
5
5
  const browsers = Effect.fn("browsers")(function* (query, path) {
6
6
  return yield* Effect.try({
@@ -11,5 +11,4 @@ const browsers = Effect.fn("browsers")(function* (query, path) {
11
11
  })
12
12
  });
13
13
  });
14
- //#endregion
15
14
  export { browsers };
package/dist/check.d.mts CHANGED
@@ -2,7 +2,6 @@ import { QueryKind } from "./query.mjs";
2
2
  import { RuleError, TwinError } from "./errors.mjs";
3
3
  import { Warning } from "./support.mjs";
4
4
  import { Effect } from "effect";
5
- //#region src/check.d.ts
6
5
  export type DeclarationError = TwinError | RuleError;
7
6
  export declare const isDeclarationError: (e: unknown) => e is DeclarationError;
8
7
  export declare function checkDeclarationNow(p: string, v: string, warnings: boolean): Warning[];
@@ -13,5 +12,4 @@ export declare function checkQueryNow(kind: QueryKind, q: string): void;
13
12
  /** Twin of ValidQuery<K, S> (query.ts): the query of a media(), container() or supports() call is valid, or why not. */
14
13
  export declare const checkQuery: (kind: "media" | "container" | "supports", q: string) => Effect.Effect<void, TwinError, never>;
15
14
  /** The selector of a `css.global()` call is a <complex-selector-list>, or why not (selector.ts). */
16
- export declare const checkSelector: (selector: string) => Effect.Effect<void, TwinError, never>;
17
- //#endregion
15
+ export declare const checkSelector: (selector: string) => Effect.Effect<void, TwinError, never>;
package/dist/check.mjs CHANGED
@@ -6,7 +6,7 @@ import { violation } from "./rules.mjs";
6
6
  import { checkSelectorNow } from "./selector.mjs";
7
7
  import { supportOf } from "./support.mjs";
8
8
  import { Effect } from "effect";
9
- //#region src/check.ts
9
+ // src/check.ts
10
10
  const isDeclarationError = (e) => isTwinError(e) || e instanceof RuleError;
11
11
  const passed = /* @__PURE__ */ new Set();
12
12
  function checkDeclarationNow(p, v, warnings) {
@@ -81,5 +81,4 @@ const checkSelector = Effect.fnUntraced(function* (selector) {
81
81
  }
82
82
  });
83
83
  });
84
- //#endregion
85
84
  export { checkDeclaration, checkDeclarationNow, checkQuery, checkQueryNow, checkSelector, checkValueNow, isDeclarationError };
package/dist/css.d.mts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { Keywords } from "./keywords.mjs";
2
2
  import { properties, syntaxes } from "./mdn.mjs";
3
- //#region src/css.d.ts
4
3
  type Props = typeof properties;
5
4
  type Syns = typeof syntaxes;
6
5
  type Ws = " " | "\n" | "\t";
@@ -295,4 +294,4 @@ type Message<Label extends string, G extends string, S extends string> = Furthes
295
294
  type CaseFix<Label extends string, F extends string> = Tok1<F>[0] extends (infer W extends string) ? ([W] extends [""] ? "" : Keywords extends { [K in Label]: infer O; } ? FixWord<Bucket<O, Lowercase<W>>, W> extends (infer K extends string) ? ([K] extends [never] ? "" : ` ("${W}" is ${K} in CSS; write "${K}")`) : "" : "") : "";
296
295
  type FixWord<K, W extends string> = K extends string ? (Lowercase<K> extends Lowercase<W> ? (K extends W ? never : K) : never) : never;
297
296
  export type PropertyFn<P extends keyof Props> = <const S extends string>(value: Valid<P, S>) => string;
298
- //#endregion
297
+ export {};
package/dist/errors.d.mts CHANGED
@@ -1,4 +1,3 @@
1
- //#region src/errors.d.ts
2
1
  declare const ParseError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
3
2
  readonly _tag: "ParseError";
4
3
  } & Readonly<A>;
@@ -49,4 +48,4 @@ export declare class BrowsersError extends BrowsersError_base<{
49
48
  }> {}
50
49
  export type TwinError = ParseError | UnknownPropertyError | InvalidValueError;
51
50
  export declare const isTwinError: (e: unknown) => e is TwinError;
52
- //#endregion
51
+ export {};
package/dist/errors.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Data } from "effect";
2
- //#region src/errors.ts
2
+ // src/errors.ts
3
3
  /** A value grammar (mdn-data syntax) is malformed: `position` is the offset in `grammar`, `expected` what fits there. */
4
4
  var ParseError = class extends Data.TaggedError("ParseError") {};
5
5
  /** `property` has no grammar in mdn-data. */
@@ -11,5 +11,4 @@ var RuleError = class extends Data.TaggedError("RuleError") {};
11
11
  /** browserslist rejected the query. */
12
12
  var BrowsersError = class extends Data.TaggedError("BrowsersError") {};
13
13
  const isTwinError = (e) => e instanceof ParseError || e instanceof UnknownPropertyError || e instanceof InvalidValueError;
14
- //#endregion
15
14
  export { BrowsersError, InvalidValueError, ParseError, RuleError, UnknownPropertyError, isTwinError };
@@ -1,4 +1,3 @@
1
- //#region src/functions.d.ts
2
1
  export declare const functions: {
3
2
  readonly abs: {
4
3
  readonly sep: ", ";
@@ -351,5 +350,4 @@ export declare const functions: {
351
350
  readonly "dynamic-range-limit-mix": {
352
351
  readonly sep: ", ";
353
352
  };
354
- };
355
- //#endregion
353
+ };
@@ -1,4 +1,4 @@
1
- //#region src/functions.ts
1
+ // src/functions.ts
2
2
  const functions = {
3
3
  abs: {
4
4
  "sep": ", ",
@@ -174,5 +174,4 @@ const functions = {
174
174
  superellipse: { "sep": " " },
175
175
  "dynamic-range-limit-mix": { "sep": ", " }
176
176
  };
177
- //#endregion
178
177
  export { functions };
@@ -1,4 +1,3 @@
1
- //#region src/keywords.d.ts
2
1
  type K_absolute_size = {
3
2
  "l": "large";
4
3
  "m": "medium";
@@ -2350,4 +2349,4 @@ export interface Keywords {
2350
2349
  "n": "normal";
2351
2350
  };
2352
2351
  }
2353
- //#endregion
2352
+ export {};
@@ -1,3 +1 @@
1
- //#region src/longhands.d.ts
2
- export declare const longhands: Record<string, readonly string[] | undefined>;
3
- //#endregion
1
+ export declare const longhands: Record<string, readonly string[] | undefined>;
@@ -1,4 +1,4 @@
1
- //#region src/longhands.ts
1
+ // src/longhands.ts
2
2
  const longhands = {
3
3
  "-webkit-text-stroke": ["-webkit-text-stroke-color", "-webkit-text-stroke-width"],
4
4
  "all": [
@@ -837,5 +837,4 @@ const longhands = {
837
837
  "white-space": ["text-wrap-mode", "white-space-collapse"],
838
838
  "word-wrap": ["overflow-wrap"]
839
839
  };
840
- //#endregion
841
840
  export { longhands };
package/dist/mdn.d.mts CHANGED
@@ -1,4 +1,3 @@
1
- //#region src/mdn.d.ts
2
1
  export declare const properties: {
3
2
  readonly "--*": "<declaration-value>";
4
3
  readonly "-webkit-box-reflect": "[ above | below | right | left ]? <length>? <image>?";
@@ -890,5 +889,4 @@ export declare const syntaxes: {
890
889
  readonly "target-counter()": "target-counter( [ <string> | <url> ] , <custom-ident> , <counter-style>? )";
891
890
  readonly "target-counters()": "target-counters( [ <string> | <url> ] , <custom-ident> , <string> , <counter-style>? )";
892
891
  readonly "target-text()": "target-text( [ <string> | <url> ] , [ content | before | after | first-letter ]? )";
893
- };
894
- //#endregion
892
+ };
package/dist/mdn.mjs CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/mdn.ts
1
+ // src/mdn.ts
2
2
  const properties = {
3
3
  "--*": "<declaration-value>",
4
4
  "-webkit-box-reflect": "[ above | below | right | left ]? <length>? <image>?",
@@ -891,5 +891,4 @@ const syntaxes = {
891
891
  "target-counters()": "target-counters( [ <string> | <url> ] , <custom-ident> , <string> , <counter-style>? )",
892
892
  "target-text()": "target-text( [ <string> | <url> ] , [ content | before | after | first-letter ]? )"
893
893
  };
894
- //#endregion
895
894
  export { properties, syntaxes };
package/dist/query.d.mts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { Consume, Matches, Parse, Stuck, Unexpected } from "./css.mjs";
2
- //#region src/query.d.ts
3
2
  export declare const ENTRY: {
4
3
  readonly media: "media-query-list";
5
4
  readonly container: "container-condition";
@@ -31,4 +30,4 @@ type Open = {
31
30
  type Balanced<S extends string, Stack extends string = ""> = S extends `${infer C}${infer R}` ? C extends "(" | "[" ? Balanced<R, `${C}${Stack}`> : C extends ")" | "]" ? Stack extends `${Open[C]}${infer Rest}` ? Balanced<R, Rest> : false : C extends '"' | "'" ? R extends `${string}${C}${infer After}` ? Balanced<After, Stack> : false : Balanced<R, Stack> : Stack extends "" ? true : false;
32
31
  /** The selector of `global()`, or a message: not empty, brackets and quotes balanced. */
33
32
  export type ValidSelector<S extends string> = Trim<S> extends "" ? "global(): the selector is empty" : Balanced<S> extends true ? S : `global(): unbalanced brackets or quotes in "${S}"`;
34
- //#endregion
33
+ export {};
package/dist/query.mjs CHANGED
@@ -1,8 +1,7 @@
1
- //#region src/query.ts
1
+ // src/query.ts
2
2
  const ENTRY = {
3
3
  media: "media-query-list",
4
4
  container: "container-condition",
5
5
  supports: "supports-condition"
6
6
  };
7
- //#endregion
8
7
  export { ENTRY };
package/dist/rules.d.mts CHANGED
@@ -1,6 +1,4 @@
1
1
  import { RuleError } from "./errors.mjs";
2
2
  import { Effect } from "effect";
3
- //#region src/rules.d.ts
4
3
  export declare function violation(p: string, v: string): RuleError | undefined;
5
- export declare const checkRules: (p: string, v: string) => Effect.Effect<string, RuleError, never>;
6
- //#endregion
4
+ export declare const checkRules: (p: string, v: string) => Effect.Effect<string, RuleError, never>;
package/dist/rules.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { RuleError } from "./errors.mjs";
2
2
  import { matches } from "./twin-core.mjs";
3
3
  import { Effect, Formatter } from "effect";
4
- //#region src/rules.ts
4
+ // src/rules.ts
5
5
  const splitList = (v) => v.match(/(?:"[^"]*"|'[^']*'|\([^()]*(?:\([^()]*\)[^()]*)*\)|[^,"'()])+/g)?.map((s) => s.trim()) ?? [];
6
6
  const CSS_WIDE = /* @__PURE__ */ new Set([
7
7
  "inherit",
@@ -214,5 +214,4 @@ const checkRules = Effect.fnUntraced(function* (p, v) {
214
214
  if (error) return yield* error;
215
215
  return v;
216
216
  });
217
- //#endregion
218
217
  export { checkRules, violation };
@@ -1,3 +1 @@
1
- //#region src/selector.d.ts
2
- export declare function checkSelectorNow(sel: string): void;
3
- //#endregion
1
+ export declare function checkSelectorNow(sel: string): void;
package/dist/selector.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { InvalidValueError } from "./errors.mjs";
2
- //#region src/selector.ts
2
+ // src/selector.ts
3
3
  const I = String.raw`(?:--|-?(?:[A-Za-z_\u0080-\uffff]|\\.))(?:[\w\u0080-\uffff-]|\\.)*`;
4
4
  const STR = String.raw`"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'`;
5
5
  const NS = String.raw`(?:(?:${I}|\*)?\|)?`;
@@ -75,5 +75,4 @@ function checkSelectorNow(sel) {
75
75
  }
76
76
  }
77
77
  }
78
- //#endregion
79
78
  export { checkSelectorNow };
@@ -1,7 +1,6 @@
1
1
  import { BrowsersError } from "./errors.mjs";
2
2
  import { Effect } from "effect";
3
3
  import { Identifier } from "@mdn/browser-compat-data";
4
- //#region src/support.d.ts
5
4
  export type Target = [agent: string, version: string];
6
5
  export declare const targets: (query?: string | undefined, path?: string | undefined) => Effect.Effect<Target[], BrowsersError, never>;
7
6
  declare global {
@@ -32,5 +31,4 @@ export declare function supportOf(p: string, v: string, ts?: Target[]): Warning[
32
31
  export declare function browsers(lacking: string[]): string;
33
32
  export declare const support: (p: string, v: string, ts?: Target[] | undefined) => Effect.Effect<Warning[], never, never>;
34
33
  export declare const messageOf: (p: string, v: string, w: Warning) => string;
35
- export declare const message: (p: string, v: string, w: Warning) => Effect.Effect<string, never, never>;
36
- //#endregion
34
+ export declare const message: (p: string, v: string, w: Warning) => Effect.Effect<string, never, never>;
package/dist/support.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { browsers as browsers$1 } from "./browsers.mjs";
2
2
  import { properties, syntaxes } from "./mdn.mjs";
3
3
  import { Effect } from "effect";
4
- //#region src/support.ts
4
+ // src/support.ts
5
5
  const bcd = process.getBuiltinModule("node:module").createRequire(import.meta.url)("@mdn/browser-compat-data");
6
6
  const props = properties;
7
7
  const syns = syntaxes;
@@ -174,5 +174,4 @@ const messageOf = (p, v, w) => `${p}: ${w.feature === p ? "the property" : `"${w
174
174
  const message = Effect.fn("support.message")(function* (p, v, w) {
175
175
  return yield* Effect.sync(() => messageOf(p, v, w));
176
176
  });
177
- //#endregion
178
177
  export { browsers, get, lacking, lackingOf, message, messageOf, support, supportOf, targets, tokenKey, useTargets };
package/dist/token.d.mts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { Consume, Matches, Parse, Stuck, Unexpected } from "./css.mjs";
2
2
  import { CSSStyleValue } from "./values.mjs";
3
- //#region src/token.d.ts
4
3
  /**
5
4
  * Per token type, by the name of `token.<name>`:
6
5
  * - `syntax`: the `@property` syntax, `<syntax>`, checked by the twin and by `ValidSyntax`;
@@ -143,4 +142,4 @@ export type StyleObject = Record<string, string>;
143
142
  export type TokenFn<K extends TokenType> = <const I extends string, const N extends string | TokenName | undefined = undefined>(initial: ValidToken<K, I>, name?: N) => Token<K, [N] extends [undefined] ? false : true>;
144
143
  /** `token.set(token, value)`: a style object with one custom property. A private token cannot be set. */
145
144
  export type TokenSetFn = <const K extends TokenType, const V extends string>(token: Token<K, true>, value: ValidToken<K, V>) => StyleObject;
146
- //#endregion
145
+ export {};
package/dist/token.mjs CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/token.ts
1
+ // src/token.ts
2
2
  /**
3
3
  * Per token type, by the name of `token.<name>`:
4
4
  * - `syntax`: the `@property` syntax, `<syntax>`, checked by the twin and by `ValidSyntax`;
@@ -108,5 +108,4 @@ const DTCG_TYPES = {
108
108
  cubicBezier: "easingFunction",
109
109
  shadow: "shadow"
110
110
  };
111
- //#endregion
112
111
  export { DTCG_TYPES, TOKEN_TYPES, grammarOf };
@@ -1,4 +1,3 @@
1
- //#region src/twin-core.d.ts
2
1
  type Tok = {
3
2
  t: "type";
4
3
  v: string;
@@ -45,4 +44,4 @@ export declare const magnitude: (t: string) => number;
45
44
  export declare const nullable: (n: Node) => boolean;
46
45
  export declare function matches(syntax: string, s: string, pending?: boolean): boolean;
47
46
  export declare function valid(p: string, s: string, syntax?: string | undefined): string;
48
- //#endregion
47
+ export {};
@@ -1,6 +1,6 @@
1
1
  import { InvalidValueError, ParseError, UnknownPropertyError } from "./errors.mjs";
2
2
  import { properties, syntaxes } from "./mdn.mjs";
3
- //#region src/twin-core.ts
3
+ // src/twin-core.ts
4
4
  const props = properties;
5
5
  const syns = syntaxes;
6
6
  const trim = (s) => s.replace(/^[ \n\t]+/, "");
@@ -785,5 +785,4 @@ function valid(p, s, syntax = props[p]) {
785
785
  expected
786
786
  });
787
787
  }
788
- //#endregion
789
788
  export { consume, isNative, magnitude, matches, next, nullable, parseGrammar, spaced, valid };
package/dist/twin.d.mts CHANGED
@@ -1,12 +1,10 @@
1
1
  import { ParseError, TwinError } from "./errors.mjs";
2
2
  import { Node, nullable } from "./twin-core.mjs";
3
3
  import { Effect } from "effect";
4
- //#region src/twin.d.ts
5
4
  /** The grammar as a tree, memoized by its text. */
6
5
  export declare const parse: (grammar: string) => Effect.Effect<Node, ParseError, never>;
7
6
  /** Whether `s` is a complete value of the grammar `syntax`; `pending`: a var(), env() or if() in it stands for any value. */
8
7
  export declare const matches: (syntax: string, s: string, pending?: boolean | undefined) => Effect.Effect<boolean, TwinError, never>;
9
8
  /** Twin of Valid<P, S>: the value, or the furthest point it reached and what the grammar expected there. */
10
9
  export declare const valid: (p: string, s: string) => Effect.Effect<string, TwinError, never>;
11
- //#endregion
12
10
  export { type Node, nullable };
package/dist/twin.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ParseError, isTwinError } from "./errors.mjs";
2
2
  import { matches as matches$1, nullable, parseGrammar, valid as valid$1 } from "./twin-core.mjs";
3
3
  import { Effect } from "effect";
4
- //#region src/twin.ts
4
+ // src/twin.ts
5
5
  const grammarError = (grammar, e) => isTwinError(e) ? e : new ParseError({
6
6
  message: `grammar: ${String(e)}`,
7
7
  grammar,
@@ -34,5 +34,4 @@ const valid = Effect.fnUntraced(function* (p, s) {
34
34
  catch: (e) => grammarError(p, e)
35
35
  });
36
36
  });
37
- //#endregion
38
37
  export { matches, nullable, parse, valid };
package/dist/values.d.mts CHANGED
@@ -1,4 +1,3 @@
1
- //#region src/values.d.ts
2
1
  export declare class CSSStyleValue<T extends string = string> {
3
2
  readonly "~type": T;
4
3
  }
@@ -24,5 +23,4 @@ export declare const CSS: {
24
23
  em: (v: number) => CSSUnitValue<"length">;
25
24
  percent: (v: number) => CSSUnitValue<"percentage">;
26
25
  number: (v: number) => CSSUnitValue<"number">;
27
- };
28
- //#endregion
26
+ };
package/dist/values.mjs CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/values.ts
1
+ // src/values.ts
2
2
  var CSSStyleValue = class {};
3
3
  var CSSUnitValue = class extends CSSStyleValue {
4
4
  value;
@@ -40,5 +40,4 @@ const CSS = {
40
40
  percent: unit("percent"),
41
41
  number: unit("number")
42
42
  };
43
- //#endregion
44
43
  export { CSS, CSSColorValue, CSSImageValue, CSSStyleValue, CSSUnitValue };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cssints/css-grammar",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Type-level and runtime recognizer of CSS values over mdn-data grammars (the engine of cssints)",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -24,7 +24,7 @@
24
24
  "dependencies": {
25
25
  "@mdn/browser-compat-data": "8.1.3",
26
26
  "browserslist": "4.29.1",
27
- "effect": "4.0.0"
27
+ "effect": "4.0.6"
28
28
  },
29
29
  "engines": {
30
30
  "node": ">=22"