Home / File/ style.js — svelte Source File

style.js — svelte Source File

Architecture documentation for style.js, a javascript file in the svelte codebase. 2 imports, 2 dependents.

File javascript Compiler Transformer 2 imports 2 dependents 15 functions

Entity Profile

Dependency Diagram

graph LR
  251e2338_f8b8_69b4_b2e5_29ee7decbfa6["style.js"]
  495501a4_a342_6a4d_ac11_e3e2fee8b218["errors.js"]
  251e2338_f8b8_69b4_b2e5_29ee7decbfa6 --> 495501a4_a342_6a4d_ac11_e3e2fee8b218
  a146f6ac_0088_8736_b6ce_318f9f115170["e"]
  251e2338_f8b8_69b4_b2e5_29ee7decbfa6 --> a146f6ac_0088_8736_b6ce_318f9f115170
  cc8de3ad_4bae_f883_44db_d90442053943["index.js"]
  cc8de3ad_4bae_f883_44db_d90442053943 --> 251e2338_f8b8_69b4_b2e5_29ee7decbfa6
  206889ff_1f9f_b6c1_d530_059d001e1cf4["element.js"]
  206889ff_1f9f_b6c1_d530_059d001e1cf4 --> 251e2338_f8b8_69b4_b2e5_29ee7decbfa6
  style 251e2338_f8b8_69b4_b2e5_29ee7decbfa6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/** @import { AST } from '#compiler' */
/** @import { Parser } from '../index.js' */
import * as e from '../../../errors.js';

const REGEX_MATCHER = /^[~^$*|]?=/;
const REGEX_CLOSING_BRACKET = /[\s\]]/;
const REGEX_ATTRIBUTE_FLAGS = /^[a-zA-Z]+/; // only `i` and `s` are valid today, but make it future-proof
const REGEX_COMBINATOR = /^(\+|~|>|\|\|)/;
const REGEX_PERCENTAGE = /^\d+(\.\d+)?%/;
const REGEX_NTH_OF =
	/^(even|odd|\+?(\d+|\d*n(\s*[+-]\s*\d+)?)|-\d*n(\s*\+\s*\d+))((?=\s*[,)])|\s+of\s+)/;
const REGEX_WHITESPACE_OR_COLON = /[\s:]/;
const REGEX_LEADING_HYPHEN_OR_DIGIT = /-?\d/;
const REGEX_VALID_IDENTIFIER_CHAR = /[a-zA-Z0-9_-]/;
const REGEX_UNICODE_SEQUENCE = /^\\[0-9a-fA-F]{1,6}(\r\n|\s)?/;
const REGEX_COMMENT_CLOSE = /\*\//;
const REGEX_HTML_COMMENT_CLOSE = /-->/;

/**
 * @param {Parser} parser
 * @param {number} start
 * @param {Array<AST.Attribute | AST.SpreadAttribute | AST.Directive | AST.AttachTag>} attributes
 * @returns {AST.CSS.StyleSheet}
 */
export default function read_style(parser, start, attributes) {
	const content_start = parser.index;
	const children = read_body(parser, (p) => p.match('</style') || p.index >= p.template.length);
	const content_end = parser.index;

	parser.eat('</style', true);
	parser.read(/^\s*>/);

	return {
		type: 'StyleSheet',
		start,
		end: parser.index,
		attributes,
		children,
		content: {
			start: content_start,
			end: content_end,
			styles: parser.template.slice(content_start, content_end),
			comment: null
		}
	};
}

/**
 * @param {Parser} parser
 * @param {(parser: Parser) => boolean} finished
 * @returns {Array<AST.CSS.Rule | AST.CSS.Atrule>}
 */
function read_body(parser, finished) {
	/** @type {Array<AST.CSS.Rule | AST.CSS.Atrule>} */
	const children = [];

	while ((allow_comment_or_whitespace(parser), !finished(parser))) {
		if (parser.match('@')) {
			children.push(read_at_rule(parser));
		} else {
// ... (578 more lines)

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does style.js do?
style.js is a source file in the svelte codebase, written in javascript. It belongs to the Compiler domain, Transformer subdomain.
What functions are defined in style.js?
style.js defines 15 function(s): allow_comment_or_whitespace, parse_stylesheet, read_at_rule, read_attribute_value, read_block, read_block_item, read_body, read_combinator, read_declaration, read_identifier, and 5 more.
What does style.js depend on?
style.js imports 2 module(s): e, errors.js.
What files import style.js?
style.js is imported by 2 file(s): element.js, index.js.
Where is style.js in the architecture?
style.js is located at packages/svelte/src/compiler/phases/1-parse/read/style.js (domain: Compiler, subdomain: Transformer, directory: packages/svelte/src/compiler/phases/1-parse/read).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free