From e0a56a921e768faf78a4164b74c0ec2bec9e5748 Mon Sep 17 00:00:00 2001 From: Adam Miller Date: Fri, 13 Apr 2018 13:21:21 -0700 Subject: [PATCH 1/6] feat: Enable root-level typedoc generation for the project. - All local types have been pulled out to the project directory. - Packages moved to /packages/@css-blocks for module name generation. - typedoc.js configuration file added. - packages/css-blocks => packages/@css-blocks/core - packages/webpack-plugin => packages/@css-blocks/webpack. - packages/glimmer-templates => packages/@css-blocks/glimmer. - packages/runtime/src/runtime.ts => packages/@css-blocks/runtime/src/index.ts. - yarn run docs will generate a typedoc site at /docs. - TODO: Uses pre-built forked version of typedoc-plugin-external-module-map. Remove when merged. --- packages/@css-blocks/broccoli/package.json | 4 +- packages/@css-blocks/broccoli/src/index.ts | 2 +- .../@css-blocks/core/src/Analyzer/Analysis.ts | 2 +- .../@css-blocks/core/src/Analyzer/Analyzer.ts | 2 +- .../core/src/Analyzer/ElementAnalysis.ts | 8 +- .../core/src/Analyzer/validations/index.ts | 2 +- .../property-conflict-validator.ts | 2 +- .../src/BlockCompiler/ConflictResolver.ts | 2 +- .../core/src/BlockCompiler/index.ts | 4 +- .../core/src/BlockParser/BlockFactory.ts | 4 +- .../core/src/BlockParser/BlockParser.ts | 2 +- .../assert-foreign-global-attribute.ts | 2 +- .../BlockParser/features/construct-block.ts | 4 +- .../features/disallow-important.ts | 2 +- .../src/BlockParser/features/discover-name.ts | 2 +- .../src/BlockParser/features/extend-block.ts | 2 +- .../BlockParser/features/global-attributes.ts | 2 +- .../BlockParser/features/implement-block.ts | 2 +- .../features/resolve-references.ts | 2 +- .../core/src/BlockSyntax/parseBlockDebug.ts | 2 +- .../core/src/BlockTree/Attribute.ts | 2 +- .../@css-blocks/core/src/BlockTree/Block.ts | 6 +- .../core/src/BlockTree/BlockClass.ts | 2 +- .../core/src/BlockTree/RulesetContainer.ts | 4 +- packages/@css-blocks/core/src/Plugin.ts | 50 +++++ .../src/TemplateRewriter/RewriteMapping.ts | 8 +- .../core/src/configuration/resolver.ts | 2 +- packages/@css-blocks/core/src/cssBlocks.ts | 33 +++ .../core/test/global-states-test.ts | 2 +- .../@css-blocks/core/test/importing-test.ts | 4 +- .../@css-blocks/core/test/opticss-test.ts | 4 +- .../@css-blocks/core/test/resolution-test.ts | 2 +- packages/@css-blocks/core/test/syntax-test.ts | 2 +- .../core/test/template-analysis-test.ts | 4 +- .../attribute-group-validator-test.ts | 2 +- .../attribute-parent-validator-test.ts | 2 +- .../validations/class-pairs-validator-test.ts | 2 +- .../property-conflict-validator-test.ts | 4 +- .../validations/root-class-validator-test.ts | 2 +- .../core/test/validations/validator-test.ts | 2 +- .../glimmer/src/ClassnamesHelperGenerator.ts | 13 +- .../glimmer/src/GlimmerImporter.ts | 4 + packages/@css-blocks/glimmer/src/Rewriter.ts | 6 + packages/@css-blocks/glimmer/src/project.ts | 5 + .../jsx/src/Analyzer/visitors/element.ts | 10 +- .../jsx/src/Analyzer/visitors/importer.ts | 4 +- packages/@css-blocks/jsx/src/options.ts | 4 + .../jsx/src/styleFunctions/index.ts | 4 +- .../@css-blocks/jsx/src/transformer/babel.ts | 12 +- .../jsx/src/transformer/classNameGenerator.ts | 17 +- .../@css-blocks/jsx/src/transformer/index.ts | 6 + .../jsx/src/utils/ExpressionReader.ts | 8 +- .../jsx/src/utils/isConsoleLogStatement.ts | 2 +- .../jsx/test/transformer/transformer-test.ts | 4 + packages/@css-blocks/webpack/src/Plugin.ts | 4 + packages/@css-blocks/webpack/src/loader.ts | 8 +- yarn.lock | 190 +++++++++++++++++- 57 files changed, 404 insertions(+), 90 deletions(-) create mode 100644 packages/@css-blocks/core/src/Plugin.ts create mode 100644 packages/@css-blocks/core/src/cssBlocks.ts diff --git a/packages/@css-blocks/broccoli/package.json b/packages/@css-blocks/broccoli/package.json index d30e6e7aa..6b88ed539 100644 --- a/packages/@css-blocks/broccoli/package.json +++ b/packages/@css-blocks/broccoli/package.json @@ -6,7 +6,7 @@ "author": "Adam Miller ", "license": "MIT", "keywords": [ - "css-blocks", + "@css-blocks/core", "css blocks", "broccoli-plugin" ], @@ -46,4 +46,4 @@ "recursive-readdir": "^2.2.2", "walk-sync": "^0.3.2" } -} \ No newline at end of file +} diff --git a/packages/@css-blocks/broccoli/src/index.ts b/packages/@css-blocks/broccoli/src/index.ts index c1b3e672a..27bbdbcf2 100644 --- a/packages/@css-blocks/broccoli/src/index.ts +++ b/packages/@css-blocks/broccoli/src/index.ts @@ -92,7 +92,7 @@ class BroccoliCSSBlocks extends BroccoliPlugin { // Run optimization and compute StyleMapping. let optimized = await optimizer.optimize(this.output); - let styleMapping = new StyleMapping(optimized.styleMapping, blocks, options, this.analyzer.analyses()); + let styleMapping = new StyleMapping(optimized.styleMapping, blocks, options, this.analyzer.analyses()); // Attach all computed data to our magic shared memory transport object... this.transport.mapping = styleMapping; diff --git a/packages/@css-blocks/core/src/Analyzer/Analysis.ts b/packages/@css-blocks/core/src/Analyzer/Analysis.ts index 4a04f4062..2d463aade 100644 --- a/packages/@css-blocks/core/src/Analyzer/Analysis.ts +++ b/packages/@css-blocks/core/src/Analyzer/Analysis.ts @@ -1,9 +1,9 @@ // tslint:disable-next-line:no-unused-variable Imported for Documentation link import { + isSourcePosition, POSITION_UNKNOWN, SourceLocation, SourcePosition, - isSourcePosition, } from "@opticss/element-analysis"; import { SerializedTemplateInfo, diff --git a/packages/@css-blocks/core/src/Analyzer/Analyzer.ts b/packages/@css-blocks/core/src/Analyzer/Analyzer.ts index 21331d7d9..3bcfad662 100644 --- a/packages/@css-blocks/core/src/Analyzer/Analyzer.ts +++ b/packages/@css-blocks/core/src/Analyzer/Analyzer.ts @@ -10,8 +10,8 @@ import { BlockFactory } from "../BlockParser"; import { Block, Style } from "../BlockTree"; import { Options, - ResolvedConfiguration, resolveConfiguration, + ResolvedConfiguration, } from "../configuration"; import { Analysis, SerializedAnalysis } from "./Analysis"; diff --git a/packages/@css-blocks/core/src/Analyzer/ElementAnalysis.ts b/packages/@css-blocks/core/src/Analyzer/ElementAnalysis.ts index 4845ac5c9..7f98cd209 100644 --- a/packages/@css-blocks/core/src/Analyzer/ElementAnalysis.ts +++ b/packages/@css-blocks/core/src/Analyzer/ElementAnalysis.ts @@ -4,14 +4,14 @@ import { AttributeValueChoiceOption, AttributeValueSet, AttributeValueSetItem, + attrValues, Element, + isConstant, POSITION_UNKNOWN, SourceLocation, Tagname, ValueAbsent, ValueConstant, - attrValues, - isConstant, } from "@opticss/element-analysis"; import { MultiMap, @@ -21,13 +21,13 @@ import { } from "@opticss/util"; import { - AttrValue, Attribute, + AttrValue, Block, BlockClass, - Style, isAttrValue, isBlockClass, + Style, } from "../BlockTree"; import { ResolvedConfiguration, diff --git a/packages/@css-blocks/core/src/Analyzer/validations/index.ts b/packages/@css-blocks/core/src/Analyzer/validations/index.ts index ae071096f..1c40361a2 100644 --- a/packages/@css-blocks/core/src/Analyzer/validations/index.ts +++ b/packages/@css-blocks/core/src/Analyzer/validations/index.ts @@ -5,12 +5,12 @@ import * as errors from "../../errors"; import { Analysis } from "../Analysis"; import { ElementAnalysis } from "../ElementAnalysis"; +import { Validator } from "./Validator"; import { attributeGroupValidator } from "./attribute-group-validator"; import { attributeParentValidator } from "./attribute-parent-validator"; import { classPairsValidator } from "./class-pairs-validator"; import { propertyConflictValidator } from "./property-conflict-validator"; import { rootClassValidator } from "./root-class-validator"; -import { Validator } from "./Validator"; export * from "./class-pairs-validator"; export * from "./root-class-validator"; diff --git a/packages/@css-blocks/core/src/Analyzer/validations/property-conflict-validator.ts b/packages/@css-blocks/core/src/Analyzer/validations/property-conflict-validator.ts index 2eec665eb..62ea1d823 100644 --- a/packages/@css-blocks/core/src/Analyzer/validations/property-conflict-validator.ts +++ b/packages/@css-blocks/core/src/Analyzer/validations/property-conflict-validator.ts @@ -1,4 +1,4 @@ -import { MultiMap, TwoKeyMultiMap, objectValues } from "@opticss/util"; +import { MultiMap, objectValues, TwoKeyMultiMap } from "@opticss/util"; import * as propParser from "css-property-parser"; import { postcss } from "opticss"; diff --git a/packages/@css-blocks/core/src/BlockCompiler/ConflictResolver.ts b/packages/@css-blocks/core/src/BlockCompiler/ConflictResolver.ts index 6f7402271..498c966a1 100644 --- a/packages/@css-blocks/core/src/BlockCompiler/ConflictResolver.ts +++ b/packages/@css-blocks/core/src/BlockCompiler/ConflictResolver.ts @@ -4,10 +4,10 @@ import { CompoundSelector, ParsedSelector, parseSelector, postcss, postcssSelect import { getBlockNode } from "../BlockParser"; import { RESOLVE_RE } from "../BlockSyntax"; import { Block, Style } from "../BlockTree"; +import { SourceLocation, sourceLocation } from "../SourceLocation"; import { ResolvedConfiguration } from "../configuration"; import * as errors from "../errors"; import { QueryKeySelector } from "../query"; -import { SourceLocation, sourceLocation } from "../SourceLocation"; import { Conflicts, detectConflicts } from "./conflictDetection"; diff --git a/packages/@css-blocks/core/src/BlockCompiler/index.ts b/packages/@css-blocks/core/src/BlockCompiler/index.ts index 55963311e..6ed1c7611 100644 --- a/packages/@css-blocks/core/src/BlockCompiler/index.ts +++ b/packages/@css-blocks/core/src/BlockCompiler/index.ts @@ -6,14 +6,14 @@ import { BLOCK_DEBUG, BLOCK_PROP_NAMES_RE, BLOCK_REFERENCE, - ROOT_CLASS, parseBlockDebug, + ROOT_CLASS, } from "../BlockSyntax"; import { Block } from "../BlockTree"; import { Options, - ResolvedConfiguration, resolveConfiguration, + ResolvedConfiguration, } from "../configuration"; import { ConflictResolver } from "./ConflictResolver"; diff --git a/packages/@css-blocks/core/src/BlockParser/BlockFactory.ts b/packages/@css-blocks/core/src/BlockParser/BlockFactory.ts index 57c91f373..c6f073ab8 100644 --- a/packages/@css-blocks/core/src/BlockParser/BlockFactory.ts +++ b/packages/@css-blocks/core/src/BlockParser/BlockFactory.ts @@ -5,12 +5,12 @@ import * as path from "path"; import { RawSourceMap } from "source-map"; import { Block } from "../BlockTree"; -import { Options, ResolvedConfiguration, resolveConfiguration } from "../configuration"; +import { Options, resolveConfiguration, ResolvedConfiguration } from "../configuration"; import { FileIdentifier, ImportedFile, Importer } from "../importing"; import { PromiseQueue } from "../util/PromiseQueue"; import { BlockParser, ParsedSource } from "./BlockParser"; -import { Preprocessor, Preprocessors, ProcessedFile, Syntax, annotateCssContentWithSourceMap, syntaxName } from "./preprocessing"; +import { annotateCssContentWithSourceMap, Preprocessor, Preprocessors, ProcessedFile, Syntax, syntaxName } from "./preprocessing"; const debug = debugGenerator("css-blocks:BlockFactory"); diff --git a/packages/@css-blocks/core/src/BlockParser/BlockParser.ts b/packages/@css-blocks/core/src/BlockParser/BlockParser.ts index c60ba03e8..79191b87b 100644 --- a/packages/@css-blocks/core/src/BlockParser/BlockParser.ts +++ b/packages/@css-blocks/core/src/BlockParser/BlockParser.ts @@ -1,7 +1,7 @@ import { postcss } from "opticss"; import { Block } from "../BlockTree"; -import { Options, ResolvedConfiguration, resolveConfiguration } from "../configuration"; +import { Options, resolveConfiguration, ResolvedConfiguration } from "../configuration"; import * as errors from "../errors"; import { FileIdentifier } from "../importing"; diff --git a/packages/@css-blocks/core/src/BlockParser/features/assert-foreign-global-attribute.ts b/packages/@css-blocks/core/src/BlockParser/features/assert-foreign-global-attribute.ts index 719a5777a..49e31fc42 100644 --- a/packages/@css-blocks/core/src/BlockParser/features/assert-foreign-global-attribute.ts +++ b/packages/@css-blocks/core/src/BlockParser/features/assert-foreign-global-attribute.ts @@ -1,8 +1,8 @@ import { postcss } from "opticss"; import { Block } from "../../BlockTree"; -import * as errors from "../../errors"; import { selectorSourceLocation as loc } from "../../SourceLocation"; +import * as errors from "../../errors"; import { BlockType, getBlockNode, diff --git a/packages/@css-blocks/core/src/BlockParser/features/construct-block.ts b/packages/@css-blocks/core/src/BlockParser/features/construct-block.ts index a83d7350f..a520dbf60 100644 --- a/packages/@css-blocks/core/src/BlockParser/features/construct-block.ts +++ b/packages/@css-blocks/core/src/BlockParser/features/construct-block.ts @@ -2,12 +2,11 @@ import { assertNever } from "@opticss/util"; import { CompoundSelector, ParsedSelector, postcss, postcssSelectorParser as selectorParser } from "opticss"; import { Block, Style } from "../../BlockTree"; -import * as errors from "../../errors"; import { selectorSourceLocation as loc, sourceLocation } from "../../SourceLocation"; +import * as errors from "../../errors"; import { BlockNodeAndType, BlockType, - NodeAndType, blockTypeName, getBlockNode, isAttributeNode, @@ -15,6 +14,7 @@ import { isClassNode, isRootLevelObject, isRootNode, + NodeAndType, toAttrToken, } from "../block-intermediates"; diff --git a/packages/@css-blocks/core/src/BlockParser/features/disallow-important.ts b/packages/@css-blocks/core/src/BlockParser/features/disallow-important.ts index d3dcde6d6..c98588031 100644 --- a/packages/@css-blocks/core/src/BlockParser/features/disallow-important.ts +++ b/packages/@css-blocks/core/src/BlockParser/features/disallow-important.ts @@ -1,7 +1,7 @@ import { postcss } from "opticss"; -import * as errors from "../../errors"; import { sourceLocation as loc } from "../../SourceLocation"; +import * as errors from "../../errors"; export async function disallowImportant(root: postcss.Root, file: string): Promise { root.walkDecls((decl) => { diff --git a/packages/@css-blocks/core/src/BlockParser/features/discover-name.ts b/packages/@css-blocks/core/src/BlockParser/features/discover-name.ts index 8baeceaeb..acb1aaef2 100644 --- a/packages/@css-blocks/core/src/BlockParser/features/discover-name.ts +++ b/packages/@css-blocks/core/src/BlockParser/features/discover-name.ts @@ -1,8 +1,8 @@ import { postcss } from "opticss"; import { BLOCK_NAME, CLASS_NAME_IDENT } from "../../BlockSyntax"; -import * as errors from "../../errors"; import { sourceLocation } from "../../SourceLocation"; +import * as errors from "../../errors"; export async function discoverName(root: postcss.Root, defaultName: string, file: string): Promise { diff --git a/packages/@css-blocks/core/src/BlockParser/features/extend-block.ts b/packages/@css-blocks/core/src/BlockParser/features/extend-block.ts index 030d27075..2f4f1045d 100644 --- a/packages/@css-blocks/core/src/BlockParser/features/extend-block.ts +++ b/packages/@css-blocks/core/src/BlockParser/features/extend-block.ts @@ -2,8 +2,8 @@ import { postcss } from "opticss"; import { EXTENDS } from "../../BlockSyntax"; import { Block } from "../../BlockTree"; -import * as errors from "../../errors"; import { sourceLocation } from "../../SourceLocation"; +import * as errors from "../../errors"; /** * For each `extends` property found in the passed ruleset, set the block's base diff --git a/packages/@css-blocks/core/src/BlockParser/features/global-attributes.ts b/packages/@css-blocks/core/src/BlockParser/features/global-attributes.ts index bbb237535..82fd5f866 100644 --- a/packages/@css-blocks/core/src/BlockParser/features/global-attributes.ts +++ b/packages/@css-blocks/core/src/BlockParser/features/global-attributes.ts @@ -2,8 +2,8 @@ import { parseSelector, postcss, postcssSelectorParser as selectorParser } from import { BLOCK_GLOBAL } from "../../BlockSyntax"; import { Block } from "../../BlockTree"; -import * as errors from "../../errors"; import { sourceLocation as loc } from "../../SourceLocation"; +import * as errors from "../../errors"; import { toAttrToken } from "../block-intermediates"; export async function globalAttributes(root: postcss.Root, block: Block, file: string): Promise { diff --git a/packages/@css-blocks/core/src/BlockParser/features/implement-block.ts b/packages/@css-blocks/core/src/BlockParser/features/implement-block.ts index ab2812703..07119e82a 100644 --- a/packages/@css-blocks/core/src/BlockParser/features/implement-block.ts +++ b/packages/@css-blocks/core/src/BlockParser/features/implement-block.ts @@ -2,8 +2,8 @@ import { postcss } from "opticss"; import { IMPLEMENTS } from "../../BlockSyntax"; import { Block } from "../../BlockTree"; -import * as errors from "../../errors"; import { sourceLocation } from "../../SourceLocation"; +import * as errors from "../../errors"; /** * For each `implements` property found in the passed ruleset, track the foreign diff --git a/packages/@css-blocks/core/src/BlockParser/features/resolve-references.ts b/packages/@css-blocks/core/src/BlockParser/features/resolve-references.ts index 8292d2311..81f0c3158 100644 --- a/packages/@css-blocks/core/src/BlockParser/features/resolve-references.ts +++ b/packages/@css-blocks/core/src/BlockParser/features/resolve-references.ts @@ -3,8 +3,8 @@ import { postcss } from "opticss"; import { BLOCK_REFERENCE, CLASS_NAME_IDENT } from "../../BlockSyntax"; import { Block } from "../../BlockTree"; -import * as errors from "../../errors"; import { sourceLocation } from "../../SourceLocation"; +import * as errors from "../../errors"; import { BlockFactory } from "../index"; /** diff --git a/packages/@css-blocks/core/src/BlockSyntax/parseBlockDebug.ts b/packages/@css-blocks/core/src/BlockSyntax/parseBlockDebug.ts index 317943dfe..7404bd6e3 100644 --- a/packages/@css-blocks/core/src/BlockSyntax/parseBlockDebug.ts +++ b/packages/@css-blocks/core/src/BlockSyntax/parseBlockDebug.ts @@ -1,8 +1,8 @@ import { postcss } from "opticss"; import { Block } from "../BlockTree"; -import * as errors from "../errors"; import { sourceLocation } from "../SourceLocation"; +import * as errors from "../errors"; export type DebugChannel = "comment" | "stderr" | "stdout"; diff --git a/packages/@css-blocks/core/src/BlockTree/Attribute.ts b/packages/@css-blocks/core/src/BlockTree/Attribute.ts index cf2f16fba..4b06f4394 100644 --- a/packages/@css-blocks/core/src/BlockTree/Attribute.ts +++ b/packages/@css-blocks/core/src/BlockTree/Attribute.ts @@ -6,7 +6,7 @@ import { ValueAbsent, ValueConstant, } from "@opticss/element-analysis"; -import { ObjectDictionary, assertNever } from "@opticss/util"; +import { assertNever, ObjectDictionary } from "@opticss/util"; import { ATTR_PRESENT, IAttrToken as AttrToken } from "../BlockSyntax"; import { OutputMode, ResolvedConfiguration } from "../configuration"; diff --git a/packages/@css-blocks/core/src/BlockTree/Block.ts b/packages/@css-blocks/core/src/BlockTree/Block.ts index eef5092df..8cac23e12 100644 --- a/packages/@css-blocks/core/src/BlockTree/Block.ts +++ b/packages/@css-blocks/core/src/BlockTree/Block.ts @@ -1,4 +1,4 @@ -import { MultiMap, ObjectDictionary, assertNever } from "@opticss/util"; +import { assertNever, MultiMap, ObjectDictionary } from "@opticss/util"; import { whatever } from "@opticss/util"; import { CompoundSelector, @@ -10,16 +10,16 @@ import { import { BlockType, - NodeAndType, isAttributeNode, isClassNode, + NodeAndType, } from "../BlockParser"; import { isRootNode, toAttrToken } from "../BlockParser"; import { BlockPath, CLASS_NAME_IDENT, ROOT_CLASS } from "../BlockSyntax"; +import { SourceLocation } from "../SourceLocation"; import { ResolvedConfiguration } from "../configuration"; import { CssBlockError, InvalidBlockSyntax } from "../errors"; import { FileIdentifier } from "../importing"; -import { SourceLocation } from "../SourceLocation"; import { BlockClass } from "./BlockClass"; import { Inheritable } from "./Inheritable"; diff --git a/packages/@css-blocks/core/src/BlockTree/BlockClass.ts b/packages/@css-blocks/core/src/BlockTree/BlockClass.ts index be139c74e..8e954a1ea 100644 --- a/packages/@css-blocks/core/src/BlockTree/BlockClass.ts +++ b/packages/@css-blocks/core/src/BlockTree/BlockClass.ts @@ -6,8 +6,8 @@ import { ATTR_PRESENT, IAttrToken as AttrToken, ROOT_CLASS } from "../BlockSynta import { BlockPath } from "../BlockSyntax"; import { OutputMode, ResolvedConfiguration } from "../configuration"; -import { Attribute } from "./Attribute"; import { AttrValue } from "./AttrValue"; +import { Attribute } from "./Attribute"; import { Block } from "./Block"; import { RulesetContainer } from "./RulesetContainer"; import { Style } from "./Style"; diff --git a/packages/@css-blocks/core/src/BlockTree/RulesetContainer.ts b/packages/@css-blocks/core/src/BlockTree/RulesetContainer.ts index a174c9338..1d253b502 100644 --- a/packages/@css-blocks/core/src/BlockTree/RulesetContainer.ts +++ b/packages/@css-blocks/core/src/BlockTree/RulesetContainer.ts @@ -11,10 +11,10 @@ import * as propParser from "css-property-parser"; import { ParsedSelector, postcss } from "opticss"; import { BLOCK_PROP_NAMES, RESOLVE_RE, SELF_SELECTOR } from "../BlockSyntax"; -import { InvalidBlockSyntax } from "../errors"; import { sourceLocation } from "../SourceLocation"; +import { InvalidBlockSyntax } from "../errors"; -import { Styles, isStyle } from "./Styles"; +import { isStyle, Styles } from "./Styles"; export { Styles, BlockClass, AttrValue } from "./Styles"; // Convenience types to help our code read better. diff --git a/packages/@css-blocks/core/src/Plugin.ts b/packages/@css-blocks/core/src/Plugin.ts new file mode 100644 index 000000000..16c990fd8 --- /dev/null +++ b/packages/@css-blocks/core/src/Plugin.ts @@ -0,0 +1,50 @@ +import { postcss } from "opticss"; + +import { BlockCompiler } from "./BlockCompiler"; +import { BlockFactory } from "./BlockParser"; +import { Options, resolveConfiguration, ResolvedConfiguration } from "./configuration"; +import * as errors from "./errors"; + +/** + * CSS Blocks PostCSS plugin. + */ +export class Plugin { + private config: ResolvedConfiguration; + private postcss: typeof postcss; + + /** + * @param postcssImpl PostCSS instance to use + * @param opts Optional plugin config options + */ + constructor(postcssImpl: typeof postcss, opts?: Options) { + this.config = resolveConfiguration(opts); + this.postcss = postcssImpl; + } + + /** + * Main processing entrypoint for PostCSS Plugin + * @param root PostCSS AST + * @param result Provides the result of the PostCSS transformations + */ + public process(root: postcss.Root, result: postcss.Result) { + + // Fetch the CSS source file path. Throw if not present. + let sourceFile: string; + if (result && result.opts && result.opts.from) { + sourceFile = result.opts.from; + } else { + throw new errors.MissingSourcePath(); + } + + // Fetch block name from importer + let identifier = this.config.importer.identifier(null, sourceFile, this.config); + let defaultName: string = this.config.importer.defaultName(identifier, this.config); + let factory = new BlockFactory(this.config, this.postcss); + + return factory.parse(root, sourceFile, defaultName).then((block) => { + let compiler = new BlockCompiler(postcss, this.config); + compiler.compile(block, root); + }); + } + +} diff --git a/packages/@css-blocks/core/src/TemplateRewriter/RewriteMapping.ts b/packages/@css-blocks/core/src/TemplateRewriter/RewriteMapping.ts index 2293873fc..6a7363731 100644 --- a/packages/@css-blocks/core/src/TemplateRewriter/RewriteMapping.ts +++ b/packages/@css-blocks/core/src/TemplateRewriter/RewriteMapping.ts @@ -1,15 +1,15 @@ import { BooleanExpression, - RewriteMapping as OptimizedMapping, - SimpleAttribute, - SimpleTagname, isAndExpression, isBooleanExpression, isNotExpression, isOrExpression, isSimpleTagname, + RewriteMapping as OptimizedMapping, + SimpleAttribute, + SimpleTagname, } from "@opticss/template-api"; -import { Maybe, ObjectDictionary, assertNever, maybe, objectValues } from "@opticss/util"; +import { assertNever, Maybe, maybe, ObjectDictionary, objectValues } from "@opticss/util"; import { inspect } from "util"; import { Style } from "../BlockTree"; diff --git a/packages/@css-blocks/core/src/configuration/resolver.ts b/packages/@css-blocks/core/src/configuration/resolver.ts index 70965d89c..c59f1f37b 100644 --- a/packages/@css-blocks/core/src/configuration/resolver.ts +++ b/packages/@css-blocks/core/src/configuration/resolver.ts @@ -1,8 +1,8 @@ import { Preprocessors } from "../BlockParser"; import { + filesystemImporter, Importer, ImporterData, - filesystemImporter, } from "../importing"; import { OutputMode } from "./OutputMode"; diff --git a/packages/@css-blocks/core/src/cssBlocks.ts b/packages/@css-blocks/core/src/cssBlocks.ts new file mode 100644 index 000000000..4395d3e44 --- /dev/null +++ b/packages/@css-blocks/core/src/cssBlocks.ts @@ -0,0 +1,33 @@ +import { postcss } from "opticss"; + +import { Plugin } from "./Plugin"; +import { Configuration, OutputMode } from "./configuration"; +import { CssBlockError, InvalidBlockSyntax, MissingSourcePath } from "./errors"; + +// This is ugly but it's the only thing I have been able to make work. +// I welcome a patch that cleans this up. + +type temp = { + (postcssImpl: typeof postcss): (config?: Partial>) => postcss.Plugin>>; + OutputMode: typeof OutputMode; + CssBlockError: typeof CssBlockError; + InvalidBlockSyntax: typeof InvalidBlockSyntax; + MissingSourcePath: typeof MissingSourcePath; +}; + +function makeApi(): temp { + let cssBlocks: temp; + cssBlocks = function(postcssImpl: typeof postcss) { + return (config?: Partial>) => { + let plugin = new Plugin(postcssImpl, config); + return plugin.process.bind(plugin); + }; + }; + cssBlocks.OutputMode = OutputMode; + cssBlocks.CssBlockError = CssBlockError; + cssBlocks.InvalidBlockSyntax = InvalidBlockSyntax; + cssBlocks.MissingSourcePath = MissingSourcePath; + return cssBlocks; +} + +export = makeApi(); diff --git a/packages/@css-blocks/core/test/global-states-test.ts b/packages/@css-blocks/core/test/global-states-test.ts index 4993694d7..228f6e30e 100644 --- a/packages/@css-blocks/core/test/global-states-test.ts +++ b/packages/@css-blocks/core/test/global-states-test.ts @@ -3,8 +3,8 @@ import { suite, test } from "mocha-typescript"; import cssBlocks = require("./util/postcss-helper"); -import { assertError } from "./util/assertError"; import { BEMProcessor } from "./util/BEMProcessor"; +import { assertError } from "./util/assertError"; import { setupImporting } from "./util/setupImporting"; @suite("Resolves conflicts") diff --git a/packages/@css-blocks/core/test/importing-test.ts b/packages/@css-blocks/core/test/importing-test.ts index ce9b504fb..06d12ce6a 100644 --- a/packages/@css-blocks/core/test/importing-test.ts +++ b/packages/@css-blocks/core/test/importing-test.ts @@ -6,13 +6,13 @@ import * as path from "path"; import { Syntax } from "../src/BlockParser"; import { Options, - ResolvedConfiguration, resolveConfiguration, + ResolvedConfiguration, } from "../src/configuration"; import { + filesystemImporter, Importer, PathAliasImporter, - filesystemImporter, } from "../src/importing"; const FIXTURES = path.resolve(__dirname, "..", "..", "test", "fixtures"); diff --git a/packages/@css-blocks/core/test/opticss-test.ts b/packages/@css-blocks/core/test/opticss-test.ts index 81e625590..00d533cce 100644 --- a/packages/@css-blocks/core/test/opticss-test.ts +++ b/packages/@css-blocks/core/test/opticss-test.ts @@ -2,8 +2,8 @@ import { POSITION_UNKNOWN, } from "@opticss/element-analysis"; import { - Template, isAndExpression, + Template, } from "@opticss/template-api"; import { clean, @@ -18,8 +18,8 @@ import { Analysis, Analyzer } from "../src/Analyzer"; import { ElementAnalysis } from "../src/Analyzer"; import { BlockCompiler } from "../src/BlockCompiler"; import { AttrValue, Block, BlockClass } from "../src/BlockTree"; -import { resolveConfiguration } from "../src/configuration"; import { StyleMapping } from "../src/TemplateRewriter/StyleMapping"; +import { resolveConfiguration } from "../src/configuration"; @suite("Optimization") export class TemplateAnalysisTests { diff --git a/packages/@css-blocks/core/test/resolution-test.ts b/packages/@css-blocks/core/test/resolution-test.ts index 226864f2f..9e86b3f07 100644 --- a/packages/@css-blocks/core/test/resolution-test.ts +++ b/packages/@css-blocks/core/test/resolution-test.ts @@ -3,8 +3,8 @@ import { skip, suite, test } from "mocha-typescript"; import cssBlocks = require("./util/postcss-helper"); -import { assertError } from "./util/assertError"; import { BEMProcessor } from "./util/BEMProcessor"; +import { assertError } from "./util/assertError"; import { setupImporting } from "./util/setupImporting"; @suite("Resolves conflicts") diff --git a/packages/@css-blocks/core/test/syntax-test.ts b/packages/@css-blocks/core/test/syntax-test.ts index 75104a72e..3ac565c9b 100644 --- a/packages/@css-blocks/core/test/syntax-test.ts +++ b/packages/@css-blocks/core/test/syntax-test.ts @@ -3,9 +3,9 @@ import { skip, suite, test } from "mocha-typescript"; import cssBlocks = require("./util/postcss-helper"); -import { assertError } from "./util/assertError"; import { BEMProcessor } from "./util/BEMProcessor"; import { MockImportRegistry } from "./util/MockImportRegistry"; +import { assertError } from "./util/assertError"; @suite("In BEM output mode") export class BEMOutputMode extends BEMProcessor { diff --git a/packages/@css-blocks/core/test/template-analysis-test.ts b/packages/@css-blocks/core/test/template-analysis-test.ts index b00348262..78e70b663 100644 --- a/packages/@css-blocks/core/test/template-analysis-test.ts +++ b/packages/@css-blocks/core/test/template-analysis-test.ts @@ -6,13 +6,13 @@ import { postcss } from "opticss"; import { ElementAnalysis, SerializedAnalysis } from "../src/Analyzer"; import { BlockFactory } from "../src/BlockParser"; -import { AttrValue, Attribute, Block, BlockClass } from "../src/BlockTree"; +import { Attribute, AttrValue, Block, BlockClass } from "../src/BlockTree"; import { Options, resolveConfiguration } from "../src/configuration"; import * as cssBlocks from "../src/errors"; +import { TestAnalyzer } from "./util/TestAnalyzer"; import { assertParseError } from "./util/assertError"; import { setupImporting } from "./util/setupImporting"; -import { TestAnalyzer } from "./util/TestAnalyzer"; type TestElement = ElementAnalysis; type TemplateType = "Opticss.Template"; diff --git a/packages/@css-blocks/core/test/validations/attribute-group-validator-test.ts b/packages/@css-blocks/core/test/validations/attribute-group-validator-test.ts index b1978ef25..c6d2f7ae2 100644 --- a/packages/@css-blocks/core/test/validations/attribute-group-validator-test.ts +++ b/packages/@css-blocks/core/test/validations/attribute-group-validator-test.ts @@ -7,9 +7,9 @@ import { BlockFactory } from "../../src/BlockParser"; import { Block } from "../../src/BlockTree"; import { Options, resolveConfiguration } from "../../src/configuration"; import * as cssBlocks from "../../src/errors"; +import { TestAnalyzer } from "../util/TestAnalyzer"; import { assertParseError } from "../util/assertError"; import { setupImporting } from "../util/setupImporting"; -import { TestAnalyzer } from "../util/TestAnalyzer"; type BlockAndRoot = [Block, postcss.Container]; diff --git a/packages/@css-blocks/core/test/validations/attribute-parent-validator-test.ts b/packages/@css-blocks/core/test/validations/attribute-parent-validator-test.ts index 3d9a58d76..6a4f010c1 100644 --- a/packages/@css-blocks/core/test/validations/attribute-parent-validator-test.ts +++ b/packages/@css-blocks/core/test/validations/attribute-parent-validator-test.ts @@ -8,9 +8,9 @@ import { Block, BlockClass } from "../../src/BlockTree"; import { Options, resolveConfiguration } from "../../src/configuration"; import * as cssBlocks from "../../src/errors"; +import { TestAnalyzer } from "../util/TestAnalyzer"; import { assertParseError } from "../util/assertError"; import { setupImporting } from "../util/setupImporting"; -import { TestAnalyzer } from "../util/TestAnalyzer"; type BlockAndRoot = [Block, postcss.Container]; diff --git a/packages/@css-blocks/core/test/validations/class-pairs-validator-test.ts b/packages/@css-blocks/core/test/validations/class-pairs-validator-test.ts index eb088b823..e2d221b96 100644 --- a/packages/@css-blocks/core/test/validations/class-pairs-validator-test.ts +++ b/packages/@css-blocks/core/test/validations/class-pairs-validator-test.ts @@ -7,8 +7,8 @@ import { Block } from "../../src/BlockTree"; import { Options, resolveConfiguration } from "../../src/configuration"; import * as cssBlocks from "../../src/errors"; -import { assertParseError } from "../util/assertError"; import { TestAnalyzer } from "../util/TestAnalyzer"; +import { assertParseError } from "../util/assertError"; type BlockAndRoot = [Block, postcss.Container]; diff --git a/packages/@css-blocks/core/test/validations/property-conflict-validator-test.ts b/packages/@css-blocks/core/test/validations/property-conflict-validator-test.ts index c41225520..7c8d9a812 100644 --- a/packages/@css-blocks/core/test/validations/property-conflict-validator-test.ts +++ b/packages/@css-blocks/core/test/validations/property-conflict-validator-test.ts @@ -8,10 +8,10 @@ import { AttrValue, Block, BlockClass, isAttrValue, isBlockClass } from "../../s import { Options, resolveConfiguration } from "../../src/configuration"; import { CssBlockError, TemplateAnalysisError } from "../../src/errors"; -import { assertParseError } from "../util/assertError"; -import { indented } from "../util/indented"; import { MockImportRegistry } from "../util/MockImportRegistry"; import { TestAnalyzer } from "../util/TestAnalyzer"; +import { assertParseError } from "../util/assertError"; +import { indented } from "../util/indented"; type BlockAndRoot = [Block, postcss.Container]; diff --git a/packages/@css-blocks/core/test/validations/root-class-validator-test.ts b/packages/@css-blocks/core/test/validations/root-class-validator-test.ts index 1f0c6972c..d908fad02 100644 --- a/packages/@css-blocks/core/test/validations/root-class-validator-test.ts +++ b/packages/@css-blocks/core/test/validations/root-class-validator-test.ts @@ -9,9 +9,9 @@ import { Block } from "../../src/BlockTree"; import { Options, resolveConfiguration } from "../../src/configuration"; import * as cssBlocks from "../../src/errors"; -import { assertParseError } from "../util/assertError"; import { MockImportRegistry } from "../util/MockImportRegistry"; import { TestAnalyzer } from "../util/TestAnalyzer"; +import { assertParseError } from "../util/assertError"; type BlockAndRoot = [Block, postcss.Container]; diff --git a/packages/@css-blocks/core/test/validations/validator-test.ts b/packages/@css-blocks/core/test/validations/validator-test.ts index 117ba4a98..61b3cf576 100644 --- a/packages/@css-blocks/core/test/validations/validator-test.ts +++ b/packages/@css-blocks/core/test/validations/validator-test.ts @@ -8,8 +8,8 @@ import { Block } from "../../src/BlockTree"; import { Options, resolveConfiguration } from "../../src/configuration"; import { TemplateAnalysisError } from "../../src/errors"; -import { assertParseError } from "../util/assertError"; import { TestAnalyzer } from "../util/TestAnalyzer"; +import { assertParseError } from "../util/assertError"; type BlockAndRoot = [Block, postcss.Container]; diff --git a/packages/@css-blocks/glimmer/src/ClassnamesHelperGenerator.ts b/packages/@css-blocks/glimmer/src/ClassnamesHelperGenerator.ts index 4e0eb6f05..274cd52f6 100644 --- a/packages/@css-blocks/glimmer/src/ClassnamesHelperGenerator.ts +++ b/packages/@css-blocks/glimmer/src/ClassnamesHelperGenerator.ts @@ -6,17 +6,20 @@ import { Dependency, DynamicClasses, HasAttrValue, + hasDependency, HasGroup, IndexedClassRewrite, - NotExpression, - OrExpression, - Style, - Switch, - hasDependency, isConditional, isFalseCondition, isSwitch, isTrueCondition, +<<<<<<< HEAD:packages/@css-blocks/glimmer/src/ClassnamesHelperGenerator.ts +======= + NotExpression, + OrExpression, + Style, + Switch, +>>>>>>> feat: Enable root-level typedoc generation for the project.:packages/@css-blocks/glimmer/src/ClassnamesHelperGenerator.ts } from "@css-blocks/core"; import { AST, diff --git a/packages/@css-blocks/glimmer/src/GlimmerImporter.ts b/packages/@css-blocks/glimmer/src/GlimmerImporter.ts index 67420f4c8..e68289b1a 100644 --- a/packages/@css-blocks/glimmer/src/GlimmerImporter.ts +++ b/packages/@css-blocks/glimmer/src/GlimmerImporter.ts @@ -1,10 +1,14 @@ import { FileIdentifier, + filesystemImporter, ImportedFile, Importer, PathBasedImporter, ResolvedConfiguration as CSSBlocksConfiguration, +<<<<<<< HEAD:packages/@css-blocks/glimmer/src/GlimmerImporter.ts filesystemImporter, +======= +>>>>>>> feat: Enable root-level typedoc generation for the project.:packages/@css-blocks/glimmer/src/GlimmerImporter.ts } from "@css-blocks/core"; import * as path from "path"; diff --git a/packages/@css-blocks/glimmer/src/Rewriter.ts b/packages/@css-blocks/glimmer/src/Rewriter.ts index 8ff64f29a..b35a918dc 100644 --- a/packages/@css-blocks/glimmer/src/Rewriter.ts +++ b/packages/@css-blocks/glimmer/src/Rewriter.ts @@ -1,9 +1,15 @@ import { Block, Options as CSSBlocksOptions, +<<<<<<< HEAD:packages/@css-blocks/glimmer/src/Rewriter.ts ResolvedConfiguration as CSSBlocksConfiguration, StyleMapping, resolveConfiguration, +======= + resolveConfiguration, + ResolvedConfiguration as CSSBlocksConfiguration, + StyleMapping, +>>>>>>> feat: Enable root-level typedoc generation for the project.:packages/@css-blocks/glimmer/src/Rewriter.ts } from "@css-blocks/core"; import { AST, diff --git a/packages/@css-blocks/glimmer/src/project.ts b/packages/@css-blocks/glimmer/src/project.ts index 91ab8579b..5ecdb0b94 100644 --- a/packages/@css-blocks/glimmer/src/project.ts +++ b/packages/@css-blocks/glimmer/src/project.ts @@ -1,8 +1,13 @@ import { BlockFactory, Options as CSSBlocksOptions, +<<<<<<< HEAD:packages/@css-blocks/glimmer/src/project.ts ResolvedConfiguration, resolveConfiguration, +======= + resolveConfiguration, + ResolvedConfiguration, +>>>>>>> feat: Enable root-level typedoc generation for the project.:packages/@css-blocks/glimmer/src/project.ts } from "@css-blocks/core"; import * as fs from "fs"; import * as glob from "glob"; diff --git a/packages/@css-blocks/jsx/src/Analyzer/visitors/element.ts b/packages/@css-blocks/jsx/src/Analyzer/visitors/element.ts index 2572d9d95..00c785747 100644 --- a/packages/@css-blocks/jsx/src/Analyzer/visitors/element.ts +++ b/packages/@css-blocks/jsx/src/Analyzer/visitors/element.ts @@ -9,16 +9,16 @@ import { CallExpression, Expression, Identifier, - JSXAttribute, - JSXOpeningElement, - Node, - SourceLocation, isCallExpression, isIdentifier, isJSXExpressionContainer, isJSXIdentifier, isMemberExpression, isVariableDeclarator, + JSXAttribute, + JSXOpeningElement, + Node, + SourceLocation, } from "babel-types"; import { isCommonNameForStyling, isStyleFunction } from "../../styleFunctions"; @@ -26,8 +26,8 @@ import { MalformedBlockPath, TemplateAnalysisError } from "../../utils/Errors"; import { ExpressionReader, isBlockStateGroupResult, isBlockStateResult } from "../../utils/ExpressionReader"; import { isConsoleLogStatement } from "../../utils/isConsoleLogStatement"; -import { JSXAnalysis } from "../index"; import { TEMPLATE_TYPE } from "../Template"; +import { JSXAnalysis } from "../index"; import { BooleanExpression, Flags, JSXElementAnalysis, StringExpression, TernaryExpression } from "../types"; function htmlTagName(el: JSXOpeningElement): string | undefined { return (isJSXIdentifier(el.name) && el.name.name === el.name.name.toLowerCase()) ? el.name.name : undefined; } diff --git a/packages/@css-blocks/jsx/src/Analyzer/visitors/importer.ts b/packages/@css-blocks/jsx/src/Analyzer/visitors/importer.ts index 3678ac1ff..e15a47056 100644 --- a/packages/@css-blocks/jsx/src/Analyzer/visitors/importer.ts +++ b/packages/@css-blocks/jsx/src/Analyzer/visitors/importer.ts @@ -8,12 +8,12 @@ import { ClassDeclaration, Function, ImportDeclaration, - VariableDeclaration, - VariableDeclarator, isIdentifier, isImportDefaultSpecifier, isImportNamespaceSpecifier, isImportSpecifier, + VariableDeclaration, + VariableDeclarator, } from "babel-types"; import * as debugGenerator from "debug"; diff --git a/packages/@css-blocks/jsx/src/options.ts b/packages/@css-blocks/jsx/src/options.ts index 20d4cea89..205199893 100644 --- a/packages/@css-blocks/jsx/src/options.ts +++ b/packages/@css-blocks/jsx/src/options.ts @@ -1,4 +1,8 @@ +<<<<<<< HEAD:packages/@css-blocks/jsx/src/options.ts import { ResolvedConfiguration, resolveConfiguration } from "@css-blocks/core"; +======= +import { resolveConfiguration, ResolvedConfiguration } from "@css-blocks/core"; +>>>>>>> feat: Enable root-level typedoc generation for the project.:packages/@css-blocks/jsx/src/options.ts import { ObjectDictionary } from "@opticss/util"; /** diff --git a/packages/@css-blocks/jsx/src/styleFunctions/index.ts b/packages/@css-blocks/jsx/src/styleFunctions/index.ts index d37bd3706..36923a7f0 100644 --- a/packages/@css-blocks/jsx/src/styleFunctions/index.ts +++ b/packages/@css-blocks/jsx/src/styleFunctions/index.ts @@ -1,14 +1,14 @@ import { Binding, NodePath } from "babel-traverse"; import { CallExpression, - Node, isIdentifier, isImportDeclaration, + Node, } from "babel-types"; import { ErrorLocation } from "../utils/Errors"; -import { COMMON_NAMES as COMMON_OBJSTR_NAMES, ObjStrStyleFunction, objstrFn } from "./objstrFunction"; +import { COMMON_NAMES as COMMON_OBJSTR_NAMES, objstrFn, ObjStrStyleFunction } from "./objstrFunction"; export type StyleFunction = ObjStrStyleFunction; diff --git a/packages/@css-blocks/jsx/src/transformer/babel.ts b/packages/@css-blocks/jsx/src/transformer/babel.ts index f8571e9f5..f7232d4a5 100644 --- a/packages/@css-blocks/jsx/src/transformer/babel.ts +++ b/packages/@css-blocks/jsx/src/transformer/babel.ts @@ -9,19 +9,19 @@ import { AssignmentExpression, Expression, Identifier, - ImportDeclaration, - JSXAttribute, - JSXOpeningElement, - Node, - Statement, identifier, + ImportDeclaration, importDeclaration, importDefaultSpecifier, isIdentifier, isJSXExpressionContainer, + JSXAttribute, jSXAttribute, jSXExpressionContainer, jSXIdentifier, + JSXOpeningElement, + Node, + Statement, stringLiteral, } from "babel-types"; // import { TemplateAnalysisError } from '../utils/Errors'; @@ -32,7 +32,7 @@ import { JSXElementAnalyzer } from "../Analyzer/visitors/element"; import { isBlockFilename } from "../utils/isBlockFilename"; import { isConsoleLogStatement } from "../utils/isConsoleLogStatement"; -import { HELPER_FN_NAME, classnamesHelper as generateClassName } from "./classNameGenerator"; +import { classnamesHelper as generateClassName, HELPER_FN_NAME } from "./classNameGenerator"; import { CSSBlocksJSXTransformer as Rewriter } from "./index"; const debug = debugGenerator("css-blocks:jsx:rewriter"); diff --git a/packages/@css-blocks/jsx/src/transformer/classNameGenerator.ts b/packages/@css-blocks/jsx/src/transformer/classNameGenerator.ts index 04d3b59e8..6ec88329c 100644 --- a/packages/@css-blocks/jsx/src/transformer/classNameGenerator.ts +++ b/packages/@css-blocks/jsx/src/transformer/classNameGenerator.ts @@ -6,6 +6,7 @@ import { Dependency, DynamicClasses, HasAttrValue, +<<<<<<< HEAD:packages/@css-blocks/jsx/src/transformer/classNameGenerator.ts HasGroup, IndexedClassRewrite, NotExpression, @@ -13,10 +14,22 @@ import { Style, Switch, hasDependency, +======= + hasDependency, + HasGroup, + IndexedClassRewrite, +>>>>>>> feat: Enable root-level typedoc generation for the project.:packages/@css-blocks/jsx/src/transformer/classNameGenerator.ts isConditional, isFalseCondition, isSwitch, isTrueCondition, +<<<<<<< HEAD:packages/@css-blocks/jsx/src/transformer/classNameGenerator.ts +======= + NotExpression, + OrExpression, + Style, + Switch, +>>>>>>> feat: Enable root-level typedoc generation for the project.:packages/@css-blocks/jsx/src/transformer/classNameGenerator.ts } from "@css-blocks/core"; import { isAndExpression, @@ -29,10 +42,10 @@ import { unwrap, } from "@opticss/util"; import { - CallExpression, - Expression, arrayExpression, + CallExpression, callExpression, + Expression, identifier, nullLiteral, numericLiteral, diff --git a/packages/@css-blocks/jsx/src/transformer/index.ts b/packages/@css-blocks/jsx/src/transformer/index.ts index 426669345..89d100522 100644 --- a/packages/@css-blocks/jsx/src/transformer/index.ts +++ b/packages/@css-blocks/jsx/src/transformer/index.ts @@ -1,8 +1,14 @@ import { Options as CSSBlocksOptions, +<<<<<<< HEAD:packages/@css-blocks/jsx/src/transformer/index.ts ResolvedConfiguration, StyleMapping, resolveConfiguration, +======= + resolveConfiguration, + ResolvedConfiguration, + StyleMapping, +>>>>>>> feat: Enable root-level typedoc generation for the project.:packages/@css-blocks/jsx/src/transformer/index.ts } from "@css-blocks/core"; import { ObjectDictionary, whatever } from "@opticss/util"; diff --git a/packages/@css-blocks/jsx/src/utils/ExpressionReader.ts b/packages/@css-blocks/jsx/src/utils/ExpressionReader.ts index 78ec5497e..9673c4090 100644 --- a/packages/@css-blocks/jsx/src/utils/ExpressionReader.ts +++ b/packages/@css-blocks/jsx/src/utils/ExpressionReader.ts @@ -1,11 +1,13 @@ +<<<<<<< HEAD:packages/@css-blocks/jsx/src/utils/ExpressionReader.ts import { AttrValue, Attribute, Block, BlockClass, isBlockClass } from "@css-blocks/core"; +======= +import { Attribute, AttrValue, Block, BlockClass, isBlockClass } from "@css-blocks/core"; +>>>>>>> feat: Enable root-level typedoc generation for the project.:packages/@css-blocks/jsx/src/utils/ExpressionReader.ts import { Node } from "babel-traverse"; import { BooleanLiteral, CallExpression, Expression, - NumericLiteral, - StringLiteral, isBooleanLiteral, isCallExpression, isIdentifier, @@ -14,6 +16,8 @@ import { isMemberExpression, isNumericLiteral, isStringLiteral, + NumericLiteral, + StringLiteral, } from "babel-types"; import * as debugGenerator from "debug"; diff --git a/packages/@css-blocks/jsx/src/utils/isConsoleLogStatement.ts b/packages/@css-blocks/jsx/src/utils/isConsoleLogStatement.ts index 62adb13a6..fdc595572 100644 --- a/packages/@css-blocks/jsx/src/utils/isConsoleLogStatement.ts +++ b/packages/@css-blocks/jsx/src/utils/isConsoleLogStatement.ts @@ -1,8 +1,8 @@ import { - Node, isCallExpression, isIdentifier, isMemberExpression, + Node, } from "babel-types"; export function isConsoleLogStatement(node: Node): boolean { diff --git a/packages/@css-blocks/jsx/test/transformer/transformer-test.ts b/packages/@css-blocks/jsx/test/transformer/transformer-test.ts index dfe3b4e71..fc7c332d5 100644 --- a/packages/@css-blocks/jsx/test/transformer/transformer-test.ts +++ b/packages/@css-blocks/jsx/test/transformer/transformer-test.ts @@ -2,7 +2,11 @@ import c$$ from "@css-blocks/runtime"; import { TemplateIntegrationOptions } from "@opticss/template-api"; import { Analysis } from "@css-blocks/core"; +<<<<<<< HEAD:packages/@css-blocks/jsx/test/transformer/transformer-test.ts import { BlockCompiler, Options as CSSBlocksOptions, StyleMapping, resolveConfiguration as resolveBlocksConfiguration } from "@css-blocks/core"; +======= +import { BlockCompiler, Options as CSSBlocksOptions, resolveConfiguration as resolveBlocksConfiguration, StyleMapping } from "@css-blocks/core"; +>>>>>>> feat: Enable root-level typedoc generation for the project.:packages/@css-blocks/jsx/test/transformer/transformer-test.ts import * as babel from "babel-core"; import { assert } from "chai"; import { skip, suite, test } from "mocha-typescript"; diff --git a/packages/@css-blocks/webpack/src/Plugin.ts b/packages/@css-blocks/webpack/src/Plugin.ts index 80aa4baba..6c26a839f 100644 --- a/packages/@css-blocks/webpack/src/Plugin.ts +++ b/packages/@css-blocks/webpack/src/Plugin.ts @@ -14,8 +14,12 @@ import { Block, BlockCompiler, Options as CSSBlocksOptions, + resolveConfiguration, StyleMapping, +<<<<<<< HEAD:packages/@css-blocks/webpack/src/Plugin.ts resolveConfiguration, +======= +>>>>>>> feat: Enable root-level typedoc generation for the project.:packages/@css-blocks/webpack/src/Plugin.ts } from "@css-blocks/core"; import { Actions, diff --git a/packages/@css-blocks/webpack/src/loader.ts b/packages/@css-blocks/webpack/src/loader.ts index be50cf7a9..dc54cb301 100644 --- a/packages/@css-blocks/webpack/src/loader.ts +++ b/packages/@css-blocks/webpack/src/loader.ts @@ -1,15 +1,21 @@ import { Block, +<<<<<<< HEAD:packages/@css-blocks/webpack/src/loader.ts ResolvedConfiguration, StyleMapping, resolveConfiguration, +======= + resolveConfiguration, + ResolvedConfiguration, + StyleMapping, +>>>>>>> feat: Enable root-level typedoc generation for the project.:packages/@css-blocks/webpack/src/loader.ts } from "@css-blocks/core"; import * as debugGenerator from "debug"; import * as loaderUtils from "loader-utils"; const debug = debugGenerator("css-blocks:webpack:loader"); -import { LoaderContext } from "./context"; import { PendingResult, TmpType } from "./Plugin"; +import { LoaderContext } from "./context"; /** * The css-blocks loader makes css-blocks available to webpack modules. diff --git a/yarn.lock b/yarn.lock index 45956baa7..7732fc037 100644 --- a/yarn.lock +++ b/yarn.lock @@ -125,6 +125,7 @@ find-up "^2.1.0" "@glimmer/compiler@^0.33.0": +<<<<<<< HEAD version "0.33.6" resolved "https://registry.npmjs.org/@glimmer/compiler/-/compiler-0.33.6.tgz#bb5948a7035f13a2c8406abffa89504d1a98ac51" dependencies: @@ -132,6 +133,15 @@ "@glimmer/syntax" "^0.33.6" "@glimmer/util" "^0.33.6" "@glimmer/wire-format" "^0.33.6" +======= + version "0.33.4" + resolved "https://registry.npmjs.org/@glimmer/compiler/-/compiler-0.33.4.tgz#9fa1a604c5313b0b281b5351620a82e6b5e34f51" + dependencies: + "@glimmer/interfaces" "^0.33.4" + "@glimmer/syntax" "^0.33.4" + "@glimmer/util" "^0.33.4" + "@glimmer/wire-format" "^0.33.4" +>>>>>>> feat: Enable root-level typedoc generation for the project. "@glimmer/di@^0.2.0": version "0.2.0" @@ -143,11 +153,19 @@ dependencies: "@glimmer/wire-format" "^0.29.10" +<<<<<<< HEAD "@glimmer/interfaces@^0.33.6": version "0.33.6" resolved "https://registry.npmjs.org/@glimmer/interfaces/-/interfaces-0.33.6.tgz#876edf185cfcde9a40ad087df18ad35a48735451" dependencies: "@glimmer/wire-format" "^0.33.6" +======= +"@glimmer/interfaces@^0.33.4": + version "0.33.4" + resolved "https://registry.npmjs.org/@glimmer/interfaces/-/interfaces-0.33.4.tgz#80783552d4d8b567f78ddbc3273e751fe263006b" + dependencies: + "@glimmer/wire-format" "^0.33.4" +>>>>>>> feat: Enable root-level typedoc generation for the project. "@glimmer/resolution-map-builder@0.5.1": version "0.5.1" @@ -186,12 +204,21 @@ handlebars "^4.0.6" simple-html-tokenizer "^0.4.1" +<<<<<<< HEAD "@glimmer/syntax@^0.33.0", "@glimmer/syntax@^0.33.6": version "0.33.6" resolved "https://registry.npmjs.org/@glimmer/syntax/-/syntax-0.33.6.tgz#1a1839c5f3b80333a86bba110c2af649df41a917" dependencies: "@glimmer/interfaces" "^0.33.6" "@glimmer/util" "^0.33.6" +======= +"@glimmer/syntax@^0.33.0", "@glimmer/syntax@^0.33.4": + version "0.33.4" + resolved "https://registry.npmjs.org/@glimmer/syntax/-/syntax-0.33.4.tgz#ac824e0ccad3fd4cb9bf05d7cf6b5a9fbd8b195e" + dependencies: + "@glimmer/interfaces" "^0.33.4" + "@glimmer/util" "^0.33.4" +>>>>>>> feat: Enable root-level typedoc generation for the project. handlebars "^4.0.6" simple-html-tokenizer "^0.5.0" @@ -199,9 +226,15 @@ version "0.29.10" resolved "https://registry.npmjs.org/@glimmer/util/-/util-0.29.10.tgz#8662daf273ffef9254b8d943d39aa396ed7225a5" +<<<<<<< HEAD "@glimmer/util@^0.33.6": version "0.33.6" resolved "https://registry.npmjs.org/@glimmer/util/-/util-0.33.6.tgz#cd8186286baa08ab5b754a1f49a385c312c72da0" +======= +"@glimmer/util@^0.33.4": + version "0.33.4" + resolved "https://registry.npmjs.org/@glimmer/util/-/util-0.33.4.tgz#3aaabcad5cf04195917553510d2128fdce3208eb" +>>>>>>> feat: Enable root-level typedoc generation for the project. "@glimmer/wire-format@^0.29.10": version "0.29.10" @@ -209,11 +242,19 @@ dependencies: "@glimmer/util" "^0.29.10" +<<<<<<< HEAD "@glimmer/wire-format@^0.33.6": version "0.33.6" resolved "https://registry.npmjs.org/@glimmer/wire-format/-/wire-format-0.33.6.tgz#51eb651528572c23eba4601770529fa8c21f5303" dependencies: "@glimmer/util" "^0.33.6" +======= +"@glimmer/wire-format@^0.33.4": + version "0.33.4" + resolved "https://registry.npmjs.org/@glimmer/wire-format/-/wire-format-0.33.4.tgz#782d8bc02cb0f6261b5711cef007d907831f15d5" + dependencies: + "@glimmer/util" "^0.33.4" +>>>>>>> feat: Enable root-level typedoc generation for the project. "@marionebl/sander@^0.6.0": version "0.6.1" @@ -236,7 +277,11 @@ dependencies: "@opticss/element-analysis" "file:../../Library/Caches/Yarn/v1/npm-@opticss/element-analysis" "@opticss/util" "file:../../Library/Caches/Yarn/v1/npm-@opticss/util" +<<<<<<< HEAD postcss "^6.0.21" +======= + postcss "^6.0.12" +>>>>>>> feat: Enable root-level typedoc generation for the project. typescript-collections "^1.2.5" "@opticss/util@file:../opticss/packages/util": @@ -359,16 +404,26 @@ resolved "https://registry.npmjs.org/@types/mocha/-/mocha-2.2.48.tgz#3523b126a0b049482e1c3c11877460f76622ffab" "@types/node@*": +<<<<<<< HEAD version "9.6.6" resolved "https://registry.npmjs.org/@types/node/-/node-9.6.6.tgz#439b91f9caf3983cad2eef1e11f6bedcbf9431d2" "@types/node@^8.0.0": version "8.10.9" resolved "https://registry.npmjs.org/@types/node/-/node-8.10.9.tgz#b507a74a7d3eddc74a17dc35fd40d8f45dde0d6c" +======= + version "9.6.5" + resolved "https://registry.npmjs.org/@types/node/-/node-9.6.5.tgz#ee700810fdf49ac1c399fc5980b7559b3e5a381d" + +"@types/node@^8.0.0": + version "8.10.8" + resolved "https://registry.npmjs.org/@types/node/-/node-8.10.8.tgz#794cba23cc9f8d9715f6543fa8827433b5f5cd3b" +>>>>>>> feat: Enable root-level typedoc generation for the project. "@types/prettier@^1.8.0": version "1.12.0" resolved "https://registry.npmjs.org/@types/prettier/-/prettier-1.12.0.tgz#61ed6bdc64386f49c9e1f179cf84ef26ddc4740c" +<<<<<<< HEAD "@types/recursive-readdir@^2.2.0": version "2.2.0" @@ -376,6 +431,15 @@ dependencies: "@types/node" "*" +======= + +"@types/recursive-readdir@^2.2.0": + version "2.2.0" + resolved "https://registry.npmjs.org/@types/recursive-readdir/-/recursive-readdir-2.2.0.tgz#b39cd5474fd58ea727fe434d5c68b7a20ba9121c" + dependencies: + "@types/node" "*" + +>>>>>>> feat: Enable root-level typedoc generation for the project. "@types/shelljs@0.7.8": version "0.7.8" resolved "https://registry.npmjs.org/@types/shelljs/-/shelljs-0.7.8.tgz#4b4d6ee7926e58d7bca448a50ba442fd9f6715bd" @@ -388,8 +452,13 @@ resolved "https://registry.npmjs.org/@types/source-list-map/-/source-list-map-0.1.2.tgz#0078836063ffaf17412349bba364087e0ac02ec9" "@types/tapable@*": +<<<<<<< HEAD version "1.0.2" resolved "https://registry.npmjs.org/@types/tapable/-/tapable-1.0.2.tgz#e13182e1b69871a422d7863e11a4a6f5b814a4bd" +======= + version "1.0.1" + resolved "https://registry.npmjs.org/@types/tapable/-/tapable-1.0.1.tgz#938bfcc018eda2f386c34e37f084e6e961c08ca6" +>>>>>>> feat: Enable root-level typedoc generation for the project. "@types/tapable@0.2.4": version "0.2.4" @@ -935,10 +1004,13 @@ broccoli-merge-trees@^3.0.0: broccoli-plugin "^1.3.0" merge-trees "^2.0.0" +<<<<<<< HEAD broccoli-node-info@1.1.0: version "1.1.0" resolved "https://registry.npmjs.org/broccoli-node-info/-/broccoli-node-info-1.1.0.tgz#3aa2e31e07e5bdb516dd25214f7c45ba1c459412" +======= +>>>>>>> feat: Enable root-level typedoc generation for the project. broccoli-plugin@^1.3.0: version "1.3.0" resolved "https://registry.npmjs.org/broccoli-plugin/-/broccoli-plugin-1.3.0.tgz#bee704a8e42da08cb58e513aaa436efb7f0ef1ee" @@ -1054,12 +1126,15 @@ browserslist@^1.3.6, browserslist@^1.5.2, browserslist@^1.7.6: caniuse-db "^1.0.30000639" electron-to-chromium "^1.2.7" +<<<<<<< HEAD bser@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/bser/-/bser-2.0.0.tgz#9ac78d3ed5d915804fd87acb158bc797147a1719" dependencies: node-int64 "^0.4.0" +======= +>>>>>>> feat: Enable root-level typedoc generation for the project. buffer-from@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/buffer-from/-/buffer-from-1.0.0.tgz#4cb8832d23612589b0406e9e2956c17f06fdf531" @@ -1165,8 +1240,13 @@ caniuse-api@^1.5.2: lodash.uniq "^4.5.0" caniuse-db@^1.0.30000529, caniuse-db@^1.0.30000634, caniuse-db@^1.0.30000639: +<<<<<<< HEAD version "1.0.30000830" resolved "https://registry.npmjs.org/caniuse-db/-/caniuse-db-1.0.30000830.tgz#6e45255b345649fd15ff59072da1e12bb3de2f13" +======= + version "1.0.30000828" + resolved "https://registry.npmjs.org/caniuse-db/-/caniuse-db-1.0.30000828.tgz#ed6d6f03b5a81fb291c3c0e088828b11a70948bf" +>>>>>>> feat: Enable root-level typedoc generation for the project. capture-stack-trace@^1.0.0: version "1.0.0" @@ -1210,8 +1290,13 @@ chalk@^1.0.0, chalk@^1.1.3: supports-color "^2.0.0" chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.3.0, chalk@^2.3.2: +<<<<<<< HEAD version "2.4.0" resolved "https://registry.npmjs.org/chalk/-/chalk-2.4.0.tgz#a060a297a6b57e15b61ca63ce84995daa0fe6e52" +======= + version "2.3.2" + resolved "https://registry.npmjs.org/chalk/-/chalk-2.3.2.tgz#250dc96b07491bfd601e648d66ddf5f60c7a5c65" +>>>>>>> feat: Enable root-level typedoc generation for the project. dependencies: ansi-styles "^3.2.1" escape-string-regexp "^1.0.5" @@ -1402,7 +1487,11 @@ commander@2.9.0: dependencies: graceful-readlink ">= 1.0.0" +<<<<<<< HEAD commander@^2.12.1, commander@^2.5.0: +======= +commander@^2.12.1: +>>>>>>> feat: Enable root-level typedoc generation for the project. version "2.15.1" resolved "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz#df46e867d0fc2aec66a34662b406a9ccafff5b0f" @@ -1477,11 +1566,19 @@ conventional-changelog-atom@^0.2.8: q "^1.5.1" conventional-changelog-cli@^1.3.13: +<<<<<<< HEAD version "1.3.22" resolved "https://registry.npmjs.org/conventional-changelog-cli/-/conventional-changelog-cli-1.3.22.tgz#13570fe1728f56f013ff7a88878ff49d5162a405" dependencies: add-stream "^1.0.0" conventional-changelog "^1.1.24" +======= + version "1.3.21" + resolved "https://registry.npmjs.org/conventional-changelog-cli/-/conventional-changelog-cli-1.3.21.tgz#f6b063102ba34c0f2bec552249ee233e0762e0a4" + dependencies: + add-stream "^1.0.0" + conventional-changelog "^1.1.23" +>>>>>>> feat: Enable root-level typedoc generation for the project. lodash "^4.2.1" meow "^4.0.0" tempfile "^1.1.1" @@ -1492,9 +1589,15 @@ conventional-changelog-codemirror@^0.3.8: dependencies: q "^1.5.1" +<<<<<<< HEAD conventional-changelog-core@^2.0.11: version "2.0.11" resolved "https://registry.npmjs.org/conventional-changelog-core/-/conventional-changelog-core-2.0.11.tgz#19b5fbd55a9697773ed6661f4e32030ed7e30287" +======= +conventional-changelog-core@^2.0.10: + version "2.0.10" + resolved "https://registry.npmjs.org/conventional-changelog-core/-/conventional-changelog-core-2.0.10.tgz#3e47565ef9d148bcdceab6de6b3651a16dd28dc8" +>>>>>>> feat: Enable root-level typedoc generation for the project. dependencies: conventional-changelog-writer "^3.0.9" conventional-commits-parser "^2.1.7" @@ -1510,9 +1613,15 @@ conventional-changelog-core@^2.0.11: read-pkg-up "^1.0.1" through2 "^2.0.0" +<<<<<<< HEAD conventional-changelog-ember@^0.3.12: version "0.3.12" resolved "https://registry.npmjs.org/conventional-changelog-ember/-/conventional-changelog-ember-0.3.12.tgz#b7d31851756d0fcb49b031dffeb6afa93b202400" +======= +conventional-changelog-ember@^0.3.11: + version "0.3.11" + resolved "https://registry.npmjs.org/conventional-changelog-ember/-/conventional-changelog-ember-0.3.11.tgz#56ca9b418ee9d7f089bea34307d57497420d72a6" +>>>>>>> feat: Enable root-level typedoc generation for the project. dependencies: q "^1.5.1" @@ -1566,15 +1675,26 @@ conventional-changelog-writer@^3.0.9: split "^1.0.0" through2 "^2.0.0" +<<<<<<< HEAD conventional-changelog@^1.1.24: version "1.1.24" resolved "https://registry.npmjs.org/conventional-changelog/-/conventional-changelog-1.1.24.tgz#3d94c29c960f5261c002678315b756cdd3d7d1f0" +======= +conventional-changelog@^1.1.23: + version "1.1.23" + resolved "https://registry.npmjs.org/conventional-changelog/-/conventional-changelog-1.1.23.tgz#4ac72af8b9ea9af260e97acf556c19d8b2da970e" +>>>>>>> feat: Enable root-level typedoc generation for the project. dependencies: conventional-changelog-angular "^1.6.6" conventional-changelog-atom "^0.2.8" conventional-changelog-codemirror "^0.3.8" +<<<<<<< HEAD conventional-changelog-core "^2.0.11" conventional-changelog-ember "^0.3.12" +======= + conventional-changelog-core "^2.0.10" + conventional-changelog-ember "^0.3.11" +>>>>>>> feat: Enable root-level typedoc generation for the project. conventional-changelog-eslint "^1.0.9" conventional-changelog-express "^0.3.6" conventional-changelog-jquery "^0.1.0" @@ -1753,10 +1873,6 @@ cssesc@^0.1.0: version "0.1.0" resolved "https://registry.npmjs.org/cssesc/-/cssesc-0.1.0.tgz#c814903e45623371a0477b40109aaafbeeaddbb4" -cssesc@^1.0.1: - version "1.0.1" - resolved "https://registry.npmjs.org/cssesc/-/cssesc-1.0.1.tgz#ef7bd8d0229ed6a3a7051ff7771265fe7330e0a8" - cssnano@^3.10.0: version "3.10.0" resolved "https://registry.npmjs.org/cssnano/-/cssnano-3.10.0.tgz#4f38f6cea2b9b17fa01490f23f1dc68ea65c1c38" @@ -1992,6 +2108,12 @@ dot-prop@^3.0.0: dependencies: is-obj "^1.0.0" +dot-prop@^4.1.1: + version "4.2.0" + resolved "https://registry.npmjs.org/dot-prop/-/dot-prop-4.2.0.tgz#1f19e0c2e1aa0e32797c49799f2837ac6af69c57" + dependencies: + is-obj "^1.0.0" + duplexer2@0.0.2: version "0.0.2" resolved "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz#c614dcf67e2fb14995a91711e5a617e8a60a31db" @@ -2471,6 +2593,7 @@ fragment-cache@^0.2.1: dependencies: map-cache "^0.2.2" +<<<<<<< HEAD fs-exists-sync@^0.1.0: version "0.1.0" resolved "https://registry.npmjs.org/fs-exists-sync/-/fs-exists-sync-0.1.0.tgz#982d6893af918e72d08dec9e8673ff2b5a8d6add" @@ -2485,6 +2608,8 @@ fs-extra@^0.30.0: path-is-absolute "^1.0.0" rimraf "^2.2.8" +======= +>>>>>>> feat: Enable root-level typedoc generation for the project. fs-extra@^3.0.1: version "3.0.1" resolved "https://registry.npmjs.org/fs-extra/-/fs-extra-3.0.1.tgz#3794f378c58b342ea7dbbb23095109c4b3b62291" @@ -2509,7 +2634,11 @@ fs-extra@^5.0.0: jsonfile "^4.0.0" universalify "^0.1.0" +<<<<<<< HEAD fs-tree-diff@^0.5.3, fs-tree-diff@^0.5.6: +======= +fs-tree-diff@^0.5.3: +>>>>>>> feat: Enable root-level typedoc generation for the project. version "0.5.7" resolved "https://registry.npmjs.org/fs-tree-diff/-/fs-tree-diff-0.5.7.tgz#315e2b098d5fe7f622880ac965b1b051868ac871" dependencies: @@ -3525,8 +3654,13 @@ lcid@^1.0.0: invert-kv "^1.0.0" lerna@^2.5.1: +<<<<<<< HEAD version "2.10.2" resolved "https://registry.npmjs.org/lerna/-/lerna-2.10.2.tgz#3a0d54d398360fecc5918207c6d7ab68a5443d9f" +======= + version "2.10.1" + resolved "https://registry.npmjs.org/lerna/-/lerna-2.10.1.tgz#3b0ffe6b80d3312e8efdc7003a50d47d90ebdf03" +>>>>>>> feat: Enable root-level typedoc generation for the project. dependencies: async "^1.5.0" chalk "^2.1.0" @@ -4084,8 +4218,13 @@ modify-values@^1.0.0: resolved "https://registry.npmjs.org/modify-values/-/modify-values-1.0.1.tgz#b3939fa605546474e3e3e3c63d64bd43b4ee6022" moment@^2.6.0: +<<<<<<< HEAD version "2.22.1" resolved "https://registry.npmjs.org/moment/-/moment-2.22.1.tgz#529a2e9bf973f259c9643d237fda84de3a26e8ad" +======= + version "2.22.0" + resolved "https://registry.npmjs.org/moment/-/moment-2.22.0.tgz#7921ade01017dd45186e7fee5f424f0b8663a730" +>>>>>>> feat: Enable root-level typedoc generation for the project. moo@^0.4.1: version "0.4.3" @@ -4142,10 +4281,13 @@ neo-async@^2.5.0: next-tick@1: version "1.0.0" resolved "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz#ca86d1fe8828169b0120208e3dc8424b9db8342c" +<<<<<<< HEAD node-int64@^0.4.0: version "0.4.0" resolved "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b" +======= +>>>>>>> feat: Enable root-level typedoc generation for the project. node-libs-browser@^2.0.0: version "2.1.0" @@ -4351,8 +4493,13 @@ onetime@^2.0.0: css-property-parser "^1.0.5" debug "^2.6.8" object.values "^1.0.4" +<<<<<<< HEAD postcss "^6.0.21" postcss-selector-parser "^4.0.0-rc.1" +======= + postcss "^6.0.12" + postcss-selector-parser "^3.1.1" +>>>>>>> feat: Enable root-level typedoc generation for the project. source-map "^0.6.1" specificity "^0.3.2" typescript-collections "^1.2.5" @@ -4797,19 +4944,25 @@ postcss-scss@^0.3.0: dependencies: postcss "^5.2.4" -postcss-selector-parser@^2.0.0, postcss-selector-parser@^2.2.2: - version "2.2.3" - resolved "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-2.2.3.tgz#f9437788606c3c9acee16ffe8d8b16297f27bb90" +postcss-selector-parser@3.1.1, postcss-selector-parser@^3.1.1: + version "3.1.1" + resolved "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-3.1.1.tgz#4f875f4afb0c96573d5cf4d74011aee250a7e865" dependencies: - flatten "^1.0.2" + dot-prop "^4.1.1" indexes-of "^1.0.1" uniq "^1.0.1" +<<<<<<< HEAD postcss-selector-parser@^4.0.0-rc.1: version "4.0.0-rc.1" resolved "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-4.0.0-rc.1.tgz#e32edb8a8f3ca8300cb20b9207b15ef41b760f88" +======= +postcss-selector-parser@^2.0.0, postcss-selector-parser@^2.2.2: + version "2.2.3" + resolved "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-2.2.3.tgz#f9437788606c3c9acee16ffe8d8b16297f27bb90" +>>>>>>> feat: Enable root-level typedoc generation for the project. dependencies: - cssesc "^1.0.1" + flatten "^1.0.2" indexes-of "^1.0.1" uniq "^1.0.1" @@ -4851,7 +5004,11 @@ postcss@^5.0.10, postcss@^5.0.11, postcss@^5.0.12, postcss@^5.0.13, postcss@^5.0 source-map "^0.5.6" supports-color "^3.2.3" +<<<<<<< HEAD postcss@^6.0.1, postcss@^6.0.21: +======= +postcss@^6.0.1, postcss@^6.0.12, postcss@^6.0.14, postcss@^6.0.21: +>>>>>>> feat: Enable root-level typedoc generation for the project. version "6.0.21" resolved "https://registry.npmjs.org/postcss/-/postcss-6.0.21.tgz#8265662694eddf9e9a5960db6da33c39e4cd069d" dependencies: @@ -4876,8 +5033,13 @@ preserve@^0.2.0: resolved "https://registry.npmjs.org/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" prettier@^1.8.2: +<<<<<<< HEAD version "1.12.1" resolved "https://registry.npmjs.org/prettier/-/prettier-1.12.1.tgz#c1ad20e803e7749faf905a409d2367e06bbe7325" +======= + version "1.12.0" + resolved "https://registry.npmjs.org/prettier/-/prettier-1.12.0.tgz#d26fc5894b9230de97629b39cae225b503724ce8" +>>>>>>> feat: Enable root-level typedoc generation for the project. private@^0.1.7: version "0.1.8" @@ -5366,7 +5528,11 @@ right-align@^0.1.1: dependencies: align-text "^0.1.1" +<<<<<<< HEAD rimraf@2, rimraf@^2.2.8, rimraf@^2.3.4, rimraf@^2.4.3, rimraf@^2.5.1, rimraf@^2.5.2, rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.2: +======= +rimraf@2, rimraf@^2.3.4, rimraf@^2.4.3, rimraf@^2.5.1, rimraf@^2.5.2, rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.2: +>>>>>>> feat: Enable root-level typedoc generation for the project. version "2.6.2" resolved "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36" dependencies: @@ -5417,6 +5583,7 @@ safer-buffer@^2.1.0: version "2.1.2" resolved "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" +<<<<<<< HEAD sane@^1.4.1: version "1.7.0" resolved "https://registry.npmjs.org/sane/-/sane-1.7.0.tgz#b3579bccb45c94cf20355cc81124990dfd346e30" @@ -5429,6 +5596,8 @@ sane@^1.4.1: walker "~1.0.5" watch "~0.10.0" +======= +>>>>>>> feat: Enable root-level typedoc generation for the project. sax@~1.2.1: version "1.2.4" resolved "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" @@ -5948,12 +6117,15 @@ tmp@0.0.28: dependencies: os-tmpdir "~1.0.1" +<<<<<<< HEAD tmp@0.0.31: version "0.0.31" resolved "https://registry.npmjs.org/tmp/-/tmp-0.0.31.tgz#8f38ab9438e17315e5dbd8b3657e8bfb277ae4a7" dependencies: os-tmpdir "~1.0.1" +======= +>>>>>>> feat: Enable root-level typedoc generation for the project. tmp@^0.0.33: version "0.0.33" resolved "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" From 5bfb39041ea1c8a959cd5d3ad908f8f41b030a58 Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Sat, 14 Apr 2018 13:03:51 -0700 Subject: [PATCH 2/6] chore: Update lockfile. Organize imports. --- .../@css-blocks/core/src/Analyzer/Analysis.ts | 2 +- .../@css-blocks/core/src/Analyzer/Analyzer.ts | 2 +- .../core/src/Analyzer/ElementAnalysis.ts | 8 +- .../core/src/Analyzer/validations/index.ts | 2 +- .../property-conflict-validator.ts | 2 +- .../src/BlockCompiler/ConflictResolver.ts | 2 +- .../core/src/BlockCompiler/index.ts | 4 +- .../core/src/BlockParser/BlockFactory.ts | 4 +- .../core/src/BlockParser/BlockParser.ts | 2 +- .../assert-foreign-global-attribute.ts | 2 +- .../BlockParser/features/construct-block.ts | 4 +- .../features/disallow-important.ts | 2 +- .../src/BlockParser/features/discover-name.ts | 2 +- .../src/BlockParser/features/extend-block.ts | 2 +- .../BlockParser/features/global-attributes.ts | 2 +- .../BlockParser/features/implement-block.ts | 2 +- .../features/resolve-references.ts | 2 +- .../core/src/BlockSyntax/parseBlockDebug.ts | 2 +- .../core/src/BlockTree/Attribute.ts | 2 +- .../@css-blocks/core/src/BlockTree/Block.ts | 6 +- .../core/src/BlockTree/BlockClass.ts | 2 +- .../core/src/BlockTree/RulesetContainer.ts | 4 +- packages/@css-blocks/core/src/Plugin.ts | 2 +- .../src/TemplateRewriter/RewriteMapping.ts | 8 +- .../core/src/configuration/resolver.ts | 2 +- packages/@css-blocks/core/src/cssBlocks.ts | 2 +- .../core/test/global-states-test.ts | 2 +- .../@css-blocks/core/test/importing-test.ts | 4 +- .../@css-blocks/core/test/opticss-test.ts | 4 +- .../@css-blocks/core/test/resolution-test.ts | 2 +- packages/@css-blocks/core/test/syntax-test.ts | 2 +- .../core/test/template-analysis-test.ts | 4 +- .../attribute-group-validator-test.ts | 2 +- .../attribute-parent-validator-test.ts | 2 +- .../validations/class-pairs-validator-test.ts | 2 +- .../property-conflict-validator-test.ts | 4 +- .../validations/root-class-validator-test.ts | 2 +- .../core/test/validations/validator-test.ts | 2 +- .../glimmer/src/ClassnamesHelperGenerator.ts | 13 +- .../glimmer/src/GlimmerImporter.ts | 4 - packages/@css-blocks/glimmer/src/Rewriter.ts | 6 - packages/@css-blocks/glimmer/src/project.ts | 5 - .../jsx/src/Analyzer/visitors/element.ts | 10 +- .../jsx/src/Analyzer/visitors/importer.ts | 4 +- packages/@css-blocks/jsx/src/options.ts | 4 - .../jsx/src/styleFunctions/index.ts | 4 +- .../@css-blocks/jsx/src/transformer/babel.ts | 12 +- .../jsx/src/transformer/classNameGenerator.ts | 17 +- .../@css-blocks/jsx/src/transformer/index.ts | 6 - .../jsx/src/utils/ExpressionReader.ts | 8 +- .../jsx/src/utils/isConsoleLogStatement.ts | 2 +- .../jsx/test/transformer/transformer-test.ts | 5 +- packages/@css-blocks/webpack/src/Plugin.ts | 4 - packages/@css-blocks/webpack/src/loader.ts | 8 +- yarn.lock | 190 +----------------- 55 files changed, 90 insertions(+), 320 deletions(-) diff --git a/packages/@css-blocks/core/src/Analyzer/Analysis.ts b/packages/@css-blocks/core/src/Analyzer/Analysis.ts index 2d463aade..4a04f4062 100644 --- a/packages/@css-blocks/core/src/Analyzer/Analysis.ts +++ b/packages/@css-blocks/core/src/Analyzer/Analysis.ts @@ -1,9 +1,9 @@ // tslint:disable-next-line:no-unused-variable Imported for Documentation link import { - isSourcePosition, POSITION_UNKNOWN, SourceLocation, SourcePosition, + isSourcePosition, } from "@opticss/element-analysis"; import { SerializedTemplateInfo, diff --git a/packages/@css-blocks/core/src/Analyzer/Analyzer.ts b/packages/@css-blocks/core/src/Analyzer/Analyzer.ts index 3bcfad662..21331d7d9 100644 --- a/packages/@css-blocks/core/src/Analyzer/Analyzer.ts +++ b/packages/@css-blocks/core/src/Analyzer/Analyzer.ts @@ -10,8 +10,8 @@ import { BlockFactory } from "../BlockParser"; import { Block, Style } from "../BlockTree"; import { Options, - resolveConfiguration, ResolvedConfiguration, + resolveConfiguration, } from "../configuration"; import { Analysis, SerializedAnalysis } from "./Analysis"; diff --git a/packages/@css-blocks/core/src/Analyzer/ElementAnalysis.ts b/packages/@css-blocks/core/src/Analyzer/ElementAnalysis.ts index 7f98cd209..4845ac5c9 100644 --- a/packages/@css-blocks/core/src/Analyzer/ElementAnalysis.ts +++ b/packages/@css-blocks/core/src/Analyzer/ElementAnalysis.ts @@ -4,14 +4,14 @@ import { AttributeValueChoiceOption, AttributeValueSet, AttributeValueSetItem, - attrValues, Element, - isConstant, POSITION_UNKNOWN, SourceLocation, Tagname, ValueAbsent, ValueConstant, + attrValues, + isConstant, } from "@opticss/element-analysis"; import { MultiMap, @@ -21,13 +21,13 @@ import { } from "@opticss/util"; import { - Attribute, AttrValue, + Attribute, Block, BlockClass, + Style, isAttrValue, isBlockClass, - Style, } from "../BlockTree"; import { ResolvedConfiguration, diff --git a/packages/@css-blocks/core/src/Analyzer/validations/index.ts b/packages/@css-blocks/core/src/Analyzer/validations/index.ts index 1c40361a2..ae071096f 100644 --- a/packages/@css-blocks/core/src/Analyzer/validations/index.ts +++ b/packages/@css-blocks/core/src/Analyzer/validations/index.ts @@ -5,12 +5,12 @@ import * as errors from "../../errors"; import { Analysis } from "../Analysis"; import { ElementAnalysis } from "../ElementAnalysis"; -import { Validator } from "./Validator"; import { attributeGroupValidator } from "./attribute-group-validator"; import { attributeParentValidator } from "./attribute-parent-validator"; import { classPairsValidator } from "./class-pairs-validator"; import { propertyConflictValidator } from "./property-conflict-validator"; import { rootClassValidator } from "./root-class-validator"; +import { Validator } from "./Validator"; export * from "./class-pairs-validator"; export * from "./root-class-validator"; diff --git a/packages/@css-blocks/core/src/Analyzer/validations/property-conflict-validator.ts b/packages/@css-blocks/core/src/Analyzer/validations/property-conflict-validator.ts index 62ea1d823..2eec665eb 100644 --- a/packages/@css-blocks/core/src/Analyzer/validations/property-conflict-validator.ts +++ b/packages/@css-blocks/core/src/Analyzer/validations/property-conflict-validator.ts @@ -1,4 +1,4 @@ -import { MultiMap, objectValues, TwoKeyMultiMap } from "@opticss/util"; +import { MultiMap, TwoKeyMultiMap, objectValues } from "@opticss/util"; import * as propParser from "css-property-parser"; import { postcss } from "opticss"; diff --git a/packages/@css-blocks/core/src/BlockCompiler/ConflictResolver.ts b/packages/@css-blocks/core/src/BlockCompiler/ConflictResolver.ts index 498c966a1..6f7402271 100644 --- a/packages/@css-blocks/core/src/BlockCompiler/ConflictResolver.ts +++ b/packages/@css-blocks/core/src/BlockCompiler/ConflictResolver.ts @@ -4,10 +4,10 @@ import { CompoundSelector, ParsedSelector, parseSelector, postcss, postcssSelect import { getBlockNode } from "../BlockParser"; import { RESOLVE_RE } from "../BlockSyntax"; import { Block, Style } from "../BlockTree"; -import { SourceLocation, sourceLocation } from "../SourceLocation"; import { ResolvedConfiguration } from "../configuration"; import * as errors from "../errors"; import { QueryKeySelector } from "../query"; +import { SourceLocation, sourceLocation } from "../SourceLocation"; import { Conflicts, detectConflicts } from "./conflictDetection"; diff --git a/packages/@css-blocks/core/src/BlockCompiler/index.ts b/packages/@css-blocks/core/src/BlockCompiler/index.ts index 6ed1c7611..55963311e 100644 --- a/packages/@css-blocks/core/src/BlockCompiler/index.ts +++ b/packages/@css-blocks/core/src/BlockCompiler/index.ts @@ -6,14 +6,14 @@ import { BLOCK_DEBUG, BLOCK_PROP_NAMES_RE, BLOCK_REFERENCE, - parseBlockDebug, ROOT_CLASS, + parseBlockDebug, } from "../BlockSyntax"; import { Block } from "../BlockTree"; import { Options, - resolveConfiguration, ResolvedConfiguration, + resolveConfiguration, } from "../configuration"; import { ConflictResolver } from "./ConflictResolver"; diff --git a/packages/@css-blocks/core/src/BlockParser/BlockFactory.ts b/packages/@css-blocks/core/src/BlockParser/BlockFactory.ts index c6f073ab8..57c91f373 100644 --- a/packages/@css-blocks/core/src/BlockParser/BlockFactory.ts +++ b/packages/@css-blocks/core/src/BlockParser/BlockFactory.ts @@ -5,12 +5,12 @@ import * as path from "path"; import { RawSourceMap } from "source-map"; import { Block } from "../BlockTree"; -import { Options, resolveConfiguration, ResolvedConfiguration } from "../configuration"; +import { Options, ResolvedConfiguration, resolveConfiguration } from "../configuration"; import { FileIdentifier, ImportedFile, Importer } from "../importing"; import { PromiseQueue } from "../util/PromiseQueue"; import { BlockParser, ParsedSource } from "./BlockParser"; -import { annotateCssContentWithSourceMap, Preprocessor, Preprocessors, ProcessedFile, Syntax, syntaxName } from "./preprocessing"; +import { Preprocessor, Preprocessors, ProcessedFile, Syntax, annotateCssContentWithSourceMap, syntaxName } from "./preprocessing"; const debug = debugGenerator("css-blocks:BlockFactory"); diff --git a/packages/@css-blocks/core/src/BlockParser/BlockParser.ts b/packages/@css-blocks/core/src/BlockParser/BlockParser.ts index 79191b87b..c60ba03e8 100644 --- a/packages/@css-blocks/core/src/BlockParser/BlockParser.ts +++ b/packages/@css-blocks/core/src/BlockParser/BlockParser.ts @@ -1,7 +1,7 @@ import { postcss } from "opticss"; import { Block } from "../BlockTree"; -import { Options, resolveConfiguration, ResolvedConfiguration } from "../configuration"; +import { Options, ResolvedConfiguration, resolveConfiguration } from "../configuration"; import * as errors from "../errors"; import { FileIdentifier } from "../importing"; diff --git a/packages/@css-blocks/core/src/BlockParser/features/assert-foreign-global-attribute.ts b/packages/@css-blocks/core/src/BlockParser/features/assert-foreign-global-attribute.ts index 49e31fc42..719a5777a 100644 --- a/packages/@css-blocks/core/src/BlockParser/features/assert-foreign-global-attribute.ts +++ b/packages/@css-blocks/core/src/BlockParser/features/assert-foreign-global-attribute.ts @@ -1,8 +1,8 @@ import { postcss } from "opticss"; import { Block } from "../../BlockTree"; -import { selectorSourceLocation as loc } from "../../SourceLocation"; import * as errors from "../../errors"; +import { selectorSourceLocation as loc } from "../../SourceLocation"; import { BlockType, getBlockNode, diff --git a/packages/@css-blocks/core/src/BlockParser/features/construct-block.ts b/packages/@css-blocks/core/src/BlockParser/features/construct-block.ts index a520dbf60..a83d7350f 100644 --- a/packages/@css-blocks/core/src/BlockParser/features/construct-block.ts +++ b/packages/@css-blocks/core/src/BlockParser/features/construct-block.ts @@ -2,11 +2,12 @@ import { assertNever } from "@opticss/util"; import { CompoundSelector, ParsedSelector, postcss, postcssSelectorParser as selectorParser } from "opticss"; import { Block, Style } from "../../BlockTree"; -import { selectorSourceLocation as loc, sourceLocation } from "../../SourceLocation"; import * as errors from "../../errors"; +import { selectorSourceLocation as loc, sourceLocation } from "../../SourceLocation"; import { BlockNodeAndType, BlockType, + NodeAndType, blockTypeName, getBlockNode, isAttributeNode, @@ -14,7 +15,6 @@ import { isClassNode, isRootLevelObject, isRootNode, - NodeAndType, toAttrToken, } from "../block-intermediates"; diff --git a/packages/@css-blocks/core/src/BlockParser/features/disallow-important.ts b/packages/@css-blocks/core/src/BlockParser/features/disallow-important.ts index c98588031..d3dcde6d6 100644 --- a/packages/@css-blocks/core/src/BlockParser/features/disallow-important.ts +++ b/packages/@css-blocks/core/src/BlockParser/features/disallow-important.ts @@ -1,7 +1,7 @@ import { postcss } from "opticss"; -import { sourceLocation as loc } from "../../SourceLocation"; import * as errors from "../../errors"; +import { sourceLocation as loc } from "../../SourceLocation"; export async function disallowImportant(root: postcss.Root, file: string): Promise { root.walkDecls((decl) => { diff --git a/packages/@css-blocks/core/src/BlockParser/features/discover-name.ts b/packages/@css-blocks/core/src/BlockParser/features/discover-name.ts index acb1aaef2..8baeceaeb 100644 --- a/packages/@css-blocks/core/src/BlockParser/features/discover-name.ts +++ b/packages/@css-blocks/core/src/BlockParser/features/discover-name.ts @@ -1,8 +1,8 @@ import { postcss } from "opticss"; import { BLOCK_NAME, CLASS_NAME_IDENT } from "../../BlockSyntax"; -import { sourceLocation } from "../../SourceLocation"; import * as errors from "../../errors"; +import { sourceLocation } from "../../SourceLocation"; export async function discoverName(root: postcss.Root, defaultName: string, file: string): Promise { diff --git a/packages/@css-blocks/core/src/BlockParser/features/extend-block.ts b/packages/@css-blocks/core/src/BlockParser/features/extend-block.ts index 2f4f1045d..030d27075 100644 --- a/packages/@css-blocks/core/src/BlockParser/features/extend-block.ts +++ b/packages/@css-blocks/core/src/BlockParser/features/extend-block.ts @@ -2,8 +2,8 @@ import { postcss } from "opticss"; import { EXTENDS } from "../../BlockSyntax"; import { Block } from "../../BlockTree"; -import { sourceLocation } from "../../SourceLocation"; import * as errors from "../../errors"; +import { sourceLocation } from "../../SourceLocation"; /** * For each `extends` property found in the passed ruleset, set the block's base diff --git a/packages/@css-blocks/core/src/BlockParser/features/global-attributes.ts b/packages/@css-blocks/core/src/BlockParser/features/global-attributes.ts index 82fd5f866..bbb237535 100644 --- a/packages/@css-blocks/core/src/BlockParser/features/global-attributes.ts +++ b/packages/@css-blocks/core/src/BlockParser/features/global-attributes.ts @@ -2,8 +2,8 @@ import { parseSelector, postcss, postcssSelectorParser as selectorParser } from import { BLOCK_GLOBAL } from "../../BlockSyntax"; import { Block } from "../../BlockTree"; -import { sourceLocation as loc } from "../../SourceLocation"; import * as errors from "../../errors"; +import { sourceLocation as loc } from "../../SourceLocation"; import { toAttrToken } from "../block-intermediates"; export async function globalAttributes(root: postcss.Root, block: Block, file: string): Promise { diff --git a/packages/@css-blocks/core/src/BlockParser/features/implement-block.ts b/packages/@css-blocks/core/src/BlockParser/features/implement-block.ts index 07119e82a..ab2812703 100644 --- a/packages/@css-blocks/core/src/BlockParser/features/implement-block.ts +++ b/packages/@css-blocks/core/src/BlockParser/features/implement-block.ts @@ -2,8 +2,8 @@ import { postcss } from "opticss"; import { IMPLEMENTS } from "../../BlockSyntax"; import { Block } from "../../BlockTree"; -import { sourceLocation } from "../../SourceLocation"; import * as errors from "../../errors"; +import { sourceLocation } from "../../SourceLocation"; /** * For each `implements` property found in the passed ruleset, track the foreign diff --git a/packages/@css-blocks/core/src/BlockParser/features/resolve-references.ts b/packages/@css-blocks/core/src/BlockParser/features/resolve-references.ts index 81f0c3158..8292d2311 100644 --- a/packages/@css-blocks/core/src/BlockParser/features/resolve-references.ts +++ b/packages/@css-blocks/core/src/BlockParser/features/resolve-references.ts @@ -3,8 +3,8 @@ import { postcss } from "opticss"; import { BLOCK_REFERENCE, CLASS_NAME_IDENT } from "../../BlockSyntax"; import { Block } from "../../BlockTree"; -import { sourceLocation } from "../../SourceLocation"; import * as errors from "../../errors"; +import { sourceLocation } from "../../SourceLocation"; import { BlockFactory } from "../index"; /** diff --git a/packages/@css-blocks/core/src/BlockSyntax/parseBlockDebug.ts b/packages/@css-blocks/core/src/BlockSyntax/parseBlockDebug.ts index 7404bd6e3..317943dfe 100644 --- a/packages/@css-blocks/core/src/BlockSyntax/parseBlockDebug.ts +++ b/packages/@css-blocks/core/src/BlockSyntax/parseBlockDebug.ts @@ -1,8 +1,8 @@ import { postcss } from "opticss"; import { Block } from "../BlockTree"; -import { sourceLocation } from "../SourceLocation"; import * as errors from "../errors"; +import { sourceLocation } from "../SourceLocation"; export type DebugChannel = "comment" | "stderr" | "stdout"; diff --git a/packages/@css-blocks/core/src/BlockTree/Attribute.ts b/packages/@css-blocks/core/src/BlockTree/Attribute.ts index 4b06f4394..cf2f16fba 100644 --- a/packages/@css-blocks/core/src/BlockTree/Attribute.ts +++ b/packages/@css-blocks/core/src/BlockTree/Attribute.ts @@ -6,7 +6,7 @@ import { ValueAbsent, ValueConstant, } from "@opticss/element-analysis"; -import { assertNever, ObjectDictionary } from "@opticss/util"; +import { ObjectDictionary, assertNever } from "@opticss/util"; import { ATTR_PRESENT, IAttrToken as AttrToken } from "../BlockSyntax"; import { OutputMode, ResolvedConfiguration } from "../configuration"; diff --git a/packages/@css-blocks/core/src/BlockTree/Block.ts b/packages/@css-blocks/core/src/BlockTree/Block.ts index 8cac23e12..eef5092df 100644 --- a/packages/@css-blocks/core/src/BlockTree/Block.ts +++ b/packages/@css-blocks/core/src/BlockTree/Block.ts @@ -1,4 +1,4 @@ -import { assertNever, MultiMap, ObjectDictionary } from "@opticss/util"; +import { MultiMap, ObjectDictionary, assertNever } from "@opticss/util"; import { whatever } from "@opticss/util"; import { CompoundSelector, @@ -10,16 +10,16 @@ import { import { BlockType, + NodeAndType, isAttributeNode, isClassNode, - NodeAndType, } from "../BlockParser"; import { isRootNode, toAttrToken } from "../BlockParser"; import { BlockPath, CLASS_NAME_IDENT, ROOT_CLASS } from "../BlockSyntax"; -import { SourceLocation } from "../SourceLocation"; import { ResolvedConfiguration } from "../configuration"; import { CssBlockError, InvalidBlockSyntax } from "../errors"; import { FileIdentifier } from "../importing"; +import { SourceLocation } from "../SourceLocation"; import { BlockClass } from "./BlockClass"; import { Inheritable } from "./Inheritable"; diff --git a/packages/@css-blocks/core/src/BlockTree/BlockClass.ts b/packages/@css-blocks/core/src/BlockTree/BlockClass.ts index 8e954a1ea..be139c74e 100644 --- a/packages/@css-blocks/core/src/BlockTree/BlockClass.ts +++ b/packages/@css-blocks/core/src/BlockTree/BlockClass.ts @@ -6,8 +6,8 @@ import { ATTR_PRESENT, IAttrToken as AttrToken, ROOT_CLASS } from "../BlockSynta import { BlockPath } from "../BlockSyntax"; import { OutputMode, ResolvedConfiguration } from "../configuration"; -import { AttrValue } from "./AttrValue"; import { Attribute } from "./Attribute"; +import { AttrValue } from "./AttrValue"; import { Block } from "./Block"; import { RulesetContainer } from "./RulesetContainer"; import { Style } from "./Style"; diff --git a/packages/@css-blocks/core/src/BlockTree/RulesetContainer.ts b/packages/@css-blocks/core/src/BlockTree/RulesetContainer.ts index 1d253b502..a174c9338 100644 --- a/packages/@css-blocks/core/src/BlockTree/RulesetContainer.ts +++ b/packages/@css-blocks/core/src/BlockTree/RulesetContainer.ts @@ -11,10 +11,10 @@ import * as propParser from "css-property-parser"; import { ParsedSelector, postcss } from "opticss"; import { BLOCK_PROP_NAMES, RESOLVE_RE, SELF_SELECTOR } from "../BlockSyntax"; -import { sourceLocation } from "../SourceLocation"; import { InvalidBlockSyntax } from "../errors"; +import { sourceLocation } from "../SourceLocation"; -import { isStyle, Styles } from "./Styles"; +import { Styles, isStyle } from "./Styles"; export { Styles, BlockClass, AttrValue } from "./Styles"; // Convenience types to help our code read better. diff --git a/packages/@css-blocks/core/src/Plugin.ts b/packages/@css-blocks/core/src/Plugin.ts index 16c990fd8..80d9b6b9a 100644 --- a/packages/@css-blocks/core/src/Plugin.ts +++ b/packages/@css-blocks/core/src/Plugin.ts @@ -2,7 +2,7 @@ import { postcss } from "opticss"; import { BlockCompiler } from "./BlockCompiler"; import { BlockFactory } from "./BlockParser"; -import { Options, resolveConfiguration, ResolvedConfiguration } from "./configuration"; +import { Options, ResolvedConfiguration, resolveConfiguration } from "./configuration"; import * as errors from "./errors"; /** diff --git a/packages/@css-blocks/core/src/TemplateRewriter/RewriteMapping.ts b/packages/@css-blocks/core/src/TemplateRewriter/RewriteMapping.ts index 6a7363731..2293873fc 100644 --- a/packages/@css-blocks/core/src/TemplateRewriter/RewriteMapping.ts +++ b/packages/@css-blocks/core/src/TemplateRewriter/RewriteMapping.ts @@ -1,15 +1,15 @@ import { BooleanExpression, + RewriteMapping as OptimizedMapping, + SimpleAttribute, + SimpleTagname, isAndExpression, isBooleanExpression, isNotExpression, isOrExpression, isSimpleTagname, - RewriteMapping as OptimizedMapping, - SimpleAttribute, - SimpleTagname, } from "@opticss/template-api"; -import { assertNever, Maybe, maybe, ObjectDictionary, objectValues } from "@opticss/util"; +import { Maybe, ObjectDictionary, assertNever, maybe, objectValues } from "@opticss/util"; import { inspect } from "util"; import { Style } from "../BlockTree"; diff --git a/packages/@css-blocks/core/src/configuration/resolver.ts b/packages/@css-blocks/core/src/configuration/resolver.ts index c59f1f37b..70965d89c 100644 --- a/packages/@css-blocks/core/src/configuration/resolver.ts +++ b/packages/@css-blocks/core/src/configuration/resolver.ts @@ -1,8 +1,8 @@ import { Preprocessors } from "../BlockParser"; import { - filesystemImporter, Importer, ImporterData, + filesystemImporter, } from "../importing"; import { OutputMode } from "./OutputMode"; diff --git a/packages/@css-blocks/core/src/cssBlocks.ts b/packages/@css-blocks/core/src/cssBlocks.ts index 4395d3e44..07024b44c 100644 --- a/packages/@css-blocks/core/src/cssBlocks.ts +++ b/packages/@css-blocks/core/src/cssBlocks.ts @@ -1,8 +1,8 @@ import { postcss } from "opticss"; -import { Plugin } from "./Plugin"; import { Configuration, OutputMode } from "./configuration"; import { CssBlockError, InvalidBlockSyntax, MissingSourcePath } from "./errors"; +import { Plugin } from "./Plugin"; // This is ugly but it's the only thing I have been able to make work. // I welcome a patch that cleans this up. diff --git a/packages/@css-blocks/core/test/global-states-test.ts b/packages/@css-blocks/core/test/global-states-test.ts index 228f6e30e..4993694d7 100644 --- a/packages/@css-blocks/core/test/global-states-test.ts +++ b/packages/@css-blocks/core/test/global-states-test.ts @@ -3,8 +3,8 @@ import { suite, test } from "mocha-typescript"; import cssBlocks = require("./util/postcss-helper"); -import { BEMProcessor } from "./util/BEMProcessor"; import { assertError } from "./util/assertError"; +import { BEMProcessor } from "./util/BEMProcessor"; import { setupImporting } from "./util/setupImporting"; @suite("Resolves conflicts") diff --git a/packages/@css-blocks/core/test/importing-test.ts b/packages/@css-blocks/core/test/importing-test.ts index 06d12ce6a..ce9b504fb 100644 --- a/packages/@css-blocks/core/test/importing-test.ts +++ b/packages/@css-blocks/core/test/importing-test.ts @@ -6,13 +6,13 @@ import * as path from "path"; import { Syntax } from "../src/BlockParser"; import { Options, - resolveConfiguration, ResolvedConfiguration, + resolveConfiguration, } from "../src/configuration"; import { - filesystemImporter, Importer, PathAliasImporter, + filesystemImporter, } from "../src/importing"; const FIXTURES = path.resolve(__dirname, "..", "..", "test", "fixtures"); diff --git a/packages/@css-blocks/core/test/opticss-test.ts b/packages/@css-blocks/core/test/opticss-test.ts index 00d533cce..81e625590 100644 --- a/packages/@css-blocks/core/test/opticss-test.ts +++ b/packages/@css-blocks/core/test/opticss-test.ts @@ -2,8 +2,8 @@ import { POSITION_UNKNOWN, } from "@opticss/element-analysis"; import { - isAndExpression, Template, + isAndExpression, } from "@opticss/template-api"; import { clean, @@ -18,8 +18,8 @@ import { Analysis, Analyzer } from "../src/Analyzer"; import { ElementAnalysis } from "../src/Analyzer"; import { BlockCompiler } from "../src/BlockCompiler"; import { AttrValue, Block, BlockClass } from "../src/BlockTree"; -import { StyleMapping } from "../src/TemplateRewriter/StyleMapping"; import { resolveConfiguration } from "../src/configuration"; +import { StyleMapping } from "../src/TemplateRewriter/StyleMapping"; @suite("Optimization") export class TemplateAnalysisTests { diff --git a/packages/@css-blocks/core/test/resolution-test.ts b/packages/@css-blocks/core/test/resolution-test.ts index 9e86b3f07..226864f2f 100644 --- a/packages/@css-blocks/core/test/resolution-test.ts +++ b/packages/@css-blocks/core/test/resolution-test.ts @@ -3,8 +3,8 @@ import { skip, suite, test } from "mocha-typescript"; import cssBlocks = require("./util/postcss-helper"); -import { BEMProcessor } from "./util/BEMProcessor"; import { assertError } from "./util/assertError"; +import { BEMProcessor } from "./util/BEMProcessor"; import { setupImporting } from "./util/setupImporting"; @suite("Resolves conflicts") diff --git a/packages/@css-blocks/core/test/syntax-test.ts b/packages/@css-blocks/core/test/syntax-test.ts index 3ac565c9b..75104a72e 100644 --- a/packages/@css-blocks/core/test/syntax-test.ts +++ b/packages/@css-blocks/core/test/syntax-test.ts @@ -3,9 +3,9 @@ import { skip, suite, test } from "mocha-typescript"; import cssBlocks = require("./util/postcss-helper"); +import { assertError } from "./util/assertError"; import { BEMProcessor } from "./util/BEMProcessor"; import { MockImportRegistry } from "./util/MockImportRegistry"; -import { assertError } from "./util/assertError"; @suite("In BEM output mode") export class BEMOutputMode extends BEMProcessor { diff --git a/packages/@css-blocks/core/test/template-analysis-test.ts b/packages/@css-blocks/core/test/template-analysis-test.ts index 78e70b663..b00348262 100644 --- a/packages/@css-blocks/core/test/template-analysis-test.ts +++ b/packages/@css-blocks/core/test/template-analysis-test.ts @@ -6,13 +6,13 @@ import { postcss } from "opticss"; import { ElementAnalysis, SerializedAnalysis } from "../src/Analyzer"; import { BlockFactory } from "../src/BlockParser"; -import { Attribute, AttrValue, Block, BlockClass } from "../src/BlockTree"; +import { AttrValue, Attribute, Block, BlockClass } from "../src/BlockTree"; import { Options, resolveConfiguration } from "../src/configuration"; import * as cssBlocks from "../src/errors"; -import { TestAnalyzer } from "./util/TestAnalyzer"; import { assertParseError } from "./util/assertError"; import { setupImporting } from "./util/setupImporting"; +import { TestAnalyzer } from "./util/TestAnalyzer"; type TestElement = ElementAnalysis; type TemplateType = "Opticss.Template"; diff --git a/packages/@css-blocks/core/test/validations/attribute-group-validator-test.ts b/packages/@css-blocks/core/test/validations/attribute-group-validator-test.ts index c6d2f7ae2..b1978ef25 100644 --- a/packages/@css-blocks/core/test/validations/attribute-group-validator-test.ts +++ b/packages/@css-blocks/core/test/validations/attribute-group-validator-test.ts @@ -7,9 +7,9 @@ import { BlockFactory } from "../../src/BlockParser"; import { Block } from "../../src/BlockTree"; import { Options, resolveConfiguration } from "../../src/configuration"; import * as cssBlocks from "../../src/errors"; -import { TestAnalyzer } from "../util/TestAnalyzer"; import { assertParseError } from "../util/assertError"; import { setupImporting } from "../util/setupImporting"; +import { TestAnalyzer } from "../util/TestAnalyzer"; type BlockAndRoot = [Block, postcss.Container]; diff --git a/packages/@css-blocks/core/test/validations/attribute-parent-validator-test.ts b/packages/@css-blocks/core/test/validations/attribute-parent-validator-test.ts index 6a4f010c1..3d9a58d76 100644 --- a/packages/@css-blocks/core/test/validations/attribute-parent-validator-test.ts +++ b/packages/@css-blocks/core/test/validations/attribute-parent-validator-test.ts @@ -8,9 +8,9 @@ import { Block, BlockClass } from "../../src/BlockTree"; import { Options, resolveConfiguration } from "../../src/configuration"; import * as cssBlocks from "../../src/errors"; -import { TestAnalyzer } from "../util/TestAnalyzer"; import { assertParseError } from "../util/assertError"; import { setupImporting } from "../util/setupImporting"; +import { TestAnalyzer } from "../util/TestAnalyzer"; type BlockAndRoot = [Block, postcss.Container]; diff --git a/packages/@css-blocks/core/test/validations/class-pairs-validator-test.ts b/packages/@css-blocks/core/test/validations/class-pairs-validator-test.ts index e2d221b96..eb088b823 100644 --- a/packages/@css-blocks/core/test/validations/class-pairs-validator-test.ts +++ b/packages/@css-blocks/core/test/validations/class-pairs-validator-test.ts @@ -7,8 +7,8 @@ import { Block } from "../../src/BlockTree"; import { Options, resolveConfiguration } from "../../src/configuration"; import * as cssBlocks from "../../src/errors"; -import { TestAnalyzer } from "../util/TestAnalyzer"; import { assertParseError } from "../util/assertError"; +import { TestAnalyzer } from "../util/TestAnalyzer"; type BlockAndRoot = [Block, postcss.Container]; diff --git a/packages/@css-blocks/core/test/validations/property-conflict-validator-test.ts b/packages/@css-blocks/core/test/validations/property-conflict-validator-test.ts index 7c8d9a812..c41225520 100644 --- a/packages/@css-blocks/core/test/validations/property-conflict-validator-test.ts +++ b/packages/@css-blocks/core/test/validations/property-conflict-validator-test.ts @@ -8,10 +8,10 @@ import { AttrValue, Block, BlockClass, isAttrValue, isBlockClass } from "../../s import { Options, resolveConfiguration } from "../../src/configuration"; import { CssBlockError, TemplateAnalysisError } from "../../src/errors"; -import { MockImportRegistry } from "../util/MockImportRegistry"; -import { TestAnalyzer } from "../util/TestAnalyzer"; import { assertParseError } from "../util/assertError"; import { indented } from "../util/indented"; +import { MockImportRegistry } from "../util/MockImportRegistry"; +import { TestAnalyzer } from "../util/TestAnalyzer"; type BlockAndRoot = [Block, postcss.Container]; diff --git a/packages/@css-blocks/core/test/validations/root-class-validator-test.ts b/packages/@css-blocks/core/test/validations/root-class-validator-test.ts index d908fad02..1f0c6972c 100644 --- a/packages/@css-blocks/core/test/validations/root-class-validator-test.ts +++ b/packages/@css-blocks/core/test/validations/root-class-validator-test.ts @@ -9,9 +9,9 @@ import { Block } from "../../src/BlockTree"; import { Options, resolveConfiguration } from "../../src/configuration"; import * as cssBlocks from "../../src/errors"; +import { assertParseError } from "../util/assertError"; import { MockImportRegistry } from "../util/MockImportRegistry"; import { TestAnalyzer } from "../util/TestAnalyzer"; -import { assertParseError } from "../util/assertError"; type BlockAndRoot = [Block, postcss.Container]; diff --git a/packages/@css-blocks/core/test/validations/validator-test.ts b/packages/@css-blocks/core/test/validations/validator-test.ts index 61b3cf576..117ba4a98 100644 --- a/packages/@css-blocks/core/test/validations/validator-test.ts +++ b/packages/@css-blocks/core/test/validations/validator-test.ts @@ -8,8 +8,8 @@ import { Block } from "../../src/BlockTree"; import { Options, resolveConfiguration } from "../../src/configuration"; import { TemplateAnalysisError } from "../../src/errors"; -import { TestAnalyzer } from "../util/TestAnalyzer"; import { assertParseError } from "../util/assertError"; +import { TestAnalyzer } from "../util/TestAnalyzer"; type BlockAndRoot = [Block, postcss.Container]; diff --git a/packages/@css-blocks/glimmer/src/ClassnamesHelperGenerator.ts b/packages/@css-blocks/glimmer/src/ClassnamesHelperGenerator.ts index 274cd52f6..4e0eb6f05 100644 --- a/packages/@css-blocks/glimmer/src/ClassnamesHelperGenerator.ts +++ b/packages/@css-blocks/glimmer/src/ClassnamesHelperGenerator.ts @@ -6,20 +6,17 @@ import { Dependency, DynamicClasses, HasAttrValue, - hasDependency, HasGroup, IndexedClassRewrite, - isConditional, - isFalseCondition, - isSwitch, - isTrueCondition, -<<<<<<< HEAD:packages/@css-blocks/glimmer/src/ClassnamesHelperGenerator.ts -======= NotExpression, OrExpression, Style, Switch, ->>>>>>> feat: Enable root-level typedoc generation for the project.:packages/@css-blocks/glimmer/src/ClassnamesHelperGenerator.ts + hasDependency, + isConditional, + isFalseCondition, + isSwitch, + isTrueCondition, } from "@css-blocks/core"; import { AST, diff --git a/packages/@css-blocks/glimmer/src/GlimmerImporter.ts b/packages/@css-blocks/glimmer/src/GlimmerImporter.ts index e68289b1a..67420f4c8 100644 --- a/packages/@css-blocks/glimmer/src/GlimmerImporter.ts +++ b/packages/@css-blocks/glimmer/src/GlimmerImporter.ts @@ -1,14 +1,10 @@ import { FileIdentifier, - filesystemImporter, ImportedFile, Importer, PathBasedImporter, ResolvedConfiguration as CSSBlocksConfiguration, -<<<<<<< HEAD:packages/@css-blocks/glimmer/src/GlimmerImporter.ts filesystemImporter, -======= ->>>>>>> feat: Enable root-level typedoc generation for the project.:packages/@css-blocks/glimmer/src/GlimmerImporter.ts } from "@css-blocks/core"; import * as path from "path"; diff --git a/packages/@css-blocks/glimmer/src/Rewriter.ts b/packages/@css-blocks/glimmer/src/Rewriter.ts index b35a918dc..8ff64f29a 100644 --- a/packages/@css-blocks/glimmer/src/Rewriter.ts +++ b/packages/@css-blocks/glimmer/src/Rewriter.ts @@ -1,15 +1,9 @@ import { Block, Options as CSSBlocksOptions, -<<<<<<< HEAD:packages/@css-blocks/glimmer/src/Rewriter.ts ResolvedConfiguration as CSSBlocksConfiguration, StyleMapping, resolveConfiguration, -======= - resolveConfiguration, - ResolvedConfiguration as CSSBlocksConfiguration, - StyleMapping, ->>>>>>> feat: Enable root-level typedoc generation for the project.:packages/@css-blocks/glimmer/src/Rewriter.ts } from "@css-blocks/core"; import { AST, diff --git a/packages/@css-blocks/glimmer/src/project.ts b/packages/@css-blocks/glimmer/src/project.ts index 5ecdb0b94..91ab8579b 100644 --- a/packages/@css-blocks/glimmer/src/project.ts +++ b/packages/@css-blocks/glimmer/src/project.ts @@ -1,13 +1,8 @@ import { BlockFactory, Options as CSSBlocksOptions, -<<<<<<< HEAD:packages/@css-blocks/glimmer/src/project.ts ResolvedConfiguration, resolveConfiguration, -======= - resolveConfiguration, - ResolvedConfiguration, ->>>>>>> feat: Enable root-level typedoc generation for the project.:packages/@css-blocks/glimmer/src/project.ts } from "@css-blocks/core"; import * as fs from "fs"; import * as glob from "glob"; diff --git a/packages/@css-blocks/jsx/src/Analyzer/visitors/element.ts b/packages/@css-blocks/jsx/src/Analyzer/visitors/element.ts index 00c785747..2572d9d95 100644 --- a/packages/@css-blocks/jsx/src/Analyzer/visitors/element.ts +++ b/packages/@css-blocks/jsx/src/Analyzer/visitors/element.ts @@ -9,16 +9,16 @@ import { CallExpression, Expression, Identifier, + JSXAttribute, + JSXOpeningElement, + Node, + SourceLocation, isCallExpression, isIdentifier, isJSXExpressionContainer, isJSXIdentifier, isMemberExpression, isVariableDeclarator, - JSXAttribute, - JSXOpeningElement, - Node, - SourceLocation, } from "babel-types"; import { isCommonNameForStyling, isStyleFunction } from "../../styleFunctions"; @@ -26,8 +26,8 @@ import { MalformedBlockPath, TemplateAnalysisError } from "../../utils/Errors"; import { ExpressionReader, isBlockStateGroupResult, isBlockStateResult } from "../../utils/ExpressionReader"; import { isConsoleLogStatement } from "../../utils/isConsoleLogStatement"; -import { TEMPLATE_TYPE } from "../Template"; import { JSXAnalysis } from "../index"; +import { TEMPLATE_TYPE } from "../Template"; import { BooleanExpression, Flags, JSXElementAnalysis, StringExpression, TernaryExpression } from "../types"; function htmlTagName(el: JSXOpeningElement): string | undefined { return (isJSXIdentifier(el.name) && el.name.name === el.name.name.toLowerCase()) ? el.name.name : undefined; } diff --git a/packages/@css-blocks/jsx/src/Analyzer/visitors/importer.ts b/packages/@css-blocks/jsx/src/Analyzer/visitors/importer.ts index e15a47056..3678ac1ff 100644 --- a/packages/@css-blocks/jsx/src/Analyzer/visitors/importer.ts +++ b/packages/@css-blocks/jsx/src/Analyzer/visitors/importer.ts @@ -8,12 +8,12 @@ import { ClassDeclaration, Function, ImportDeclaration, + VariableDeclaration, + VariableDeclarator, isIdentifier, isImportDefaultSpecifier, isImportNamespaceSpecifier, isImportSpecifier, - VariableDeclaration, - VariableDeclarator, } from "babel-types"; import * as debugGenerator from "debug"; diff --git a/packages/@css-blocks/jsx/src/options.ts b/packages/@css-blocks/jsx/src/options.ts index 205199893..20d4cea89 100644 --- a/packages/@css-blocks/jsx/src/options.ts +++ b/packages/@css-blocks/jsx/src/options.ts @@ -1,8 +1,4 @@ -<<<<<<< HEAD:packages/@css-blocks/jsx/src/options.ts import { ResolvedConfiguration, resolveConfiguration } from "@css-blocks/core"; -======= -import { resolveConfiguration, ResolvedConfiguration } from "@css-blocks/core"; ->>>>>>> feat: Enable root-level typedoc generation for the project.:packages/@css-blocks/jsx/src/options.ts import { ObjectDictionary } from "@opticss/util"; /** diff --git a/packages/@css-blocks/jsx/src/styleFunctions/index.ts b/packages/@css-blocks/jsx/src/styleFunctions/index.ts index 36923a7f0..d37bd3706 100644 --- a/packages/@css-blocks/jsx/src/styleFunctions/index.ts +++ b/packages/@css-blocks/jsx/src/styleFunctions/index.ts @@ -1,14 +1,14 @@ import { Binding, NodePath } from "babel-traverse"; import { CallExpression, + Node, isIdentifier, isImportDeclaration, - Node, } from "babel-types"; import { ErrorLocation } from "../utils/Errors"; -import { COMMON_NAMES as COMMON_OBJSTR_NAMES, objstrFn, ObjStrStyleFunction } from "./objstrFunction"; +import { COMMON_NAMES as COMMON_OBJSTR_NAMES, ObjStrStyleFunction, objstrFn } from "./objstrFunction"; export type StyleFunction = ObjStrStyleFunction; diff --git a/packages/@css-blocks/jsx/src/transformer/babel.ts b/packages/@css-blocks/jsx/src/transformer/babel.ts index f7232d4a5..f8571e9f5 100644 --- a/packages/@css-blocks/jsx/src/transformer/babel.ts +++ b/packages/@css-blocks/jsx/src/transformer/babel.ts @@ -9,19 +9,19 @@ import { AssignmentExpression, Expression, Identifier, - identifier, ImportDeclaration, + JSXAttribute, + JSXOpeningElement, + Node, + Statement, + identifier, importDeclaration, importDefaultSpecifier, isIdentifier, isJSXExpressionContainer, - JSXAttribute, jSXAttribute, jSXExpressionContainer, jSXIdentifier, - JSXOpeningElement, - Node, - Statement, stringLiteral, } from "babel-types"; // import { TemplateAnalysisError } from '../utils/Errors'; @@ -32,7 +32,7 @@ import { JSXElementAnalyzer } from "../Analyzer/visitors/element"; import { isBlockFilename } from "../utils/isBlockFilename"; import { isConsoleLogStatement } from "../utils/isConsoleLogStatement"; -import { classnamesHelper as generateClassName, HELPER_FN_NAME } from "./classNameGenerator"; +import { HELPER_FN_NAME, classnamesHelper as generateClassName } from "./classNameGenerator"; import { CSSBlocksJSXTransformer as Rewriter } from "./index"; const debug = debugGenerator("css-blocks:jsx:rewriter"); diff --git a/packages/@css-blocks/jsx/src/transformer/classNameGenerator.ts b/packages/@css-blocks/jsx/src/transformer/classNameGenerator.ts index 6ec88329c..04d3b59e8 100644 --- a/packages/@css-blocks/jsx/src/transformer/classNameGenerator.ts +++ b/packages/@css-blocks/jsx/src/transformer/classNameGenerator.ts @@ -6,7 +6,6 @@ import { Dependency, DynamicClasses, HasAttrValue, -<<<<<<< HEAD:packages/@css-blocks/jsx/src/transformer/classNameGenerator.ts HasGroup, IndexedClassRewrite, NotExpression, @@ -14,22 +13,10 @@ import { Style, Switch, hasDependency, -======= - hasDependency, - HasGroup, - IndexedClassRewrite, ->>>>>>> feat: Enable root-level typedoc generation for the project.:packages/@css-blocks/jsx/src/transformer/classNameGenerator.ts isConditional, isFalseCondition, isSwitch, isTrueCondition, -<<<<<<< HEAD:packages/@css-blocks/jsx/src/transformer/classNameGenerator.ts -======= - NotExpression, - OrExpression, - Style, - Switch, ->>>>>>> feat: Enable root-level typedoc generation for the project.:packages/@css-blocks/jsx/src/transformer/classNameGenerator.ts } from "@css-blocks/core"; import { isAndExpression, @@ -42,10 +29,10 @@ import { unwrap, } from "@opticss/util"; import { - arrayExpression, CallExpression, - callExpression, Expression, + arrayExpression, + callExpression, identifier, nullLiteral, numericLiteral, diff --git a/packages/@css-blocks/jsx/src/transformer/index.ts b/packages/@css-blocks/jsx/src/transformer/index.ts index 89d100522..426669345 100644 --- a/packages/@css-blocks/jsx/src/transformer/index.ts +++ b/packages/@css-blocks/jsx/src/transformer/index.ts @@ -1,14 +1,8 @@ import { Options as CSSBlocksOptions, -<<<<<<< HEAD:packages/@css-blocks/jsx/src/transformer/index.ts ResolvedConfiguration, StyleMapping, resolveConfiguration, -======= - resolveConfiguration, - ResolvedConfiguration, - StyleMapping, ->>>>>>> feat: Enable root-level typedoc generation for the project.:packages/@css-blocks/jsx/src/transformer/index.ts } from "@css-blocks/core"; import { ObjectDictionary, whatever } from "@opticss/util"; diff --git a/packages/@css-blocks/jsx/src/utils/ExpressionReader.ts b/packages/@css-blocks/jsx/src/utils/ExpressionReader.ts index 9673c4090..78ec5497e 100644 --- a/packages/@css-blocks/jsx/src/utils/ExpressionReader.ts +++ b/packages/@css-blocks/jsx/src/utils/ExpressionReader.ts @@ -1,13 +1,11 @@ -<<<<<<< HEAD:packages/@css-blocks/jsx/src/utils/ExpressionReader.ts import { AttrValue, Attribute, Block, BlockClass, isBlockClass } from "@css-blocks/core"; -======= -import { Attribute, AttrValue, Block, BlockClass, isBlockClass } from "@css-blocks/core"; ->>>>>>> feat: Enable root-level typedoc generation for the project.:packages/@css-blocks/jsx/src/utils/ExpressionReader.ts import { Node } from "babel-traverse"; import { BooleanLiteral, CallExpression, Expression, + NumericLiteral, + StringLiteral, isBooleanLiteral, isCallExpression, isIdentifier, @@ -16,8 +14,6 @@ import { isMemberExpression, isNumericLiteral, isStringLiteral, - NumericLiteral, - StringLiteral, } from "babel-types"; import * as debugGenerator from "debug"; diff --git a/packages/@css-blocks/jsx/src/utils/isConsoleLogStatement.ts b/packages/@css-blocks/jsx/src/utils/isConsoleLogStatement.ts index fdc595572..62adb13a6 100644 --- a/packages/@css-blocks/jsx/src/utils/isConsoleLogStatement.ts +++ b/packages/@css-blocks/jsx/src/utils/isConsoleLogStatement.ts @@ -1,8 +1,8 @@ import { + Node, isCallExpression, isIdentifier, isMemberExpression, - Node, } from "babel-types"; export function isConsoleLogStatement(node: Node): boolean { diff --git a/packages/@css-blocks/jsx/test/transformer/transformer-test.ts b/packages/@css-blocks/jsx/test/transformer/transformer-test.ts index fc7c332d5..ca9e78281 100644 --- a/packages/@css-blocks/jsx/test/transformer/transformer-test.ts +++ b/packages/@css-blocks/jsx/test/transformer/transformer-test.ts @@ -2,11 +2,8 @@ import c$$ from "@css-blocks/runtime"; import { TemplateIntegrationOptions } from "@opticss/template-api"; import { Analysis } from "@css-blocks/core"; -<<<<<<< HEAD:packages/@css-blocks/jsx/test/transformer/transformer-test.ts import { BlockCompiler, Options as CSSBlocksOptions, StyleMapping, resolveConfiguration as resolveBlocksConfiguration } from "@css-blocks/core"; -======= -import { BlockCompiler, Options as CSSBlocksOptions, resolveConfiguration as resolveBlocksConfiguration, StyleMapping } from "@css-blocks/core"; ->>>>>>> feat: Enable root-level typedoc generation for the project.:packages/@css-blocks/jsx/test/transformer/transformer-test.ts + import * as babel from "babel-core"; import { assert } from "chai"; import { skip, suite, test } from "mocha-typescript"; diff --git a/packages/@css-blocks/webpack/src/Plugin.ts b/packages/@css-blocks/webpack/src/Plugin.ts index 6c26a839f..80aa4baba 100644 --- a/packages/@css-blocks/webpack/src/Plugin.ts +++ b/packages/@css-blocks/webpack/src/Plugin.ts @@ -14,12 +14,8 @@ import { Block, BlockCompiler, Options as CSSBlocksOptions, - resolveConfiguration, StyleMapping, -<<<<<<< HEAD:packages/@css-blocks/webpack/src/Plugin.ts resolveConfiguration, -======= ->>>>>>> feat: Enable root-level typedoc generation for the project.:packages/@css-blocks/webpack/src/Plugin.ts } from "@css-blocks/core"; import { Actions, diff --git a/packages/@css-blocks/webpack/src/loader.ts b/packages/@css-blocks/webpack/src/loader.ts index dc54cb301..be50cf7a9 100644 --- a/packages/@css-blocks/webpack/src/loader.ts +++ b/packages/@css-blocks/webpack/src/loader.ts @@ -1,21 +1,15 @@ import { Block, -<<<<<<< HEAD:packages/@css-blocks/webpack/src/loader.ts ResolvedConfiguration, StyleMapping, resolveConfiguration, -======= - resolveConfiguration, - ResolvedConfiguration, - StyleMapping, ->>>>>>> feat: Enable root-level typedoc generation for the project.:packages/@css-blocks/webpack/src/loader.ts } from "@css-blocks/core"; import * as debugGenerator from "debug"; import * as loaderUtils from "loader-utils"; const debug = debugGenerator("css-blocks:webpack:loader"); -import { PendingResult, TmpType } from "./Plugin"; import { LoaderContext } from "./context"; +import { PendingResult, TmpType } from "./Plugin"; /** * The css-blocks loader makes css-blocks available to webpack modules. diff --git a/yarn.lock b/yarn.lock index 7732fc037..45956baa7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -125,7 +125,6 @@ find-up "^2.1.0" "@glimmer/compiler@^0.33.0": -<<<<<<< HEAD version "0.33.6" resolved "https://registry.npmjs.org/@glimmer/compiler/-/compiler-0.33.6.tgz#bb5948a7035f13a2c8406abffa89504d1a98ac51" dependencies: @@ -133,15 +132,6 @@ "@glimmer/syntax" "^0.33.6" "@glimmer/util" "^0.33.6" "@glimmer/wire-format" "^0.33.6" -======= - version "0.33.4" - resolved "https://registry.npmjs.org/@glimmer/compiler/-/compiler-0.33.4.tgz#9fa1a604c5313b0b281b5351620a82e6b5e34f51" - dependencies: - "@glimmer/interfaces" "^0.33.4" - "@glimmer/syntax" "^0.33.4" - "@glimmer/util" "^0.33.4" - "@glimmer/wire-format" "^0.33.4" ->>>>>>> feat: Enable root-level typedoc generation for the project. "@glimmer/di@^0.2.0": version "0.2.0" @@ -153,19 +143,11 @@ dependencies: "@glimmer/wire-format" "^0.29.10" -<<<<<<< HEAD "@glimmer/interfaces@^0.33.6": version "0.33.6" resolved "https://registry.npmjs.org/@glimmer/interfaces/-/interfaces-0.33.6.tgz#876edf185cfcde9a40ad087df18ad35a48735451" dependencies: "@glimmer/wire-format" "^0.33.6" -======= -"@glimmer/interfaces@^0.33.4": - version "0.33.4" - resolved "https://registry.npmjs.org/@glimmer/interfaces/-/interfaces-0.33.4.tgz#80783552d4d8b567f78ddbc3273e751fe263006b" - dependencies: - "@glimmer/wire-format" "^0.33.4" ->>>>>>> feat: Enable root-level typedoc generation for the project. "@glimmer/resolution-map-builder@0.5.1": version "0.5.1" @@ -204,21 +186,12 @@ handlebars "^4.0.6" simple-html-tokenizer "^0.4.1" -<<<<<<< HEAD "@glimmer/syntax@^0.33.0", "@glimmer/syntax@^0.33.6": version "0.33.6" resolved "https://registry.npmjs.org/@glimmer/syntax/-/syntax-0.33.6.tgz#1a1839c5f3b80333a86bba110c2af649df41a917" dependencies: "@glimmer/interfaces" "^0.33.6" "@glimmer/util" "^0.33.6" -======= -"@glimmer/syntax@^0.33.0", "@glimmer/syntax@^0.33.4": - version "0.33.4" - resolved "https://registry.npmjs.org/@glimmer/syntax/-/syntax-0.33.4.tgz#ac824e0ccad3fd4cb9bf05d7cf6b5a9fbd8b195e" - dependencies: - "@glimmer/interfaces" "^0.33.4" - "@glimmer/util" "^0.33.4" ->>>>>>> feat: Enable root-level typedoc generation for the project. handlebars "^4.0.6" simple-html-tokenizer "^0.5.0" @@ -226,15 +199,9 @@ version "0.29.10" resolved "https://registry.npmjs.org/@glimmer/util/-/util-0.29.10.tgz#8662daf273ffef9254b8d943d39aa396ed7225a5" -<<<<<<< HEAD "@glimmer/util@^0.33.6": version "0.33.6" resolved "https://registry.npmjs.org/@glimmer/util/-/util-0.33.6.tgz#cd8186286baa08ab5b754a1f49a385c312c72da0" -======= -"@glimmer/util@^0.33.4": - version "0.33.4" - resolved "https://registry.npmjs.org/@glimmer/util/-/util-0.33.4.tgz#3aaabcad5cf04195917553510d2128fdce3208eb" ->>>>>>> feat: Enable root-level typedoc generation for the project. "@glimmer/wire-format@^0.29.10": version "0.29.10" @@ -242,19 +209,11 @@ dependencies: "@glimmer/util" "^0.29.10" -<<<<<<< HEAD "@glimmer/wire-format@^0.33.6": version "0.33.6" resolved "https://registry.npmjs.org/@glimmer/wire-format/-/wire-format-0.33.6.tgz#51eb651528572c23eba4601770529fa8c21f5303" dependencies: "@glimmer/util" "^0.33.6" -======= -"@glimmer/wire-format@^0.33.4": - version "0.33.4" - resolved "https://registry.npmjs.org/@glimmer/wire-format/-/wire-format-0.33.4.tgz#782d8bc02cb0f6261b5711cef007d907831f15d5" - dependencies: - "@glimmer/util" "^0.33.4" ->>>>>>> feat: Enable root-level typedoc generation for the project. "@marionebl/sander@^0.6.0": version "0.6.1" @@ -277,11 +236,7 @@ dependencies: "@opticss/element-analysis" "file:../../Library/Caches/Yarn/v1/npm-@opticss/element-analysis" "@opticss/util" "file:../../Library/Caches/Yarn/v1/npm-@opticss/util" -<<<<<<< HEAD postcss "^6.0.21" -======= - postcss "^6.0.12" ->>>>>>> feat: Enable root-level typedoc generation for the project. typescript-collections "^1.2.5" "@opticss/util@file:../opticss/packages/util": @@ -404,26 +359,16 @@ resolved "https://registry.npmjs.org/@types/mocha/-/mocha-2.2.48.tgz#3523b126a0b049482e1c3c11877460f76622ffab" "@types/node@*": -<<<<<<< HEAD version "9.6.6" resolved "https://registry.npmjs.org/@types/node/-/node-9.6.6.tgz#439b91f9caf3983cad2eef1e11f6bedcbf9431d2" "@types/node@^8.0.0": version "8.10.9" resolved "https://registry.npmjs.org/@types/node/-/node-8.10.9.tgz#b507a74a7d3eddc74a17dc35fd40d8f45dde0d6c" -======= - version "9.6.5" - resolved "https://registry.npmjs.org/@types/node/-/node-9.6.5.tgz#ee700810fdf49ac1c399fc5980b7559b3e5a381d" - -"@types/node@^8.0.0": - version "8.10.8" - resolved "https://registry.npmjs.org/@types/node/-/node-8.10.8.tgz#794cba23cc9f8d9715f6543fa8827433b5f5cd3b" ->>>>>>> feat: Enable root-level typedoc generation for the project. "@types/prettier@^1.8.0": version "1.12.0" resolved "https://registry.npmjs.org/@types/prettier/-/prettier-1.12.0.tgz#61ed6bdc64386f49c9e1f179cf84ef26ddc4740c" -<<<<<<< HEAD "@types/recursive-readdir@^2.2.0": version "2.2.0" @@ -431,15 +376,6 @@ dependencies: "@types/node" "*" -======= - -"@types/recursive-readdir@^2.2.0": - version "2.2.0" - resolved "https://registry.npmjs.org/@types/recursive-readdir/-/recursive-readdir-2.2.0.tgz#b39cd5474fd58ea727fe434d5c68b7a20ba9121c" - dependencies: - "@types/node" "*" - ->>>>>>> feat: Enable root-level typedoc generation for the project. "@types/shelljs@0.7.8": version "0.7.8" resolved "https://registry.npmjs.org/@types/shelljs/-/shelljs-0.7.8.tgz#4b4d6ee7926e58d7bca448a50ba442fd9f6715bd" @@ -452,13 +388,8 @@ resolved "https://registry.npmjs.org/@types/source-list-map/-/source-list-map-0.1.2.tgz#0078836063ffaf17412349bba364087e0ac02ec9" "@types/tapable@*": -<<<<<<< HEAD version "1.0.2" resolved "https://registry.npmjs.org/@types/tapable/-/tapable-1.0.2.tgz#e13182e1b69871a422d7863e11a4a6f5b814a4bd" -======= - version "1.0.1" - resolved "https://registry.npmjs.org/@types/tapable/-/tapable-1.0.1.tgz#938bfcc018eda2f386c34e37f084e6e961c08ca6" ->>>>>>> feat: Enable root-level typedoc generation for the project. "@types/tapable@0.2.4": version "0.2.4" @@ -1004,13 +935,10 @@ broccoli-merge-trees@^3.0.0: broccoli-plugin "^1.3.0" merge-trees "^2.0.0" -<<<<<<< HEAD broccoli-node-info@1.1.0: version "1.1.0" resolved "https://registry.npmjs.org/broccoli-node-info/-/broccoli-node-info-1.1.0.tgz#3aa2e31e07e5bdb516dd25214f7c45ba1c459412" -======= ->>>>>>> feat: Enable root-level typedoc generation for the project. broccoli-plugin@^1.3.0: version "1.3.0" resolved "https://registry.npmjs.org/broccoli-plugin/-/broccoli-plugin-1.3.0.tgz#bee704a8e42da08cb58e513aaa436efb7f0ef1ee" @@ -1126,15 +1054,12 @@ browserslist@^1.3.6, browserslist@^1.5.2, browserslist@^1.7.6: caniuse-db "^1.0.30000639" electron-to-chromium "^1.2.7" -<<<<<<< HEAD bser@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/bser/-/bser-2.0.0.tgz#9ac78d3ed5d915804fd87acb158bc797147a1719" dependencies: node-int64 "^0.4.0" -======= ->>>>>>> feat: Enable root-level typedoc generation for the project. buffer-from@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/buffer-from/-/buffer-from-1.0.0.tgz#4cb8832d23612589b0406e9e2956c17f06fdf531" @@ -1240,13 +1165,8 @@ caniuse-api@^1.5.2: lodash.uniq "^4.5.0" caniuse-db@^1.0.30000529, caniuse-db@^1.0.30000634, caniuse-db@^1.0.30000639: -<<<<<<< HEAD version "1.0.30000830" resolved "https://registry.npmjs.org/caniuse-db/-/caniuse-db-1.0.30000830.tgz#6e45255b345649fd15ff59072da1e12bb3de2f13" -======= - version "1.0.30000828" - resolved "https://registry.npmjs.org/caniuse-db/-/caniuse-db-1.0.30000828.tgz#ed6d6f03b5a81fb291c3c0e088828b11a70948bf" ->>>>>>> feat: Enable root-level typedoc generation for the project. capture-stack-trace@^1.0.0: version "1.0.0" @@ -1290,13 +1210,8 @@ chalk@^1.0.0, chalk@^1.1.3: supports-color "^2.0.0" chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.3.0, chalk@^2.3.2: -<<<<<<< HEAD version "2.4.0" resolved "https://registry.npmjs.org/chalk/-/chalk-2.4.0.tgz#a060a297a6b57e15b61ca63ce84995daa0fe6e52" -======= - version "2.3.2" - resolved "https://registry.npmjs.org/chalk/-/chalk-2.3.2.tgz#250dc96b07491bfd601e648d66ddf5f60c7a5c65" ->>>>>>> feat: Enable root-level typedoc generation for the project. dependencies: ansi-styles "^3.2.1" escape-string-regexp "^1.0.5" @@ -1487,11 +1402,7 @@ commander@2.9.0: dependencies: graceful-readlink ">= 1.0.0" -<<<<<<< HEAD commander@^2.12.1, commander@^2.5.0: -======= -commander@^2.12.1: ->>>>>>> feat: Enable root-level typedoc generation for the project. version "2.15.1" resolved "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz#df46e867d0fc2aec66a34662b406a9ccafff5b0f" @@ -1566,19 +1477,11 @@ conventional-changelog-atom@^0.2.8: q "^1.5.1" conventional-changelog-cli@^1.3.13: -<<<<<<< HEAD version "1.3.22" resolved "https://registry.npmjs.org/conventional-changelog-cli/-/conventional-changelog-cli-1.3.22.tgz#13570fe1728f56f013ff7a88878ff49d5162a405" dependencies: add-stream "^1.0.0" conventional-changelog "^1.1.24" -======= - version "1.3.21" - resolved "https://registry.npmjs.org/conventional-changelog-cli/-/conventional-changelog-cli-1.3.21.tgz#f6b063102ba34c0f2bec552249ee233e0762e0a4" - dependencies: - add-stream "^1.0.0" - conventional-changelog "^1.1.23" ->>>>>>> feat: Enable root-level typedoc generation for the project. lodash "^4.2.1" meow "^4.0.0" tempfile "^1.1.1" @@ -1589,15 +1492,9 @@ conventional-changelog-codemirror@^0.3.8: dependencies: q "^1.5.1" -<<<<<<< HEAD conventional-changelog-core@^2.0.11: version "2.0.11" resolved "https://registry.npmjs.org/conventional-changelog-core/-/conventional-changelog-core-2.0.11.tgz#19b5fbd55a9697773ed6661f4e32030ed7e30287" -======= -conventional-changelog-core@^2.0.10: - version "2.0.10" - resolved "https://registry.npmjs.org/conventional-changelog-core/-/conventional-changelog-core-2.0.10.tgz#3e47565ef9d148bcdceab6de6b3651a16dd28dc8" ->>>>>>> feat: Enable root-level typedoc generation for the project. dependencies: conventional-changelog-writer "^3.0.9" conventional-commits-parser "^2.1.7" @@ -1613,15 +1510,9 @@ conventional-changelog-core@^2.0.10: read-pkg-up "^1.0.1" through2 "^2.0.0" -<<<<<<< HEAD conventional-changelog-ember@^0.3.12: version "0.3.12" resolved "https://registry.npmjs.org/conventional-changelog-ember/-/conventional-changelog-ember-0.3.12.tgz#b7d31851756d0fcb49b031dffeb6afa93b202400" -======= -conventional-changelog-ember@^0.3.11: - version "0.3.11" - resolved "https://registry.npmjs.org/conventional-changelog-ember/-/conventional-changelog-ember-0.3.11.tgz#56ca9b418ee9d7f089bea34307d57497420d72a6" ->>>>>>> feat: Enable root-level typedoc generation for the project. dependencies: q "^1.5.1" @@ -1675,26 +1566,15 @@ conventional-changelog-writer@^3.0.9: split "^1.0.0" through2 "^2.0.0" -<<<<<<< HEAD conventional-changelog@^1.1.24: version "1.1.24" resolved "https://registry.npmjs.org/conventional-changelog/-/conventional-changelog-1.1.24.tgz#3d94c29c960f5261c002678315b756cdd3d7d1f0" -======= -conventional-changelog@^1.1.23: - version "1.1.23" - resolved "https://registry.npmjs.org/conventional-changelog/-/conventional-changelog-1.1.23.tgz#4ac72af8b9ea9af260e97acf556c19d8b2da970e" ->>>>>>> feat: Enable root-level typedoc generation for the project. dependencies: conventional-changelog-angular "^1.6.6" conventional-changelog-atom "^0.2.8" conventional-changelog-codemirror "^0.3.8" -<<<<<<< HEAD conventional-changelog-core "^2.0.11" conventional-changelog-ember "^0.3.12" -======= - conventional-changelog-core "^2.0.10" - conventional-changelog-ember "^0.3.11" ->>>>>>> feat: Enable root-level typedoc generation for the project. conventional-changelog-eslint "^1.0.9" conventional-changelog-express "^0.3.6" conventional-changelog-jquery "^0.1.0" @@ -1873,6 +1753,10 @@ cssesc@^0.1.0: version "0.1.0" resolved "https://registry.npmjs.org/cssesc/-/cssesc-0.1.0.tgz#c814903e45623371a0477b40109aaafbeeaddbb4" +cssesc@^1.0.1: + version "1.0.1" + resolved "https://registry.npmjs.org/cssesc/-/cssesc-1.0.1.tgz#ef7bd8d0229ed6a3a7051ff7771265fe7330e0a8" + cssnano@^3.10.0: version "3.10.0" resolved "https://registry.npmjs.org/cssnano/-/cssnano-3.10.0.tgz#4f38f6cea2b9b17fa01490f23f1dc68ea65c1c38" @@ -2108,12 +1992,6 @@ dot-prop@^3.0.0: dependencies: is-obj "^1.0.0" -dot-prop@^4.1.1: - version "4.2.0" - resolved "https://registry.npmjs.org/dot-prop/-/dot-prop-4.2.0.tgz#1f19e0c2e1aa0e32797c49799f2837ac6af69c57" - dependencies: - is-obj "^1.0.0" - duplexer2@0.0.2: version "0.0.2" resolved "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz#c614dcf67e2fb14995a91711e5a617e8a60a31db" @@ -2593,7 +2471,6 @@ fragment-cache@^0.2.1: dependencies: map-cache "^0.2.2" -<<<<<<< HEAD fs-exists-sync@^0.1.0: version "0.1.0" resolved "https://registry.npmjs.org/fs-exists-sync/-/fs-exists-sync-0.1.0.tgz#982d6893af918e72d08dec9e8673ff2b5a8d6add" @@ -2608,8 +2485,6 @@ fs-extra@^0.30.0: path-is-absolute "^1.0.0" rimraf "^2.2.8" -======= ->>>>>>> feat: Enable root-level typedoc generation for the project. fs-extra@^3.0.1: version "3.0.1" resolved "https://registry.npmjs.org/fs-extra/-/fs-extra-3.0.1.tgz#3794f378c58b342ea7dbbb23095109c4b3b62291" @@ -2634,11 +2509,7 @@ fs-extra@^5.0.0: jsonfile "^4.0.0" universalify "^0.1.0" -<<<<<<< HEAD fs-tree-diff@^0.5.3, fs-tree-diff@^0.5.6: -======= -fs-tree-diff@^0.5.3: ->>>>>>> feat: Enable root-level typedoc generation for the project. version "0.5.7" resolved "https://registry.npmjs.org/fs-tree-diff/-/fs-tree-diff-0.5.7.tgz#315e2b098d5fe7f622880ac965b1b051868ac871" dependencies: @@ -3654,13 +3525,8 @@ lcid@^1.0.0: invert-kv "^1.0.0" lerna@^2.5.1: -<<<<<<< HEAD version "2.10.2" resolved "https://registry.npmjs.org/lerna/-/lerna-2.10.2.tgz#3a0d54d398360fecc5918207c6d7ab68a5443d9f" -======= - version "2.10.1" - resolved "https://registry.npmjs.org/lerna/-/lerna-2.10.1.tgz#3b0ffe6b80d3312e8efdc7003a50d47d90ebdf03" ->>>>>>> feat: Enable root-level typedoc generation for the project. dependencies: async "^1.5.0" chalk "^2.1.0" @@ -4218,13 +4084,8 @@ modify-values@^1.0.0: resolved "https://registry.npmjs.org/modify-values/-/modify-values-1.0.1.tgz#b3939fa605546474e3e3e3c63d64bd43b4ee6022" moment@^2.6.0: -<<<<<<< HEAD version "2.22.1" resolved "https://registry.npmjs.org/moment/-/moment-2.22.1.tgz#529a2e9bf973f259c9643d237fda84de3a26e8ad" -======= - version "2.22.0" - resolved "https://registry.npmjs.org/moment/-/moment-2.22.0.tgz#7921ade01017dd45186e7fee5f424f0b8663a730" ->>>>>>> feat: Enable root-level typedoc generation for the project. moo@^0.4.1: version "0.4.3" @@ -4281,13 +4142,10 @@ neo-async@^2.5.0: next-tick@1: version "1.0.0" resolved "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz#ca86d1fe8828169b0120208e3dc8424b9db8342c" -<<<<<<< HEAD node-int64@^0.4.0: version "0.4.0" resolved "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b" -======= ->>>>>>> feat: Enable root-level typedoc generation for the project. node-libs-browser@^2.0.0: version "2.1.0" @@ -4493,13 +4351,8 @@ onetime@^2.0.0: css-property-parser "^1.0.5" debug "^2.6.8" object.values "^1.0.4" -<<<<<<< HEAD postcss "^6.0.21" postcss-selector-parser "^4.0.0-rc.1" -======= - postcss "^6.0.12" - postcss-selector-parser "^3.1.1" ->>>>>>> feat: Enable root-level typedoc generation for the project. source-map "^0.6.1" specificity "^0.3.2" typescript-collections "^1.2.5" @@ -4944,25 +4797,19 @@ postcss-scss@^0.3.0: dependencies: postcss "^5.2.4" -postcss-selector-parser@3.1.1, postcss-selector-parser@^3.1.1: - version "3.1.1" - resolved "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-3.1.1.tgz#4f875f4afb0c96573d5cf4d74011aee250a7e865" +postcss-selector-parser@^2.0.0, postcss-selector-parser@^2.2.2: + version "2.2.3" + resolved "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-2.2.3.tgz#f9437788606c3c9acee16ffe8d8b16297f27bb90" dependencies: - dot-prop "^4.1.1" + flatten "^1.0.2" indexes-of "^1.0.1" uniq "^1.0.1" -<<<<<<< HEAD postcss-selector-parser@^4.0.0-rc.1: version "4.0.0-rc.1" resolved "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-4.0.0-rc.1.tgz#e32edb8a8f3ca8300cb20b9207b15ef41b760f88" -======= -postcss-selector-parser@^2.0.0, postcss-selector-parser@^2.2.2: - version "2.2.3" - resolved "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-2.2.3.tgz#f9437788606c3c9acee16ffe8d8b16297f27bb90" ->>>>>>> feat: Enable root-level typedoc generation for the project. dependencies: - flatten "^1.0.2" + cssesc "^1.0.1" indexes-of "^1.0.1" uniq "^1.0.1" @@ -5004,11 +4851,7 @@ postcss@^5.0.10, postcss@^5.0.11, postcss@^5.0.12, postcss@^5.0.13, postcss@^5.0 source-map "^0.5.6" supports-color "^3.2.3" -<<<<<<< HEAD postcss@^6.0.1, postcss@^6.0.21: -======= -postcss@^6.0.1, postcss@^6.0.12, postcss@^6.0.14, postcss@^6.0.21: ->>>>>>> feat: Enable root-level typedoc generation for the project. version "6.0.21" resolved "https://registry.npmjs.org/postcss/-/postcss-6.0.21.tgz#8265662694eddf9e9a5960db6da33c39e4cd069d" dependencies: @@ -5033,13 +4876,8 @@ preserve@^0.2.0: resolved "https://registry.npmjs.org/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" prettier@^1.8.2: -<<<<<<< HEAD version "1.12.1" resolved "https://registry.npmjs.org/prettier/-/prettier-1.12.1.tgz#c1ad20e803e7749faf905a409d2367e06bbe7325" -======= - version "1.12.0" - resolved "https://registry.npmjs.org/prettier/-/prettier-1.12.0.tgz#d26fc5894b9230de97629b39cae225b503724ce8" ->>>>>>> feat: Enable root-level typedoc generation for the project. private@^0.1.7: version "0.1.8" @@ -5528,11 +5366,7 @@ right-align@^0.1.1: dependencies: align-text "^0.1.1" -<<<<<<< HEAD rimraf@2, rimraf@^2.2.8, rimraf@^2.3.4, rimraf@^2.4.3, rimraf@^2.5.1, rimraf@^2.5.2, rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.2: -======= -rimraf@2, rimraf@^2.3.4, rimraf@^2.4.3, rimraf@^2.5.1, rimraf@^2.5.2, rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.2: ->>>>>>> feat: Enable root-level typedoc generation for the project. version "2.6.2" resolved "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36" dependencies: @@ -5583,7 +5417,6 @@ safer-buffer@^2.1.0: version "2.1.2" resolved "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" -<<<<<<< HEAD sane@^1.4.1: version "1.7.0" resolved "https://registry.npmjs.org/sane/-/sane-1.7.0.tgz#b3579bccb45c94cf20355cc81124990dfd346e30" @@ -5596,8 +5429,6 @@ sane@^1.4.1: walker "~1.0.5" watch "~0.10.0" -======= ->>>>>>> feat: Enable root-level typedoc generation for the project. sax@~1.2.1: version "1.2.4" resolved "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" @@ -6117,15 +5948,12 @@ tmp@0.0.28: dependencies: os-tmpdir "~1.0.1" -<<<<<<< HEAD tmp@0.0.31: version "0.0.31" resolved "https://registry.npmjs.org/tmp/-/tmp-0.0.31.tgz#8f38ab9438e17315e5dbd8b3657e8bfb277ae4a7" dependencies: os-tmpdir "~1.0.1" -======= ->>>>>>> feat: Enable root-level typedoc generation for the project. tmp@^0.0.33: version "0.0.33" resolved "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" From 3d6ee0f087630e6a371d66fd23b8228a767890c2 Mon Sep 17 00:00:00 2001 From: Adam Miller Date: Mon, 16 Apr 2018 11:15:49 -0700 Subject: [PATCH 3/6] chore: Move core's postcss plugin to test helpers. --- packages/@css-blocks/core/src/Plugin.ts | 50 ---------------------- packages/@css-blocks/core/src/cssBlocks.ts | 33 -------------- 2 files changed, 83 deletions(-) delete mode 100644 packages/@css-blocks/core/src/Plugin.ts delete mode 100644 packages/@css-blocks/core/src/cssBlocks.ts diff --git a/packages/@css-blocks/core/src/Plugin.ts b/packages/@css-blocks/core/src/Plugin.ts deleted file mode 100644 index 80d9b6b9a..000000000 --- a/packages/@css-blocks/core/src/Plugin.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { postcss } from "opticss"; - -import { BlockCompiler } from "./BlockCompiler"; -import { BlockFactory } from "./BlockParser"; -import { Options, ResolvedConfiguration, resolveConfiguration } from "./configuration"; -import * as errors from "./errors"; - -/** - * CSS Blocks PostCSS plugin. - */ -export class Plugin { - private config: ResolvedConfiguration; - private postcss: typeof postcss; - - /** - * @param postcssImpl PostCSS instance to use - * @param opts Optional plugin config options - */ - constructor(postcssImpl: typeof postcss, opts?: Options) { - this.config = resolveConfiguration(opts); - this.postcss = postcssImpl; - } - - /** - * Main processing entrypoint for PostCSS Plugin - * @param root PostCSS AST - * @param result Provides the result of the PostCSS transformations - */ - public process(root: postcss.Root, result: postcss.Result) { - - // Fetch the CSS source file path. Throw if not present. - let sourceFile: string; - if (result && result.opts && result.opts.from) { - sourceFile = result.opts.from; - } else { - throw new errors.MissingSourcePath(); - } - - // Fetch block name from importer - let identifier = this.config.importer.identifier(null, sourceFile, this.config); - let defaultName: string = this.config.importer.defaultName(identifier, this.config); - let factory = new BlockFactory(this.config, this.postcss); - - return factory.parse(root, sourceFile, defaultName).then((block) => { - let compiler = new BlockCompiler(postcss, this.config); - compiler.compile(block, root); - }); - } - -} diff --git a/packages/@css-blocks/core/src/cssBlocks.ts b/packages/@css-blocks/core/src/cssBlocks.ts deleted file mode 100644 index 07024b44c..000000000 --- a/packages/@css-blocks/core/src/cssBlocks.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { postcss } from "opticss"; - -import { Configuration, OutputMode } from "./configuration"; -import { CssBlockError, InvalidBlockSyntax, MissingSourcePath } from "./errors"; -import { Plugin } from "./Plugin"; - -// This is ugly but it's the only thing I have been able to make work. -// I welcome a patch that cleans this up. - -type temp = { - (postcssImpl: typeof postcss): (config?: Partial>) => postcss.Plugin>>; - OutputMode: typeof OutputMode; - CssBlockError: typeof CssBlockError; - InvalidBlockSyntax: typeof InvalidBlockSyntax; - MissingSourcePath: typeof MissingSourcePath; -}; - -function makeApi(): temp { - let cssBlocks: temp; - cssBlocks = function(postcssImpl: typeof postcss) { - return (config?: Partial>) => { - let plugin = new Plugin(postcssImpl, config); - return plugin.process.bind(plugin); - }; - }; - cssBlocks.OutputMode = OutputMode; - cssBlocks.CssBlockError = CssBlockError; - cssBlocks.InvalidBlockSyntax = InvalidBlockSyntax; - cssBlocks.MissingSourcePath = MissingSourcePath; - return cssBlocks; -} - -export = makeApi(); From 652e8ad0ba3605fce47d338bcd98fe64c7e74b87 Mon Sep 17 00:00:00 2001 From: Adam Miller Date: Tue, 17 Apr 2018 02:30:43 -0700 Subject: [PATCH 4/6] feat: Require the :scope pseudo for root states. - Buggy getBlockNode removed from block-intermediates - block-intermediates made a private module of BlockParser - Unrelated: Fix webpack plugin file watcher for auto rebuilds --- ARCHITECTURE.md | 2 +- .../property-conflict-validator.ts | 1 + .../src/BlockCompiler/ConflictResolver.ts | 21 +++- .../BlockParser/features/construct-block.ts | 81 ++++++---------- .../core/src/BlockSyntax/BlockPath.ts | 7 +- .../core/src/BlockTree/Attribute.ts | 2 +- .../@css-blocks/core/src/BlockTree/Block.ts | 43 +-------- .../core/src/BlockTree/BlockClass.ts | 6 +- .../core/test/attribute-container-test.ts | 16 ++-- .../core/test/block-factory-test.ts | 2 +- .../core/test/block-inheritance-test.ts | 4 +- .../core/test/block-interface-test.ts | 12 +-- .../core/test/global-states-test.ts | 6 +- .../@css-blocks/core/test/local-scope-test.ts | 6 +- .../@css-blocks/core/test/opticss-test.ts | 2 +- packages/@css-blocks/core/test/query-test.ts | 10 +- .../@css-blocks/core/test/resolution-test.ts | 44 ++++----- packages/@css-blocks/core/test/syntax-test.ts | 88 ++++++++--------- .../core/test/template-analysis-test.ts | 58 +++++------ .../attribute-group-validator-test.ts | 24 ++--- .../attribute-parent-validator-test.ts | 4 +- .../validations/class-pairs-validator-test.ts | 2 +- .../property-conflict-validator-test.ts | 70 +++++++------- .../validations/root-class-validator-test.ts | 4 +- .../core/test/validations/validator-test.ts | 2 +- .../jsx/test/analyzer/dynamic-styles-test.ts | 2 +- .../test/analyzer/root-states-objstr-test.ts | 16 ++-- .../jsx/test/transformer/transformer-test.ts | 2 +- packages/@css-blocks/webpack/src/Plugin.ts | 95 ++++++++----------- .../test/fixtures/blocks/has-reference.css | 2 +- 30 files changed, 285 insertions(+), 349 deletions(-) diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 943b2df56..4fede323b 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -175,7 +175,7 @@ We can easily conceptualize the `RewriteMapping` data for each element in develo ```javascript // For Element 1: // - `.class-0` is always applied -// - [state|active] is *only* applied when `isActive` is true +// - `:scope[state|active]` is *only* applied when `isActive` is true const el1Classes = [ "block__class-0", isActive && "block__class-0--active" diff --git a/packages/@css-blocks/core/src/Analyzer/validations/property-conflict-validator.ts b/packages/@css-blocks/core/src/Analyzer/validations/property-conflict-validator.ts index 2eec665eb..ef8593046 100644 --- a/packages/@css-blocks/core/src/Analyzer/validations/property-conflict-validator.ts +++ b/packages/@css-blocks/core/src/Analyzer/validations/property-conflict-validator.ts @@ -55,6 +55,7 @@ function evaluate(obj: Style, propToRules: PropMap, conflicts: ConflictMap) { // If these styles are from the same block, abort! if (other.style.block === self.style.block) { continue; } + // Get the declarations for this specific property. let selfDecl = self.declarations.get(prop); let otherDecl = other.declarations.get(prop); diff --git a/packages/@css-blocks/core/src/BlockCompiler/ConflictResolver.ts b/packages/@css-blocks/core/src/BlockCompiler/ConflictResolver.ts index 6f7402271..479b04fe1 100644 --- a/packages/@css-blocks/core/src/BlockCompiler/ConflictResolver.ts +++ b/packages/@css-blocks/core/src/BlockCompiler/ConflictResolver.ts @@ -1,9 +1,9 @@ import { assertNever } from "@opticss/util"; import { CompoundSelector, ParsedSelector, parseSelector, postcss, postcssSelectorParser as selectorParser } from "opticss"; -import { getBlockNode } from "../BlockParser"; +import { isRootNode, isClassNode, isAttributeNode, toAttrToken } from "../BlockParser"; import { RESOLVE_RE } from "../BlockSyntax"; -import { Block, Style } from "../BlockTree"; +import { Block, BlockClass, Style } from "../BlockTree"; import { ResolvedConfiguration } from "../configuration"; import * as errors from "../errors"; import { QueryKeySelector } from "../query"; @@ -88,11 +88,22 @@ export class ConflictResolver { let parsedSelectors = block.getParsedSelectors(rule); parsedSelectors.forEach((sel) => { let key = sel.key; + let obj: Style | null = null; + let container: BlockClass | null; // Fetch the associated `Style`. If does not exist (ex: malformed selector), skip. - let blockNode = getBlockNode(key); - if (!blockNode) { return; } - let obj: Style | null = block.nodeAndTypeToStyle(blockNode); + for (let node of key.nodes) { + if (isRootNode(node)) { + container = obj = block.rootClass; + } + if (isClassNode(node)) { + container = obj = block.getClass(node.value); + } + else if (isAttributeNode(node)) { + obj = container!.getAttributeValue(toAttrToken(node)); + } + } + if (!obj) { return; } // Fetch the set of Style conflicts. If the Style has already diff --git a/packages/@css-blocks/core/src/BlockParser/features/construct-block.ts b/packages/@css-blocks/core/src/BlockParser/features/construct-block.ts index a83d7350f..a5fabe093 100644 --- a/packages/@css-blocks/core/src/BlockParser/features/construct-block.ts +++ b/packages/@css-blocks/core/src/BlockParser/features/construct-block.ts @@ -1,7 +1,6 @@ -import { assertNever } from "@opticss/util"; import { CompoundSelector, ParsedSelector, postcss, postcssSelectorParser as selectorParser } from "opticss"; -import { Block, Style } from "../../BlockTree"; +import { Block, BlockClass, Style } from "../../BlockTree"; import * as errors from "../../errors"; import { selectorSourceLocation as loc, sourceLocation } from "../../SourceLocation"; import { @@ -9,7 +8,6 @@ import { BlockType, NodeAndType, blockTypeName, - getBlockNode, isAttributeNode, isClassLevelObject, isClassNode, @@ -71,53 +69,32 @@ export async function constructBlock(root: postcss.Root, block: Block, file: str // For each `CompoundSelector` in this rule, configure the `Block` object // depending on the BlockType. while (currentCompoundSel) { + let isKey = (keySel === currentCompoundSel); - let obj = getBlockNode(currentCompoundSel); - if (obj) { - switch (obj.blockType) { - - // If type `block`, track all property concerns on the block object - // itself, excluding any inheritance properties. Make sure to - // process any inheritance properties present in this ruleset. - case BlockType.root: - if (!isKey) { break; } - styleRuleTuples.add([block.rootClass, rule]); - break; - - // If a local attribute selector, ensure the attribute is registered with - // the parent block and track add all property concerns from this - // ruleset. If a foreign attribute, do nothing (validation happened earlier). - case BlockType.attribute: - if (obj.blockName) { break; } - let attr = block.rootClass.ensureAttributeValue(toAttrToken(obj.node)); - if (!isKey) { break; } - styleRuleTuples.add([attr, rule]); - break; - - // If a class selector, ensure this class is registered with the - // parent block and track all property concerns from this ruleset. - case BlockType.class: - let blockClass = block.ensureClass(obj.node.value); - if (!isKey) { break; } - styleRuleTuples.add([blockClass, rule]); - break; - - // If a classAttribute selector, ensure the class is registered with - // the parent block, and the attribute is registered with this class. - // Track all property concerns from this ruleset. - case BlockType.classAttribute: - let classNode = obj.node.prev(); - let classObj = block.ensureClass(classNode.value!); - let classAttr = classObj.ensureAttributeValue(toAttrToken(obj.node)); - if (!isKey) { break; } - styleRuleTuples.add([classAttr, rule]); - break; - default: - assertNever(obj); + let blockClass: BlockClass | undefined = undefined; + let foundStyles: Style[] = []; + + for (let node of currentCompoundSel.nodes) { + if (isRootNode(node)){ + blockClass = block.rootClass; + } + else if (isClassNode(node)){ + blockClass = block.ensureClass(node.value); + } + else if (isAttributeNode(node)){ + // The fact that a base class exists for all state selectors is validated elsewhere + foundStyles.push(blockClass!.ensureAttributeValue(toAttrToken(node))); } + } + // If we haven't found any terminating states, we're targeting the discovered Block class. + if (blockClass && !foundStyles.length) { foundStyles.push(blockClass); } + + // If this is the key selector, save this ruleset on the created style. + if (isKey) { + foundStyles.map(s => styleRuleTuples.add([s, rule])); + } - // Move on to the next compound selector. currentCompoundSel = currentCompoundSel.next && currentCompoundSel.next.selector; } }); @@ -325,14 +302,14 @@ function assertBlockObject(block: Block, sel: CompoundSelector, rule: postcss.Ru ); } if (!found) { - found = { node: n, blockType: BlockType.attribute }; - } else if (found.blockType === BlockType.class) { - found = { node: n, blockType: BlockType.classAttribute }; - } else if (found.blockType === BlockType.root) { throw new errors.InvalidBlockSyntax( - `It's redundant to specify a state with an explicit .root: ${rule.selector}`, - loc(file, rule, found.node), + `States without an explicit :scope or class selector are not yet supported: ${rule.selector}`, + loc(file, rule, n), ); + } else if (found.blockType === BlockType.class || found.blockType === BlockType.classAttribute) { + found = { node: n, blockType: BlockType.classAttribute }; + } else if (found.blockType === BlockType.root || found.blockType === BlockType.attribute) { + found = { node: n, blockType: BlockType.attribute }; } } diff --git a/packages/@css-blocks/core/src/BlockSyntax/BlockPath.ts b/packages/@css-blocks/core/src/BlockSyntax/BlockPath.ts index 78523c9f9..be81af6ac 100644 --- a/packages/@css-blocks/core/src/BlockSyntax/BlockPath.ts +++ b/packages/@css-blocks/core/src/BlockSyntax/BlockPath.ts @@ -20,7 +20,7 @@ interface ClassToken { export interface IAttrToken { namespace?: string; name: string; - value?: string; + value: string; } export interface AttrToken extends IAttrToken { @@ -146,6 +146,8 @@ export class BlockPath { */ private addToken(token: Partial, isUserProvided: boolean): void { + if (!token.type) { return; } + // Final validation of incoming data. Blocks may have no name. State attribute must have a namespace. if (!isBlock(token) && !hasName(token)) { this.throw(ERRORS.noname); } if (isAttribute(token) && !isValidNamespace(token)) { this.throw(ERRORS.namespace); } @@ -179,7 +181,7 @@ export class BlockPath { let char, working = "", walker = this.walker, - token: Partial = { type: "block" }; + token: Partial | undefined = { type: "block" }; while (char = walker.next()) { @@ -193,6 +195,7 @@ export class BlockPath { if (working === ROOT_CLASS) { this.addToken({ type: "class", name: ROOT_CLASS }, true); working = ""; + token = {}; break; } else { diff --git a/packages/@css-blocks/core/src/BlockTree/Attribute.ts b/packages/@css-blocks/core/src/BlockTree/Attribute.ts index cf2f16fba..29a6ecb98 100644 --- a/packages/@css-blocks/core/src/BlockTree/Attribute.ts +++ b/packages/@css-blocks/core/src/BlockTree/Attribute.ts @@ -139,7 +139,7 @@ export class Attribute extends Inheritable { */ public getAttributeValue(token: AttrToken | string): AttrValue | null { token = ensureToken(token); - let value = token.value || ATTR_PRESENT; let attr = this.getAttribute(token); - return attr ? attr.getValue(value) || null : null; + return attr ? attr.getValue(token.value) || null : null; } /** @@ -136,8 +135,7 @@ export class BlockClass extends Style { */ public ensureAttributeValue(token: AttrToken | string): AttrValue { token = ensureToken(token); - let value = token.value || ATTR_PRESENT; - return this.ensureAttribute(token).ensureValue(value); + return this.ensureAttribute(token).ensureValue(token.value); } /** diff --git a/packages/@css-blocks/core/test/attribute-container-test.ts b/packages/@css-blocks/core/test/attribute-container-test.ts index af3dc0d43..7d919d9e3 100644 --- a/packages/@css-blocks/core/test/attribute-container-test.ts +++ b/packages/@css-blocks/core/test/attribute-container-test.ts @@ -27,7 +27,7 @@ export class AttributeContainerTest extends BEMProcessor { let filename = "foo/bar/a-block.css"; imports.registerSource( filename, - `[state|large] { font-size: 20px; } + `:scope[state|large] { font-size: 20px; } .foo { float: left; } .foo[state|small] { font-size: 5px; }`, ); @@ -52,9 +52,9 @@ export class AttributeContainerTest extends BEMProcessor { let filename = "foo/bar/a-block.css"; imports.registerSource( filename, - `[state|size=large] { font-size: 20px; } - [state|size=small] { font-size: 10px; } - [state|active] { color: red; } + `:scope[state|size=large] { font-size: 20px; } + :scope[state|size=small] { font-size: 10px; } + :scope[state|active] { color: red; } .foo[state|mode=collapsed] { display: none; } .foo[state|mode=minimized] { display: block; max-height: 100px; } .foo[state|mode=expanded] { display: block; }`, @@ -83,9 +83,9 @@ export class AttributeContainerTest extends BEMProcessor { let filename = "foo/bar/sub-block.block.css"; imports.registerSource( "foo/bar/base-block.block.css", - `[state|size=large] { font-size: 20px; } - [state|size=small] { font-size: 10px; } - [state|active] { color: red; } + `:scope[state|size=large] { font-size: 20px; } + :scope[state|size=small] { font-size: 10px; } + :scope[state|active] { color: red; } .foo[state|mode=collapsed] { display: none; } .foo[state|mode=minimized] { display: block; max-height: 100px; } .foo[state|mode=expanded] { display: block; }`, @@ -94,7 +94,7 @@ export class AttributeContainerTest extends BEMProcessor { filename, `@block-reference base-block from "base-block.block.css"; :scope { extends: base-block; } - [state|size=tiny] { font-size: 6px; } + :scope[state|size=tiny] { font-size: 6px; } .foo[state|mode=minimized] { display: block; max-height: 200px; }`, ); diff --git a/packages/@css-blocks/core/test/block-factory-test.ts b/packages/@css-blocks/core/test/block-factory-test.ts index 489628cf7..f8e0ecd6d 100644 --- a/packages/@css-blocks/core/test/block-factory-test.ts +++ b/packages/@css-blocks/core/test/block-factory-test.ts @@ -26,7 +26,7 @@ export class BlockFactoryTests extends BEMProcessor { imports.registerSource( baseFilename, `:scope { color: purple; } - [state|large] { font-size: 20px; } + :scope[state|large] { font-size: 20px; } .foo { float: left; } .foo[state|small] { font-size: 5px; }`, ); diff --git a/packages/@css-blocks/core/test/block-inheritance-test.ts b/packages/@css-blocks/core/test/block-inheritance-test.ts index 75f53d780..fffdc937d 100644 --- a/packages/@css-blocks/core/test/block-inheritance-test.ts +++ b/packages/@css-blocks/core/test/block-inheritance-test.ts @@ -11,7 +11,7 @@ export class BlockInheritance extends BEMProcessor { imports.registerSource( "foo/bar/base.css", `:scope { color: purple; } - [state|large] { font-size: 20px; } + :scope[state|large] { font-size: 20px; } .foo { float: left; } .foo[state|small] { font-size: 5px; }`, ); @@ -37,7 +37,7 @@ export class BlockInheritance extends BEMProcessor { " .b[state|small] => .inherits__b--small\n" + " .foo => .base__foo .inherits__foo\n" + " .foo[state|small] => .base__foo--small\n" + - " [state|large] => .base--large */\n", + " :scope[state|large] => .base--large */\n", ); }); } diff --git a/packages/@css-blocks/core/test/block-interface-test.ts b/packages/@css-blocks/core/test/block-interface-test.ts index 7c974c7db..de2808409 100644 --- a/packages/@css-blocks/core/test/block-interface-test.ts +++ b/packages/@css-blocks/core/test/block-interface-test.ts @@ -25,7 +25,7 @@ export class BlockInterfaceTests extends BEMProcessor { imports.registerSource( "foo/bar/base.css", `:scope { color: purple; } - [state|large] { font-size: 20px; } + :scope[state|large] { font-size: 20px; } .foo { float: left; } .foo[state|small] { font-size: 5px; }`, ); @@ -38,7 +38,7 @@ export class BlockInterfaceTests extends BEMProcessor { return this.assertError( cssBlocks.CssBlockError, - `Missing implementations for: [state|large], .foo[state|small] ` + + `Missing implementations for: :scope[state|large], .foo[state|small] ` + `from foo/bar/base.css`, this.process(filename, inputCSS, config).then(() => { imports.assertImported("foo/bar/base.css"); @@ -50,14 +50,14 @@ export class BlockInterfaceTests extends BEMProcessor { imports.registerSource( "foo/bar/base.css", `:scope { color: purple; } - [state|large] { font-size: 20px; } + :scope[state|large] { font-size: 20px; } .foo { float: left; } .foo[state|small] { font-size: 5px; }`, ); imports.registerSource( "foo/bar/other.css", `:scope { color: purple; } - [state|medium] { font-size: 20px; } + :scope[state|medium] { font-size: 20px; } .foo { float: left; } .foo[state|medium] { font-size: 5px; }`, ); @@ -68,12 +68,12 @@ export class BlockInterfaceTests extends BEMProcessor { :scope { implements: base, other; color: red; } .foo { clear: both; } .b[state|small] {color: blue;} - [state|large] { } + :scope[state|large] { } .foo[state|small] { }`; return this.assertError( cssBlocks.CssBlockError, - `Missing implementations for: [state|medium], .foo[state|medium] ` + + `Missing implementations for: :scope[state|medium], .foo[state|medium] ` + `from foo/bar/other.css`, this.process(filename, inputCSS, config).then(() => { imports.assertImported("foo/bar/base.css"); diff --git a/packages/@css-blocks/core/test/global-states-test.ts b/packages/@css-blocks/core/test/global-states-test.ts index 4993694d7..eac43955d 100644 --- a/packages/@css-blocks/core/test/global-states-test.ts +++ b/packages/@css-blocks/core/test/global-states-test.ts @@ -14,7 +14,7 @@ export class BlockInheritance extends BEMProcessor { imports.registerSource( "app.block.css", `@block-global [state|is-loading]; - [state|is-loading] .profile { + :scope[state|is-loading] .profile { pointer-events: none; }`, ); @@ -37,7 +37,7 @@ export class BlockInheritance extends BEMProcessor { let { imports, config } = setupImporting(); imports.registerSource( "app.block.css", - `[state|is-loading] .profile { + `:scope[state|is-loading] .profile { pointer-events: none; }`, ); @@ -50,7 +50,7 @@ export class BlockInheritance extends BEMProcessor { return assertError( cssBlocks.InvalidBlockSyntax, - "[state|is-loading] is not global: app[state|is-loading] .b (widget.block.css:2:24)", + "Can use global state[state|is-loading] is not global: app[state|is-loading] .b (widget.block.css:2:24)", this.process(filename, inputCSS, config)); } } diff --git a/packages/@css-blocks/core/test/local-scope-test.ts b/packages/@css-blocks/core/test/local-scope-test.ts index df75db29b..f2ebc3733 100644 --- a/packages/@css-blocks/core/test/local-scope-test.ts +++ b/packages/@css-blocks/core/test/local-scope-test.ts @@ -26,7 +26,7 @@ export class LocalScopeLookupTest extends BEMProcessor { imports.registerSource( filename, `:scope { color: purple; } - [state|large] { font-size: 20px; } + :scope[state|large] { font-size: 20px; } .foo { float: left; } .foo[state|small] { font-size: 5px; }`, ); @@ -53,7 +53,7 @@ export class LocalScopeLookupTest extends BEMProcessor { imports.registerSource( "foo/bar/a-block.block.css", `:scope { color: purple; } - [state|large] { font-size: 20px; } + :scope[state|large] { font-size: 20px; } .foo { float: left; } .foo[state|small] { font-size: 5px; }`, ); @@ -90,7 +90,7 @@ export class LocalScopeLookupTest extends BEMProcessor { imports.registerSource( "foo/bar/a-block.block.css", `:scope { color: purple; } - [state|large] { font-size: 20px; } + :scope[state|large] { font-size: 20px; } .foo { float: left; } .foo[state|small] { font-size: 5px; }`, ); diff --git a/packages/@css-blocks/core/test/opticss-test.ts b/packages/@css-blocks/core/test/opticss-test.ts index 81e625590..4b10b9491 100644 --- a/packages/@css-blocks/core/test/opticss-test.ts +++ b/packages/@css-blocks/core/test/opticss-test.ts @@ -58,7 +58,7 @@ export class TemplateAnalysisTests { let filename = "blocks/foo.block.css"; let css = clean` :scope { color: blue; font-size: 20px; } - [state|foo] { color: red; } + :scope[state|foo] { color: red; } .asdf { font-size: 20px; } .asdf[state|larger] { font-size: 26px; color: red; } `; diff --git a/packages/@css-blocks/core/test/query-test.ts b/packages/@css-blocks/core/test/query-test.ts index 77dec1a01..f2932eb1c 100644 --- a/packages/@css-blocks/core/test/query-test.ts +++ b/packages/@css-blocks/core/test/query-test.ts @@ -40,20 +40,20 @@ export class KeyQueryTests { }); } @test "finds states as key selector"() { - let css = `[state|foo] { color: red; } - [state|foo] .a { width: 100%; }`; + let css = `:scope[state|foo] { color: red; } + :scope[state|foo] .a { width: 100%; }`; let filename = "query-test.css"; return this.parseBlock(css, filename).then(([block, root]) => { let state = block.rootClass.allAttributeValues()[0]; - assert.equal(state.asSource(), "[state|foo]"); + assert.equal(state.asSource(), ":scope[state|foo]"); let q = new QueryKeySelector(state); let result = q.execute(root); assert.equal(result.main.length, 1); }); } @test "finds classes as key selector"() { - let css = `[state|foo] { color: red; } - [state|foo] .a { width: 100%; }`; + let css = `:scope[state|foo] { color: red; } + :scope[state|foo] .a { width: 100%; }`; let filename = "query-test.css"; return this.parseBlock(css, filename).then(([block, root]) => { let q = new QueryKeySelector(block.classes[1]); diff --git a/packages/@css-blocks/core/test/resolution-test.ts b/packages/@css-blocks/core/test/resolution-test.ts index 226864f2f..d7c478928 100644 --- a/packages/@css-blocks/core/test/resolution-test.ts +++ b/packages/@css-blocks/core/test/resolution-test.ts @@ -113,9 +113,9 @@ export class BlockInheritance extends BEMProcessor { .main { grid-area: main; font-size: 16px; } .nav { grid-area: nav; border: 1px solid black; } .sidebar { grid-area: sidebar; background-color: #ccc; } - [state|big] .main { font-size: 30px; } - [state|big] > .main { font-size: 40px; } - [state|big] > .main + .main { font-size: 20px; }`, + :scope[state|big] .main { font-size: 30px; } + :scope[state|big] > .main { font-size: 40px; } + :scope[state|big] > .main + .main { font-size: 20px; }`, ); let filename = "conflicts.css"; @@ -143,12 +143,12 @@ export class BlockInheritance extends BEMProcessor { imports.registerSource( "target.css", `.main { color: blue; } - [state|hidden] .main { color: transparent; }`, + :scope[state|hidden] .main { color: transparent; }`, ); let filename = "conflicts.css"; let inputCSS = `@block-reference target from "./target.css"; - [state|happy] .article { + :scope[state|happy] .article { color: green; color: resolve("target.main"); }`; @@ -171,12 +171,12 @@ export class BlockInheritance extends BEMProcessor { imports.registerSource( "target.css", `.main { color: blue; } - [state|hidden] > .main { color: transparent; }`, + :scope[state|hidden] > .main { color: transparent; }`, ); let filename = "conflicts.css"; let inputCSS = `@block-reference target from "./target.css"; - [state|happy] .article { + :scope[state|happy] .article { color: green; color: resolve("target.main"); }`; @@ -198,12 +198,12 @@ export class BlockInheritance extends BEMProcessor { imports.registerSource( "target.css", `.main { color: blue; } - [state|hidden] > .main { color: transparent; }`, + :scope[state|hidden] > .main { color: transparent; }`, ); let filename = "conflicts.css"; let inputCSS = `@block-reference target from "./target.css"; - [state|happy] > .article { + :scope[state|happy] > .article { color: green; color: resolve("target.main"); }`; @@ -231,9 +231,9 @@ export class BlockInheritance extends BEMProcessor { .main { grid-area: main; font-size: 16px; } .nav { grid-area: nav; border: 1px solid black; } .sidebar { grid-area: sidebar; background-color: #ccc; } - [state|big] .main { font-size: 30px; } - [state|big] > .main { font-size: 40px; } - [state|big] > .main + .main { font-size: 20px; }`, + :scope[state|big] .main { font-size: 30px; } + :scope[state|big] > .main { font-size: 40px; } + :scope[state|big] > .main + .main { font-size: 20px; }`, ); let filename = "conflicts.css"; @@ -298,9 +298,9 @@ export class BlockInheritance extends BEMProcessor { imports.registerSource( "other.css", `.foo { font-size: 10px; } - [state|dark] .foo { color: black; } + :scope[state|dark] .foo { color: black; } .bar { font-size: 99px; } - [state|dark] .bar { color: dark-gray; }`, + :scope[state|dark] .bar { color: dark-gray; }`, ); let filename = "conflicts.css"; @@ -436,7 +436,7 @@ export class BlockInheritance extends BEMProcessor { let { imports, config } = setupImporting(); imports.registerSource( "other.css", - `[state|foo] { width: 100%; }`, + `:scope[state|foo] { width: 100%; }`, ); let filename = "conflicts.css"; @@ -533,16 +533,16 @@ export class BlockInheritance extends BEMProcessor { "target.css", `.adjacent + .adjacent { border: 1px; } .sibling ~ .sibling { color: blue; } - [state|ancestor] .descendant { float: left; } - [state|parent] > .child { position: relative; }`, + :scope[state|ancestor] .descendant { float: left; } + :scope[state|parent] > .child { position: relative; }`, ); let filename = "conflicts.css"; let inputCSS = `@block-reference target from "./target.css"; .adjacent + .adjacent { color: green; color: resolve("target.sibling"); } .sibling ~ .sibling { border: 2px; border: resolve("target.adjacent"); } - [state|ancestor] .descendant { position: absolute; position: resolve("target.child"); } - [state|parent] > .child { float: right; float: resolve("target.descendant"); }`; + :scope[state|ancestor] .descendant { position: absolute; position: resolve("target.child"); } + :scope[state|parent] > .child { float: right; float: resolve("target.descendant"); }`; return this.process(filename, inputCSS, config).then((result) => { imports.assertImported("target.css"); @@ -581,7 +581,7 @@ export class BlockInheritance extends BEMProcessor { let filename = "conflicts.css"; let inputCSS = `@block-reference target from "./target.css"; - [state|happy] > .article { + :scope[state|happy] > .article { color: green; color: resolve("target.main"); }`; @@ -599,11 +599,11 @@ export class BlockInheritance extends BEMProcessor { @test "resolving to your own block is illegal"() { let filename = "conflicts.css"; - let inputCSS = `[state|happy] > .article { + let inputCSS = `:scope[state|happy] > .article { color: green; color: resolve(".bio"); } - [state|sad] > .bio { + :scope[state|sad] > .bio { color: blue; }`; diff --git a/packages/@css-blocks/core/test/syntax-test.ts b/packages/@css-blocks/core/test/syntax-test.ts index 75104a72e..e4f7016d3 100644 --- a/packages/@css-blocks/core/test/syntax-test.ts +++ b/packages/@css-blocks/core/test/syntax-test.ts @@ -36,7 +36,7 @@ export class BEMOutputMode extends BEMProcessor { @test "handles states"() { let filename = "foo/bar/test-state.css"; let inputCSS = `:scope {color: #111;} - [state|big] { transform: scale(2); }`; + :scope[state|big] { transform: scale(2); }`; return this.process(filename, inputCSS).then((result) => { assert.deepEqual( result.css.toString(), @@ -49,8 +49,8 @@ export class BEMOutputMode extends BEMProcessor { @test "handles states as scopes"() { let filename = "foo/bar/test-state.css"; let inputCSS = `:scope {color: #111;} - [state|big] .thing { transform: scale(2); } - [state|big] .thing[state|medium] { transform: scale(1.8); }`; + :scope[state|big] .thing { transform: scale(2); } + :scope[state|big] .thing[state|medium] { transform: scale(1.8); }`; return this.process(filename, inputCSS).then((result) => { assert.deepEqual( result.css.toString(), @@ -63,7 +63,7 @@ export class BEMOutputMode extends BEMProcessor { @test "handles comma-delimited states"() { let filename = "foo/bar/test-state.css"; - let inputCSS = `[state|big], [state|really-big] { transform: scale(2); }`; + let inputCSS = `:scope[state|big], :scope[state|really-big] { transform: scale(2); }`; return this.process(filename, inputCSS).then((result) => { assert.deepEqual( result.css.toString(), @@ -75,8 +75,8 @@ export class BEMOutputMode extends BEMProcessor { @skip @test "supports arbitrary whitespace in combinators"() { let filename = "foo/bar/self-combinator.css"; - let inputCSS = `[state|big] - [state|big]::after { content: "" }`; + let inputCSS = `:scope[state|big] + :scope[state|big]::after { content: "" }`; return this.process(filename, inputCSS).then((result) => { assert.deepEqual( result.css.toString(), @@ -87,7 +87,7 @@ export class BEMOutputMode extends BEMProcessor { @test "a state can be combined with itself"() { let filename = "foo/bar/self-combinator.css"; - let inputCSS = `[state|big] + [state|big]::after { content: "" }`; + let inputCSS = `:scope[state|big] + :scope[state|big]::after { content: "" }`; return this.process(filename, inputCSS).then((result) => { assert.deepEqual( result.css.toString(), @@ -99,7 +99,7 @@ export class BEMOutputMode extends BEMProcessor { @test "checkbox with sibling label"() { let filename = "foo/bar/checkbox.block.css"; let inputCSS = ` - :scope:checked + [state|when-checked] { + :scope:checked + :scope[state|when-checked] { color: green; } `; @@ -114,7 +114,7 @@ export class BEMOutputMode extends BEMProcessor { @test "handles exclusive states"() { let filename = "foo/bar/test-state.css"; let inputCSS = `:scope {color: #111;} - [state|font=big] { transform: scale(2); }`; + :scope[state|font=big] { transform: scale(2); }`; return this.process(filename, inputCSS).then((result) => { assert.deepEqual( result.css.toString(), @@ -127,7 +127,7 @@ export class BEMOutputMode extends BEMProcessor { @test "handles exclusive states with single quotes"() { let filename = "foo/bar/test-state.css"; let inputCSS = `:scope {color: #111;} - [state|size='1dp'] { transform: scale(2); }`; + :scope[state|size='1dp'] { transform: scale(2); }`; return this.process(filename, inputCSS).then((result) => { assert.deepEqual( result.css.toString(), @@ -140,7 +140,7 @@ export class BEMOutputMode extends BEMProcessor { @test "handles exclusive states with double quotes"() { let filename = "foo/bar/test-state.css"; let inputCSS = `:scope {color: #111;} - [state|size="1dp"] { transform: scale(2); }`; + :scope[state|size="1dp"] { transform: scale(2); }`; return this.process(filename, inputCSS).then((result) => { assert.deepEqual( result.css.toString(), @@ -152,7 +152,7 @@ export class BEMOutputMode extends BEMProcessor { @test "handles comma-delimited exclusive states"() { let filename = "foo/bar/test-state.css"; - let inputCSS = `[state|font=big], [state|font=really-big] { transform: scale(2); }`; + let inputCSS = `:scope[state|font=big], :scope[state|font=really-big] { transform: scale(2); }`; return this.process(filename, inputCSS).then((result) => { assert.deepEqual( result.css.toString(), @@ -163,7 +163,7 @@ export class BEMOutputMode extends BEMProcessor { @test "a exclusive state can be combined with itself"() { let filename = "foo/bar/self-combinator.css"; - let inputCSS = `[state|font=big] + [state|font=big]::after { content: "" }`; + let inputCSS = `:scope[state|font=big] + :scope[state|font=big]::after { content: "" }`; return this.process(filename, inputCSS).then((result) => { assert.deepEqual( result.css.toString(), @@ -189,7 +189,7 @@ export class BEMOutputMode extends BEMProcessor { let filename = "foo/bar/stateful-class.css"; let inputCSS = `:scope {color: #111;} .my-class { display: none; } - [state|visible] .my-class { display: block; }`; + :scope[state|visible] .my-class { display: block; }`; return this.process(filename, inputCSS).then((result) => { assert.deepEqual( result.css.toString(), @@ -219,7 +219,7 @@ export class BEMOutputMode extends BEMProcessor { let filename = "foo/bar/stateful.css"; let inputCSS = `:scope {color: #111;} .my-class { display: none; } - [state|translucent] .my-class[state|visible] { display: block; opacity: 0.75; }`; + :scope[state|translucent] .my-class[state|visible] { display: block; opacity: 0.75; }`; return this.process(filename, inputCSS).then((result) => { assert.deepEqual( result.css.toString(), @@ -236,17 +236,17 @@ export class StraightJacket extends BEMProcessor { @test "catches invalid states"() { let filename = "foo/bar/test-state.css"; let inputCSS = `:scope {color: #111;} - [state|asdf^=foo] { transform: scale(2); }`; + :scope[state|asdf^=foo] { transform: scale(2); }`; return assertError( cssBlocks.InvalidBlockSyntax, - "A state with a value must use the = operator (found ^= instead). (foo/bar/test-state.css:2:21)", + "A state with a value must use the = operator (found ^= instead). (foo/bar/test-state.css:2:27)", this.process(filename, inputCSS)); } @test "catches states with colon instead of bar"() { let filename = "foo/bar/test-state.css"; let inputCSS = `:scope {color: #111;} - [state:asdf=foo] { transform: scale(2); }`; + :scope[state:asdf=foo] { transform: scale(2); }`; return assertError( cssBlocks.InvalidBlockSyntax, 'Unexpected ":" found. (foo/bar/test-state.css:2:21)', @@ -255,21 +255,21 @@ export class StraightJacket extends BEMProcessor { @test "cannot combine two different states"() { let filename = "foo/bar/illegal-state-combinator.css"; - let inputCSS = `[state|a] [state|b] { float: left; }`; + let inputCSS = `:scope[state|a] :scope[state|b] { float: left; }`; return assertError( cssBlocks.InvalidBlockSyntax, - "Illegal scoping of a root-level state: [state|a] [state|b]" + - " (foo/bar/illegal-state-combinator.css:1:10)", + "Illegal scoping of a root-level state: :scope[state|a] :scope[state|b]" + + " (foo/bar/illegal-state-combinator.css:1:16)", this.process(filename, inputCSS)); } @test "cannot combine two different exclusive states"() { let filename = "foo/bar/illegal-state-combinator.css"; - let inputCSS = `[state|a] [state|exclusive=b] { float: left; }`; + let inputCSS = `:scope[state|a] :scope[state|exclusive=b] { float: left; }`; return assertError( cssBlocks.InvalidBlockSyntax, - "Illegal scoping of a root-level state: [state|a] [state|exclusive=b]" + - " (foo/bar/illegal-state-combinator.css:1:10)", + "Illegal scoping of a root-level state: :scope[state|a] :scope[state|exclusive=b]" + + " (foo/bar/illegal-state-combinator.css:1:16)", this.process(filename, inputCSS)); } @@ -287,33 +287,33 @@ export class StraightJacket extends BEMProcessor { @test "disallows sibling combinators with root states"() { let filename = "foo/bar/illegal-class-combinator.css"; let inputCSS = `:scope {color: #111;} - [state|foo] ~ .another-class { display: block; }`; + :scope[state|foo] ~ .another-class { display: block; }`; return assertError( cssBlocks.InvalidBlockSyntax, - "A class cannot be a sibling with a root-level state: [state|foo] ~ .another-class" + - " (foo/bar/illegal-class-combinator.css:2:33)", + "A class cannot be a sibling with a root-level state: :scope[state|foo] ~ .another-class" + + " (foo/bar/illegal-class-combinator.css:2:39)", this.process(filename, inputCSS)); } @test "disallows sibling combinators with root states after adjacent root"() { let filename = "foo/bar/illegal-class-combinator.css"; let inputCSS = `:scope {color: #111;} - [state|foo] + [state|foo] ~ .another-class { display: block; }`; + :scope[state|foo] + :scope[state|foo] ~ .another-class { display: block; }`; return assertError( cssBlocks.InvalidBlockSyntax, - "A class cannot be a sibling with a root-level state: [state|foo] + [state|foo] ~ .another-class" + - " (foo/bar/illegal-class-combinator.css:2:47)", + "A class cannot be a sibling with a root-level state: :scope[state|foo] + :scope[state|foo] ~ .another-class" + + " (foo/bar/illegal-class-combinator.css:2:59)", this.process(filename, inputCSS)); } @test "disallows adjacent sibling combinators with root states"() { let filename = "foo/bar/illegal-class-combinator.css"; let inputCSS = `:scope {color: #111;} - [state|foo] + .another-class { display: block; }`; + :scope[state|foo] + .another-class { display: block; }`; return assertError( cssBlocks.InvalidBlockSyntax, - "A class cannot be a sibling with a root-level state: [state|foo] + .another-class" + - " (foo/bar/illegal-class-combinator.css:2:33)", + "A class cannot be a sibling with a root-level state: :scope[state|foo] + .another-class" + + " (foo/bar/illegal-class-combinator.css:2:39)", this.process(filename, inputCSS)); } @@ -331,7 +331,7 @@ export class StraightJacket extends BEMProcessor { @test "allows combining states without a combinator"() { let filename = "foo/bar/multi-state.css"; let inputCSS = `:scope {color: #111;} - [state|first][state|second] { display: block; }`; + :scope[state|first][state|second] { display: block; }`; return this.process(filename, inputCSS).then((result) => { assert.deepEqual( result.css.toString(), @@ -401,10 +401,10 @@ export class StraightJacket extends BEMProcessor { @test "disallows a state before a class for the same element."() { let filename = "foo/bar/illegal-class-combinator.css"; let inputCSS = `:scope {color: #111;} - [state|foo].another-class { display: block; }`; + :scope[state|foo].another-class { display: block; }`; return assertError( cssBlocks.InvalidBlockSyntax, - "The class must precede the state: [state|foo].another-class" + + "The class must precede the state: :scope[state|foo].another-class" + " (foo/bar/illegal-class-combinator.css:2:21)", this.process(filename, inputCSS)); } @@ -418,13 +418,13 @@ export class StraightJacket extends BEMProcessor { " (foo/bar/illegal-class-combinator.css:2:21)", this.process(filename, inputCSS)); } - @test "disallows combining states and block without a combinator"() { + @test "disallows bare state selectors (for now!)"() { let filename = "foo/bar/illegal-class-combinator.css"; let inputCSS = `:scope {color: #111;} - :scope[state|foo] { display: block; }`; + [state|foo] { display: block; }`; return assertError( cssBlocks.InvalidBlockSyntax, - "It's redundant to specify a state with an explicit .root: :scope[state|foo]" + + "States without an explicit :scope or class selector are not yet supported: [state|foo]" + " (foo/bar/illegal-class-combinator.css:2:21)", this.process(filename, inputCSS)); } @@ -445,8 +445,8 @@ export class BlockReferences extends BEMProcessor { imports.registerSource( "foo/bar/imported.css", `:scope { color: purple; } - [state|large] { font-size: 20px; } - [state|theme=red] { color: red; } + :scope[state|large] { font-size: 20px; } + :scope[state|theme=red] { color: red; } .foo { float: left; } .foo[state|small] { font-size: 5px; } .foo[state|font=fancy] { font-family: fancy; }`, @@ -467,8 +467,8 @@ export class BlockReferences extends BEMProcessor { " .foo => .imported__foo\n" + " .foo[state|font=fancy] => .imported__foo--font-fancy\n" + " .foo[state|small] => .imported__foo--small\n" + - " [state|large] => .imported--large\n" + - " [state|theme=red] => .imported--theme-red */\n" + + " :scope[state|large] => .imported--large\n" + + " :scope[state|theme=red] => .imported--theme-red */\n" + ".test-block { color: red; }\n" + ".test-block__b--big { color: blue; }\n", ); @@ -700,7 +700,7 @@ export class BlockReferences extends BEMProcessor { let inputCSS = ` :scope { color: red; } @media all and (max-width: 400px) { - [state|responsive] { color: blue; } + :scope[state|responsive] { color: blue; } .a-class { width: 100%; } }`; diff --git a/packages/@css-blocks/core/test/template-analysis-test.ts b/packages/@css-blocks/core/test/template-analysis-test.ts index b00348262..835977848 100644 --- a/packages/@css-blocks/core/test/template-analysis-test.ts +++ b/packages/@css-blocks/core/test/template-analysis-test.ts @@ -36,7 +36,7 @@ export class AnalysisTests { let analysis = analyzer.newAnalysis(info); let css = ` :scope { color: blue; } - [state|foo] { color: red; } + :scope[state|foo] { color: red; } .asdf { font-size: 20px; } .asdf[state|larger] { font-size: 26px; } `; @@ -68,7 +68,7 @@ export class AnalysisTests { let analysis = analyzer.newAnalysis(info); let css = ` :scope { color: blue; } - [state|foo] { color: red; } + :scope[state|foo] { color: red; } .asdf { font-size: 20px; } .asdf[state|larger] { font-size: 26px; } `; @@ -102,7 +102,7 @@ export class AnalysisTests { let analysis = analyzer.newAnalysis(info); let css = ` :scope { color: blue; } - [state|foo] { color: red; } + :scope[state|foo] { color: red; } .asdf { font-size: 20px; } .asdf[state|larger] { font-size: 26px; } `; @@ -143,7 +143,7 @@ export class AnalysisTests { let analysis = analyzer.newAnalysis(info); let css = ` :scope { color: blue; } - [state|foo] { color: red; } + :scope[state|foo] { color: red; } .asdf { font-size: 20px; } .asdf[state|larger] { font-size: 26px; } `; @@ -196,7 +196,7 @@ export class AnalysisTests { @block-reference a from "a.css"; :scope { color: blue; } - [state|foo] { color: red; } + :scope[state|foo] { color: red; } .asdf { font-size: 20px; } .asdf[state|larger] { font-size: 26px; } .fdsa { font-size: 20px; } @@ -239,8 +239,8 @@ export class AnalysisTests { let { config } = setupImporting(); let css = ` - [state|color] { color: red; } - [state|bgcolor] { color: red; } + :scope[state|color] { color: red; } + :scope[state|bgcolor] { color: red; } `; return this.parseBlock(css, "blocks/foo.block.css", config).then(([block, _]) => { analysis.addBlock("", block); @@ -254,7 +254,7 @@ export class AnalysisTests { let expectedResult: SerializedAnalysis = { blocks: {"": "blocks/foo.block.css"}, template: { type: "Opticss.Template", identifier: "templates/my-template.hbs"}, - stylesFound: [":scope", "[state|bgcolor]", "[state|color]"], + stylesFound: [":scope", ":scope[state|bgcolor]", ":scope[state|color]"], elements: { a: { sourceLocation: { start: { filename: "templates/my-template.hbs", line: 10, column: 32 } }, @@ -278,10 +278,10 @@ export class AnalysisTests { let { config } = setupImporting(); let css = ` - [state|color=red] { color: red; } - [state|color=blue] { color: blue; } - [state|bgcolor=red] { color: red; } - [state|bgcolor=blue] { color: blue; } + :scope[state|color=red] { color: red; } + :scope[state|color=blue] { color: blue; } + :scope[state|bgcolor=red] { color: red; } + :scope[state|bgcolor=blue] { color: blue; } `; return this.parseBlock(css, "blocks/foo.block.css", config).then(([block, _]) => { analysis.addBlock("", block); @@ -297,10 +297,10 @@ export class AnalysisTests { template: { type: "Opticss.Template", identifier: "templates/my-template.hbs"}, stylesFound: [ ":scope", - "[state|bgcolor=blue]", - "[state|bgcolor=red]", - "[state|color=blue]", - "[state|color=red]", + ":scope[state|bgcolor=blue]", + ":scope[state|bgcolor=red]", + ":scope[state|color=blue]", + ":scope[state|color=red]", ], elements: { "a": { @@ -349,7 +349,7 @@ export class AnalysisTests { @block-reference a from "a.css"; :scope { color: blue; } - [state|foo] { color: red; } + :scope[state|foo] { color: red; } .asdf { font-size: 20px; } .asdf[state|larger] { font-size: 26px; } .fdsa { font-size: 20px; } @@ -404,7 +404,7 @@ export class AnalysisTests { @block-reference a from "a.css"; :scope { color: blue; } - [state|foo] { color: red; } + :scope[state|foo] { color: red; } .asdf { font-size: resolve('a.foo[state|bar]'); font-size: 20px; } .fdsa { font-size: resolve('a.foo[state|bar]'); font-size: 22px; } `; @@ -454,8 +454,8 @@ export class AnalysisTests { @block-reference a from "a.css"; :scope { color: blue; } - [state|foo=red] { color: red; } - [state|foo=purple] { color: purple; } + :scope[state|foo=red] { color: red; } + :scope[state|foo=purple] { color: purple; } .asdf { font-size: 20px; } .fdsa { font-size: 22px; } `; @@ -469,7 +469,7 @@ export class AnalysisTests { let expectedResult: SerializedAnalysis = { blocks: {"": "blocks/foo.block.css"}, template: { type: "Opticss.Template", identifier: "templates/my-template.hbs"}, - stylesFound: [":scope", "[state|foo=purple]", "[state|foo=red]"], + stylesFound: [":scope", ":scope[state|foo=purple]", ":scope[state|foo=red]"], elements: { a: { staticStyles: [ 0 ], @@ -500,7 +500,7 @@ export class AnalysisTests { @block-reference a from "a.css"; :scope { color: blue; } - [state|foo] { color: red; } + :scope[state|foo] { color: red; } .asdf { font-size: resolve('a.foo[state|bar]'); font-size: 20px; } .fdsa { font-size: 22px; font-size: resolve('a.foo[state|bar]'); } `; @@ -567,7 +567,7 @@ export class AnalysisTests { let css = ` :scope { color: blue; } - [state|foo] { color: red; } + :scope[state|foo] { color: red; } .asdf { font-size: 20px; } .asdf[state|larger] { font-size: 26px; } .fdsa { font-size: 20px; } @@ -594,7 +594,7 @@ export class AnalysisTests { let css = ` :scope { color: blue; } - [state|foo] { color: red; } + :scope[state|foo] { color: red; } .asdf { font-size: 20px; } .asdf[state|larger] { font-size: 26px; } .fdsa { font-size: 20px; } @@ -637,7 +637,7 @@ export class AnalysisTests { let css = ` :scope { color: blue; } - [state|foo] { color: red; } + :scope[state|foo] { color: red; } .asdf { font-size: 20px; } .asdf[state|larger] { font-size: 26px; } .fdsa { font-size: 20px; } @@ -665,7 +665,7 @@ export class AnalysisTests { let css = ` :scope { color: blue; } - [state|foo] { color: red; } + :scope[state|foo] { color: red; } .asdf { font-size: 20px; } .asdf[state|larger] { font-size: 26px; } .fdsa { font-size: 20px; } @@ -737,11 +737,11 @@ export class AnalysisTests { let css = ` :scope { color: blue; } - [state|test] { color: red; } + :scope[state|test] { color: red; } `; return assertParseError( cssBlocks.TemplateAnalysisError, - 'Cannot use state "[state|test]" without parent block also applied or implied by another style. (templates/my-template.hbs:10:32)', + 'Cannot use state ":scope[state|test]" without parent block also applied or implied by another style. (templates/my-template.hbs:10:32)', this.parseBlock(css, "blocks/foo.block.css", config).then(([block, _]) => { analysis.addBlock("", block); let element = analysis.startElement({ line: 10, column: 32 }); @@ -864,7 +864,7 @@ export class AnalysisTests { let source = ` :scope {} .myclass {} - [state|a-state] {} + :scope[state|a-state] {} .myclass[state|a-sub-state] {} `; let processPromise = postcss().process(source, {from: "test.css"}); diff --git a/packages/@css-blocks/core/test/validations/attribute-group-validator-test.ts b/packages/@css-blocks/core/test/validations/attribute-group-validator-test.ts index b1978ef25..b46f9459a 100644 --- a/packages/@css-blocks/core/test/validations/attribute-group-validator-test.ts +++ b/packages/@css-blocks/core/test/validations/attribute-group-validator-test.ts @@ -32,12 +32,12 @@ export class TemplateAnalysisTests { let css = ` :scope { color: blue; } - [state|test=foo] { color: red; } - [state|test=bar] { color: blue; } + :scope[state|test=foo] { color: red; } + :scope[state|test=bar] { color: blue; } `; return assertParseError( cssBlocks.TemplateAnalysisError, - 'Can not apply multiple states at the same time from the exclusive state group "[state|test]". (templates/my-template.hbs:10:32)', + 'Can not apply multiple states at the same time from the exclusive state group ":scope[state|test]". (templates/my-template.hbs:10:32)', this.parseBlock(css, "blocks/foo.block.css", config).then(([block, _]) => { analysis.addBlock("", block); let element = analysis.startElement({ line: 10, column: 32 }); @@ -57,12 +57,12 @@ export class TemplateAnalysisTests { let css = ` :scope { color: blue; } - [state|test=foo] { color: red; } - [state|test=bar] { color: blue; } + :scope[state|test=foo] { color: red; } + :scope[state|test=bar] { color: blue; } `; return assertParseError( cssBlocks.TemplateAnalysisError, - 'Can not apply multiple states at the same time from the exclusive state group "[state|test]". (templates/my-template.hbs:10:32)', + 'Can not apply multiple states at the same time from the exclusive state group ":scope[state|test]". (templates/my-template.hbs:10:32)', this.parseBlock(css, "blocks/foo.block.css", config).then(([block, _]) => { analysis.addBlock("", block); let element = analysis.startElement({ line: 10, column: 32 }); @@ -82,12 +82,12 @@ export class TemplateAnalysisTests { let css = ` :scope { color: blue; } - [state|test=foo] { color: red; } - [state|test=bar] { color: blue; } + :scope[state|test=foo] { color: red; } + :scope[state|test=bar] { color: blue; } `; return assertParseError( cssBlocks.TemplateAnalysisError, - 'Can not apply multiple states at the same time from the exclusive state group "[state|test]". (templates/my-template.hbs:10:32)', + 'Can not apply multiple states at the same time from the exclusive state group ":scope[state|test]". (templates/my-template.hbs:10:32)', this.parseBlock(css, "blocks/foo.block.css", config).then(([block, _]) => { analysis.addBlock("", block); let element = analysis.startElement({ line: 10, column: 32 }); @@ -107,12 +107,12 @@ export class TemplateAnalysisTests { let css = ` :scope { color: blue; } - [state|test=foo] { color: red; } - [state|test=bar] { color: blue; } + :scope[state|test=foo] { color: red; } + :scope[state|test=bar] { color: blue; } `; return assertParseError( cssBlocks.TemplateAnalysisError, - 'Can not apply multiple states at the same time from the exclusive state group "[state|test]". (templates/my-template.hbs:10:32)', + 'Can not apply multiple states at the same time from the exclusive state group ":scope[state|test]". (templates/my-template.hbs:10:32)', this.parseBlock(css, "blocks/foo.block.css", config).then(([block, _]) => { analysis.addBlock("", block); let element = analysis.startElement({ line: 10, column: 32 }); diff --git a/packages/@css-blocks/core/test/validations/attribute-parent-validator-test.ts b/packages/@css-blocks/core/test/validations/attribute-parent-validator-test.ts index 3d9a58d76..695ddc27f 100644 --- a/packages/@css-blocks/core/test/validations/attribute-parent-validator-test.ts +++ b/packages/@css-blocks/core/test/validations/attribute-parent-validator-test.ts @@ -33,11 +33,11 @@ export class TemplateAnalysisTests { let css = ` :scope { color: blue; } - [state|test] { color: red; } + :scope[state|test] { color: red; } `; return assertParseError( cssBlocks.TemplateAnalysisError, - 'Cannot use state "[state|test]" without parent block also applied or implied by another style. (templates/my-template.hbs:10:32)', + 'Cannot use state ":scope[state|test]" without parent block also applied or implied by another style. (templates/my-template.hbs:10:32)', this.parseBlock(css, "blocks/foo.block.css", config).then(([block, _]) => { analysis.addBlock("", block); let element = analysis.startElement({ line: 10, column: 32 }); diff --git a/packages/@css-blocks/core/test/validations/class-pairs-validator-test.ts b/packages/@css-blocks/core/test/validations/class-pairs-validator-test.ts index eb088b823..16ec9e7a8 100644 --- a/packages/@css-blocks/core/test/validations/class-pairs-validator-test.ts +++ b/packages/@css-blocks/core/test/validations/class-pairs-validator-test.ts @@ -32,7 +32,7 @@ export class TemplateAnalysisTests { let css = ` :scope { color: blue; } - [state|foo] { color: red; } + :scope[state|foo] { color: red; } .asdf { font-size: 20px; } .asdf[state|larger] { font-size: 26px; } .fdsa { font-size: 20px; } diff --git a/packages/@css-blocks/core/test/validations/property-conflict-validator-test.ts b/packages/@css-blocks/core/test/validations/property-conflict-validator-test.ts index c41225520..de45849df 100644 --- a/packages/@css-blocks/core/test/validations/property-conflict-validator-test.ts +++ b/packages/@css-blocks/core/test/validations/property-conflict-validator-test.ts @@ -136,7 +136,7 @@ export class TemplateAnalysisTests { imports.registerSource("blocks/b.block.css", ` :scope { block-name: block-b; } .klass { color: blue; background: yellow; } - [state|colorful] .klass { color: red; } + :scope[state|colorful] .klass { color: red; } `); let css = ` @@ -152,7 +152,7 @@ export class TemplateAnalysisTests { color: block-a.klass (blocks/foo.block.css:4:16) - block-b.klass (blocks/b.block.css:4:33)`, + block-b.klass (blocks/b.block.css:4:39)`, this.parseBlock(css, "blocks/foo.block.css", options).then(([block, _]) => { constructElement(block, ".klass", "b.klass").end(); @@ -167,7 +167,7 @@ export class TemplateAnalysisTests { imports.registerSource("blocks/b.block.css", ` :scope { block-name: block-b; } .klass { color: blue; background: yellow; } - [state|colorful] .klass { color: red; } + :scope[state|colorful] .klass { color: red; } `); let css = ` @@ -552,7 +552,7 @@ export class TemplateAnalysisTests { let css = ` @block-reference b from "./b.block.css"; :scope { block-name: block-a; } - [state|foo] { color: red; background-color: red; } + :scope[state|foo] { color: red; background-color: red; } `; return assertParseError( @@ -562,11 +562,11 @@ export class TemplateAnalysisTests { color: block-b:scope (blocks/b.block.css:1:31) - block-a[state|foo] (blocks/foo.block.css:4:21) + block-a:scope[state|foo] (blocks/foo.block.css:4:27) background-color: block-b:scope (blocks/b.block.css:1:44) - block-a[state|foo] (blocks/foo.block.css:4:33)`, + block-a:scope[state|foo] (blocks/foo.block.css:4:39)`, this.parseBlock(css, "blocks/foo.block.css", options).then(([block, _]) => { constructElement(block, ":scope", "b").addDynamic("[state|foo]").end(); @@ -587,7 +587,7 @@ export class TemplateAnalysisTests { let css = ` @block-reference b from "./b.block.css"; :scope { block-name: block-a; } - [state|foo] { + :scope[state|foo] { color: resolve('b'); color: red; background-color: red; @@ -662,14 +662,14 @@ export class TemplateAnalysisTests { imports.registerSource("blocks/b.block.css", ` :scope { block-name: block-b; } - [state|bar] { color: blue; background-color: yellow; } + :scope[state|bar] { color: blue; background-color: yellow; } `, ); let css = ` @block-reference b from "./b.block.css"; :scope { block-name: block-a; } - [state|foo] { color: red; background-color: red; } + :scope[state|foo] { color: red; background-color: red; } `; return assertParseError( @@ -678,15 +678,15 @@ export class TemplateAnalysisTests { The following property conflicts must be resolved for these co-located Styles: (templates/my-template.hbs:10:32) color: - block-a[state|foo] (blocks/foo.block.css:4:21) - block-b[state|bar] (blocks/b.block.css:3:21) + block-a:scope[state|foo] (blocks/foo.block.css:4:27) + block-b:scope[state|bar] (blocks/b.block.css:3:27) background-color: - block-a[state|foo] (blocks/foo.block.css:4:33) - block-b[state|bar] (blocks/b.block.css:3:34)`, + block-a:scope[state|foo] (blocks/foo.block.css:4:39) + block-b:scope[state|bar] (blocks/b.block.css:3:40)`, this.parseBlock(css, "blocks/foo.block.css", options).then(([block, _]) => { - constructElement(block, ":scope", "b").addDynamic("[state|foo]").addDynamic("b[state|bar]").end(); + constructElement(block, ":scope", "b").addDynamic("[state|foo]").addDynamic("b:scope[state|bar]").end(); }).then(() => { assert.ok(1, "does not throw"); })); @@ -698,22 +698,22 @@ export class TemplateAnalysisTests { imports.registerSource("blocks/b.block.css", ` :scope { block-name: block-b; } - [state|bar] { color: blue; background-color: yellow; } + :scope[state|bar] { color: blue; background-color: yellow; } `, ); let css = ` @block-reference b from "./b.block.css"; :scope { block-name: block-a; } - [state|foo] { - color: resolve('b[state|bar]'); + :scope[state|foo] { + color: resolve('b:scope[state|bar]'); color: red; background-color: red; - background-color: resolve('b[state|bar]'); } + background-color: resolve('b:scope[state|bar]'); } `; return this.parseBlock(css, "blocks/foo.block.css", options).then(([block, _]) => { - constructElement(block, ":scope", "b").addDynamic("[state|foo]").addDynamic("b[state|bar]").end(); + constructElement(block, ":scope", "b:scope").addDynamic(":scope[state|foo]").addDynamic("b:scope[state|bar]").end(); }).then(() => { assert.equal(1, 1); }); @@ -731,8 +731,8 @@ export class TemplateAnalysisTests { let css = ` @block-reference b from "./b.block.css"; :scope { block-name: block-a; } - [state|foo=one] { color: red; background-color: red; } - [state|foo=two] { text-decoration: underline; } + :scope[state|foo=one] { color: red; background-color: red; } + :scope[state|foo=two] { text-decoration: underline; } `; return assertParseError( @@ -742,11 +742,11 @@ export class TemplateAnalysisTests { color: block-b:scope (blocks/b.block.css:2:37) - block-a[state|foo=one] (blocks/foo.block.css:4:25) + block-a:scope[state|foo=one] (blocks/foo.block.css:4:31) background-color: block-b:scope (blocks/b.block.css:2:50) - block-a[state|foo=one] (blocks/foo.block.css:4:37)`, + block-a:scope[state|foo=one] (blocks/foo.block.css:4:43)`, this.parseBlock(css, "blocks/foo.block.css", options).then(([block, _]) => { constructElement(block, ":scope", "b").addStateGroup(":scope", "[state|foo]").end(); @@ -767,8 +767,8 @@ export class TemplateAnalysisTests { let css = ` @block-reference b from "./b.block.css"; :scope { block-name: block-a; } - [state|foo=one] { color: resolve('b'); color: red; background-color: red; background-color: resolve('b'); } - [state|foo=two] { text-decoration: underline; } + :scope[state|foo=one] { color: resolve('b'); color: red; background-color: red; background-color: resolve('b'); } + :scope[state|foo=two] { text-decoration: underline; } `; return this.parseBlock(css, "blocks/foo.block.css", options).then(([block, _]) => { @@ -784,16 +784,16 @@ export class TemplateAnalysisTests { imports.registerSource("blocks/b.block.css", ` :scope { block-name: block-b; color: blue; background-color: yellow; } - [state|bar=one] { color: red; background-color: red; } - [state|bar=two] { color: yellow; background-color: purple; } + :scope[state|bar=one] { color: red; background-color: red; } + :scope[state|bar=two] { color: yellow; background-color: purple; } `, ); let css = ` @block-reference b from "./b.block.css"; :scope { block-name: block-a; } - [state|foo=one] { color: orange; background-color: green; } - [state|foo=two] { text-decoration: underline; } + :scope[state|foo=one] { color: orange; background-color: green; } + :scope[state|foo=two] { text-decoration: underline; } `; return assertParseError( @@ -803,15 +803,15 @@ export class TemplateAnalysisTests { color: block-b:scope (blocks/b.block.css:2:37) - block-a[state|foo=one] (blocks/foo.block.css:4:25) - block-b[state|bar=one] (blocks/b.block.css:3:25) - block-b[state|bar=two] (blocks/b.block.css:4:25) + block-a:scope[state|foo=one] (blocks/foo.block.css:4:31) + block-b:scope[state|bar=one] (blocks/b.block.css:3:31) + block-b:scope[state|bar=two] (blocks/b.block.css:4:31) background-color: block-b:scope (blocks/b.block.css:2:50) - block-a[state|foo=one] (blocks/foo.block.css:4:40) - block-b[state|bar=one] (blocks/b.block.css:3:37) - block-b[state|bar=two] (blocks/b.block.css:4:40)`, + block-a:scope[state|foo=one] (blocks/foo.block.css:4:46) + block-b:scope[state|bar=one] (blocks/b.block.css:3:43) + block-b:scope[state|bar=two] (blocks/b.block.css:4:46)`, this.parseBlock(css, "blocks/foo.block.css", options).then(([block, _]) => { constructElement(block, ":scope", "b").addStateGroup(":scope", "[state|foo]").addStateGroup("b", "[state|bar]").end(); diff --git a/packages/@css-blocks/core/test/validations/root-class-validator-test.ts b/packages/@css-blocks/core/test/validations/root-class-validator-test.ts index 1f0c6972c..13a66ecc1 100644 --- a/packages/@css-blocks/core/test/validations/root-class-validator-test.ts +++ b/packages/@css-blocks/core/test/validations/root-class-validator-test.ts @@ -34,7 +34,7 @@ export class AnalysisTests { let css = ` :scope { color: blue; } - [state|foo] { color: red; } + :scope[state|foo] { color: red; } .asdf { font-size: 20px; } .asdf[state|larger] { font-size: 26px; } .fdsa { font-size: 20px; } @@ -62,7 +62,7 @@ export class AnalysisTests { let css = ` :scope { color: blue; } - [state|foo] { color: red; } + :scope[state|foo] { color: red; } .asdf { font-size: 20px; } .asdf[state|larger] { font-size: 26px; } .fdsa { font-size: 20px; } diff --git a/packages/@css-blocks/core/test/validations/validator-test.ts b/packages/@css-blocks/core/test/validations/validator-test.ts index 117ba4a98..b395ddf5e 100644 --- a/packages/@css-blocks/core/test/validations/validator-test.ts +++ b/packages/@css-blocks/core/test/validations/validator-test.ts @@ -32,7 +32,7 @@ export class TemplateAnalysisTests { let css = ` :scope { color: blue; } - [state|foo] { color: red; } + :scope[state|foo] { color: red; } .asdf { font-size: 20px; } .asdf[state|larger] { font-size: 26px; } .fdsa { font-size: 20px; } diff --git a/packages/@css-blocks/jsx/test/analyzer/dynamic-styles-test.ts b/packages/@css-blocks/jsx/test/analyzer/dynamic-styles-test.ts index 32ed330ad..8476dc7e1 100644 --- a/packages/@css-blocks/jsx/test/analyzer/dynamic-styles-test.ts +++ b/packages/@css-blocks/jsx/test/analyzer/dynamic-styles-test.ts @@ -91,7 +91,7 @@ export class Test { mock({ "foo.block.css": ` :scope { } - [state|cool=foo] { } + :scope[state|cool=foo] { } `, }); diff --git a/packages/@css-blocks/jsx/test/analyzer/root-states-objstr-test.ts b/packages/@css-blocks/jsx/test/analyzer/root-states-objstr-test.ts index 9110b00bc..a251a8654 100644 --- a/packages/@css-blocks/jsx/test/analyzer/root-states-objstr-test.ts +++ b/packages/@css-blocks/jsx/test/analyzer/root-states-objstr-test.ts @@ -16,7 +16,7 @@ export class Test { mock({ "bar.block.css": ` :scope { color: blue; } - [state|color=yellow] { + :scope[state|color=yellow] { color: yellow; } `, @@ -47,10 +47,10 @@ export class Test { mock({ "bar.block.css": ` :scope { color: blue; } - [state|color=yellow] { + :scope[state|color=yellow] { color: yellow; } - [state|color=green] { + :scope[state|color=green] { color: green; } `, @@ -81,7 +81,7 @@ export class Test { mock({ "bar.block.css": ` :scope { color: blue; } - [state|awesome] { + :scope[state|awesome] { color: yellow; } `, @@ -111,7 +111,7 @@ export class Test { mock({ "bar.block.css": ` :scope { color: blue; } - [state|awesome] { + :scope[state|awesome] { color: yellow; } `, @@ -141,7 +141,7 @@ export class Test { mock({ "bar.block.css": ` :scope { color: blue; } - [state|awesome] { + :scope[state|awesome] { color: yellow; } `, @@ -161,7 +161,7 @@ export class Test { assert.ok(false, "should not have succeeded."); }, (err) => { - assert.equal(err.message, '[css-blocks] MalformedBlockPath: No state [state|awesome=wat] found on block "bar".\n Did you mean: [state|awesome]? (7:9)'); + assert.equal(err.message, '[css-blocks] MalformedBlockPath: No state :scope[state|awesome=wat] found on block "bar".\n Did you mean: :scope[state|awesome]? (7:9)'); }); } @@ -169,7 +169,7 @@ export class Test { mock({ "bar.block.css": ` :scope { color: blue; } - [state|awesome] { + :scope[state|awesome] { color: yellow; } .pretty[state|awesome] { diff --git a/packages/@css-blocks/jsx/test/transformer/transformer-test.ts b/packages/@css-blocks/jsx/test/transformer/transformer-test.ts index ca9e78281..1b479ea02 100644 --- a/packages/@css-blocks/jsx/test/transformer/transformer-test.ts +++ b/packages/@css-blocks/jsx/test/transformer/transformer-test.ts @@ -431,7 +431,7 @@ export class Test { mock({ "foo.block.css": ` :scope { } - [state|cool] { } + :scope[state|cool] { } `, }); diff --git a/packages/@css-blocks/webpack/src/Plugin.ts b/packages/@css-blocks/webpack/src/Plugin.ts index 80aa4baba..6e89bad37 100644 --- a/packages/@css-blocks/webpack/src/Plugin.ts +++ b/packages/@css-blocks/webpack/src/Plugin.ts @@ -70,59 +70,6 @@ interface CompilationResult { analyses: Array>; } -export class CssBlocksRewriterPlugin - extends Tapable - implements WebpackPlugin -{ - parent: CssBlocksPlugin; - compilationOptions: CSSBlocksOptions; - outputCssFile: string; - name: string; - debug: debugGenerator.IDebugger; - pendingResult?: PendingResult; - constructor(parent: CssBlocksPlugin) { - super(); - this.debug = parent.debug; - this.outputCssFile = parent.outputCssFile; - this.name = parent.name; - this.compilationOptions = parent.compilationOptions; - this.parent = parent; - parent.onCompilationExpiration(() => { - this.trace(`resetting pending compilation.`); - this.pendingResult = undefined; - }); - parent.onPendingCompilation((pendingResult) => { - this.trace(`received pending compilation.`); - this.pendingResult = pendingResult; - }); - } - - apply(compiler: WebpackCompiler) { - compiler.plugin("compilation", (compilation: WebpackAny) => { - compilation.plugin("normal-module-loader", (context: LoaderContext, mod: WebpackAny) => { - this.trace(`preparing normal-module-loader for ${mod.resource}`); - context.cssBlocks = context.cssBlocks || { mappings: {}, compilationOptions: this.compilationOptions }; - - // If we're already waiting for a css file of this name to finish compiling, throw. - if (context.cssBlocks.mappings[this.outputCssFile]) { - throw new Error(`css conflict detected. Multiple compiles writing to ${this.parent.outputCssFile}?`); - } - - if (this.pendingResult === undefined) { - throw new Error(`No pending result is available yet.`); - } - context.cssBlocks.mappings[this.outputCssFile] = this.pendingResult; - }); - }); - } - - trace(message: string) { - message = message.replace(this.parent.projectDir + "/", ""); - this.debug(`[${this.name}] ${message}`); - } - -} - export class CssBlocksPlugin extends Tapable implements WebpackPlugin @@ -133,6 +80,7 @@ export class CssBlocksPlugin projectDir: string; outputCssFile: string; compilationOptions: CSSBlocksOptions; + pendingResult?: PendingResult; debug: debugGenerator.IDebugger; constructor(options: CssBlocksWebpackOptions) { @@ -147,10 +95,6 @@ export class CssBlocksPlugin this.optimizationOptions = Object.assign({}, DEFAULT_OPTIONS, options.optimization); } - getRewriterPlugin(): CssBlocksRewriterPlugin { - return new CssBlocksRewriterPlugin(this); - } - private async handleMake(outputPath: string, assets: Assets, compilation: WebpackAny, cb: (error?: Error) => void) { // Start analysis with a clean analysis object this.trace(`starting analysis.`); @@ -251,7 +195,42 @@ export class CssBlocksPlugin compiler.plugin("make", this.handleMake.bind(this, outputPath, assets)); - this.getRewriterPlugin().apply(compiler); + // Once we're done, add all discovered block files to the build dependencies + // so this plugin is re-evaluated when they change. + // TODO: We get timestamp data here. We can probably intelligently re-build. + compiler.plugin("emit", (compilation, callback) => { + let discoveredFiles = [...this.analyzer.transitiveBlockDependencies()].map((b) => b.identifier); + compilation.fileDependencies.push(...discoveredFiles); + callback(); + }); + + this.onCompilationExpiration(() => { + this.trace(`resetting pending compilation.`); + this.pendingResult = undefined; + }); + + this.onPendingCompilation((pendingResult) => { + this.trace(`received pending compilation.`); + this.pendingResult = pendingResult; + }); + + compiler.plugin("compilation", (compilation: WebpackAny) => { + compilation.plugin("normal-module-loader", (context: LoaderContext, mod: WebpackAny) => { + this.trace(`preparing normal-module-loader for ${mod.resource}`); + context.cssBlocks = context.cssBlocks || { mappings: {}, compilationOptions: this.compilationOptions }; + + // If we're already waiting for a css file of this name to finish compiling, throw. + if (context.cssBlocks.mappings[this.outputCssFile]) { + throw new Error(`css conflict detected. Multiple compiles writing to ${this.outputCssFile}?`); + } + + if (this.pendingResult === undefined) { + throw new Error(`No pending result is available yet.`); + } + context.cssBlocks.mappings[this.outputCssFile] = this.pendingResult; + }); + }); + } private compileBlocks(analyzer: Analyzer, cssOutputName: string): Promise { diff --git a/packages/@css-blocks/webpack/test/fixtures/blocks/has-reference.css b/packages/@css-blocks/webpack/test/fixtures/blocks/has-reference.css index cce6380af..4e52e6c23 100644 --- a/packages/@css-blocks/webpack/test/fixtures/blocks/has-reference.css +++ b/packages/@css-blocks/webpack/test/fixtures/blocks/has-reference.css @@ -1,3 +1,3 @@ /* Source: FIXTURES_DIRECTORY/is-referenced.block.css :scope => .is-referenced - [state|active] => .is-referenced--active */ \ No newline at end of file + :scope[state|active] => .is-referenced--active */ \ No newline at end of file From e080512953b4893be282dccd5787e954fa00f97c Mon Sep 17 00:00:00 2001 From: Adam Miller Date: Tue, 17 Apr 2018 15:42:08 -0700 Subject: [PATCH 5/6] fix: Update global states to use simplified parser utils. --- .../property-conflict-validator.ts | 1 - .../src/BlockCompiler/ConflictResolver.ts | 2 +- .../src/BlockParser/block-intermediates.ts | 18 +++- .../assert-foreign-global-attribute.ts | 71 ++++++++-------- .../BlockParser/features/construct-block.ts | 82 +++++++++++++------ .../@css-blocks/core/src/BlockParser/index.ts | 3 - .../core/src/BlockSyntax/BlockPath.ts | 16 ++-- .../core/src/BlockTree/Attribute.ts | 2 +- .../core/src/BlockTree/BlockClass.ts | 2 +- .../core/test/global-states-test.ts | 43 +++++++++- .../property-conflict-validator-test.ts | 25 +++++- .../ui/components/page-layout/stylesheet.css | 2 +- .../src/ui/components/my-app/stylesheet.css | 6 +- .../glimmer/test/stylesheet-analysis-test.ts | 2 +- .../test/analyzer/root-states-objstr-test.ts | 10 +-- 15 files changed, 198 insertions(+), 87 deletions(-) diff --git a/packages/@css-blocks/core/src/Analyzer/validations/property-conflict-validator.ts b/packages/@css-blocks/core/src/Analyzer/validations/property-conflict-validator.ts index ef8593046..2eec665eb 100644 --- a/packages/@css-blocks/core/src/Analyzer/validations/property-conflict-validator.ts +++ b/packages/@css-blocks/core/src/Analyzer/validations/property-conflict-validator.ts @@ -55,7 +55,6 @@ function evaluate(obj: Style, propToRules: PropMap, conflicts: ConflictMap) { // If these styles are from the same block, abort! if (other.style.block === self.style.block) { continue; } - // Get the declarations for this specific property. let selfDecl = self.declarations.get(prop); let otherDecl = other.declarations.get(prop); diff --git a/packages/@css-blocks/core/src/BlockCompiler/ConflictResolver.ts b/packages/@css-blocks/core/src/BlockCompiler/ConflictResolver.ts index 479b04fe1..cbefe2a6b 100644 --- a/packages/@css-blocks/core/src/BlockCompiler/ConflictResolver.ts +++ b/packages/@css-blocks/core/src/BlockCompiler/ConflictResolver.ts @@ -1,7 +1,7 @@ import { assertNever } from "@opticss/util"; import { CompoundSelector, ParsedSelector, parseSelector, postcss, postcssSelectorParser as selectorParser } from "opticss"; -import { isRootNode, isClassNode, isAttributeNode, toAttrToken } from "../BlockParser"; +import { isAttributeNode, isClassNode, isRootNode, toAttrToken } from "../BlockParser"; import { RESOLVE_RE } from "../BlockSyntax"; import { Block, BlockClass, Style } from "../BlockTree"; import { ResolvedConfiguration } from "../configuration"; diff --git a/packages/@css-blocks/core/src/BlockParser/block-intermediates.ts b/packages/@css-blocks/core/src/BlockParser/block-intermediates.ts index 1e3caa483..96c01386f 100644 --- a/packages/@css-blocks/core/src/BlockParser/block-intermediates.ts +++ b/packages/@css-blocks/core/src/BlockParser/block-intermediates.ts @@ -4,7 +4,8 @@ import { CompoundSelector, postcssSelectorParser as selectorParser } from "optic import { ATTR_PRESENT, AttrToken, ROOT_CLASS, STATE_NAMESPACE } from "../BlockSyntax"; export enum BlockType { - root = 1, + block = 1, + root, attribute, class, classAttribute, @@ -16,6 +17,9 @@ export type NodeAndType = { } | { blockType: BlockType.root | BlockType.class; node: selectorParser.ClassName | selectorParser.Pseudo; +} | { + blockType: BlockType.block; + node: selectorParser.Tag; }; export type BlockNodeAndType = NodeAndType & { @@ -34,7 +38,6 @@ function attrValue(attr: selectorParser.Attribute): string { /** Extract an Attribute's name from an attribute selector */ export function toAttrToken(attr: selectorParser.Attribute): AttrToken { return { - type: "attribute", namespace: attr.namespaceString, name: attr.attribute, value: attrValue(attr), @@ -51,6 +54,7 @@ export function toAttrToken(attr: selectorParser.Attribute): AttrToken { export function blockTypeName(t: BlockType, options?: { plural: boolean }): string { let isPlural = options && options.plural; switch (t) { + case BlockType.block: return isPlural ? "external blocks" : "external block"; case BlockType.root: return isPlural ? "block roots" : "block root"; case BlockType.attribute: return isPlural ? "root-level states" : "root-level state"; case BlockType.class: return isPlural ? "classes" : "class"; @@ -59,10 +63,18 @@ export function blockTypeName(t: BlockType, options?: { plural: boolean }): stri } } +/** + * Test if the provided node representation is an external block. + * @param object The NodeAndType's descriptor object. + */ +export function isExternalBlock(object: NodeAndType): boolean { + return object.blockType === BlockType.block; +} + /** * Test if the provided node representation is a root level object, aka: operating * on the root element. - * @param object The CompoundSelector's descriptor object. + * @param object The NodeAndType's descriptor object. */ export function isRootLevelObject(object: NodeAndType): boolean { return object.blockType === BlockType.root || object.blockType === BlockType.attribute; diff --git a/packages/@css-blocks/core/src/BlockParser/features/assert-foreign-global-attribute.ts b/packages/@css-blocks/core/src/BlockParser/features/assert-foreign-global-attribute.ts index 719a5777a..a78746670 100644 --- a/packages/@css-blocks/core/src/BlockParser/features/assert-foreign-global-attribute.ts +++ b/packages/@css-blocks/core/src/BlockParser/features/assert-foreign-global-attribute.ts @@ -1,13 +1,9 @@ -import { postcss } from "opticss"; +import { postcss, postcssSelectorParser as selectorParser } from "opticss"; import { Block } from "../../BlockTree"; import * as errors from "../../errors"; import { selectorSourceLocation as loc } from "../../SourceLocation"; -import { - BlockType, - getBlockNode, - toAttrToken, -} from "../block-intermediates"; +import { isAttributeNode, toAttrToken } from "../block-intermediates"; /** * Verify that the external block referenced by a `rule` selects an Attribute that @@ -24,42 +20,47 @@ export async function assertForeignGlobalAttribute(root: postcss.Root, block: Bl parsedSelectors.forEach((iSel) => { - iSel.eachCompoundSelector((compoundSel) => { - - let obj = getBlockNode(compoundSel); + iSel.eachCompoundSelector((sel) => { // Only test rules that are block references (this is validated in parse-styles and shouldn't happen). // If node isn't selecting a block, move on - if (!obj || !obj.blockName) { return; } + let blockName = sel.nodes.find(n => n.type === selectorParser.TAG); + if (!blockName || !blockName.value) { return; } - // If selecting something other than an attribute on external block, throw. - if (obj.blockType !== BlockType.attribute) { - throw new errors.InvalidBlockSyntax( - `Only global states from other blocks can be used in selectors: ${rule.selector}`, - loc(file, rule, obj.node)); - } + for (let node of sel.nodes) { - // If referenced block does not exist, throw. - let otherBlock = block.getReferencedBlock(obj.blockName!); - if (!otherBlock) { - throw new errors.InvalidBlockSyntax( - `No block named ${obj.blockName} found: ${rule.selector}`, - loc(file, rule, obj.node)); - } + if (node.type === selectorParser.TAG) { continue; } - // If state referenced does not exist on external block, throw - let otherAttr = otherBlock.rootClass.getAttributeValue(toAttrToken(obj.node)); - if (!otherAttr) { - throw new errors.InvalidBlockSyntax( - `No state ${obj.node.toString()} found in : ${rule.selector}`, - loc(file, rule, obj.node)); - } + // If selecting something other than an attribute on external block, throw. + if (!isAttributeNode(node)) { + throw new errors.InvalidBlockSyntax( + `Only global states from other blocks can be used in selectors: ${rule.selector}`, + loc(file, rule, node)); + } + + // If referenced block does not exist, throw. + let otherBlock = block.getReferencedBlock(blockName.value); + if (!otherBlock) { + throw new errors.InvalidBlockSyntax( + `No block named ${blockName.value} found: ${rule.selector}`, + loc(file, rule, node)); + } + + // If state referenced does not exist on external block, throw + let otherAttr = otherBlock.rootClass.getAttributeValue(toAttrToken(node)); + if (!otherAttr) { + throw new errors.InvalidBlockSyntax( + `No state ${node.toString()} found in : ${rule.selector}`, + loc(file, rule, node)); + } + + // If external state is not set as global, throw. + if (!otherAttr.isGlobal) { + throw new errors.InvalidBlockSyntax( + `${node.toString()} is not global: ${rule.selector}`, + loc(file, rule, node)); + } - // If external state is not set as global, throw. - if (!otherAttr.isGlobal) { - throw new errors.InvalidBlockSyntax( - `${obj.node.toString()} is not global: ${rule.selector}`, - loc(file, rule, obj.node)); } }); }); diff --git a/packages/@css-blocks/core/src/BlockParser/features/construct-block.ts b/packages/@css-blocks/core/src/BlockParser/features/construct-block.ts index a5fabe093..5c51f8b1f 100644 --- a/packages/@css-blocks/core/src/BlockParser/features/construct-block.ts +++ b/packages/@css-blocks/core/src/BlockParser/features/construct-block.ts @@ -11,6 +11,7 @@ import { isAttributeNode, isClassLevelObject, isClassNode, + isExternalBlock, isRootLevelObject, isRootNode, toAttrToken, @@ -61,41 +62,50 @@ export async function constructBlock(root: postcss.Root, block: Block, file: str parsedSelectors.forEach((iSel) => { let keySel = iSel.key; - let currentCompoundSel: CompoundSelector | undefined = iSel.selector; + let sel: CompoundSelector | undefined = iSel.selector; // Assert this selector is well formed according to CSS Blocks' selector rules. assertValidSelector(block, rule, iSel, file); // For each `CompoundSelector` in this rule, configure the `Block` object // depending on the BlockType. - while (currentCompoundSel) { - - let isKey = (keySel === currentCompoundSel); + while (sel) { + + let isKey = (keySel === sel); let blockClass: BlockClass | undefined = undefined; let foundStyles: Style[] = []; - for (let node of currentCompoundSel.nodes) { - if (isRootNode(node)){ + // If this is an external Style, move on. These are validated + // in `assert-foreign-global-attribute`. + let blockName = sel.nodes.find(n => n.type === selectorParser.TAG); + if (blockName) { + sel = sel.next && sel.next.selector; + continue; + } + + for (let node of sel.nodes) { + if (isRootNode(node)) { blockClass = block.rootClass; } - else if (isClassNode(node)){ + else if (isClassNode(node)) { blockClass = block.ensureClass(node.value); } - else if (isAttributeNode(node)){ - // The fact that a base class exists for all state selectors is validated elsewhere + else if (isAttributeNode(node)) { + // The fact that a base class exists for all state selectors is + // validated in `assertBlockObject`. foundStyles.push(blockClass!.ensureAttributeValue(toAttrToken(node))); } - } - // If we haven't found any terminating states, we're targeting the discovered Block class. - if (blockClass && !foundStyles.length) { foundStyles.push(blockClass); } - // If this is the key selector, save this ruleset on the created style. - if (isKey) { - foundStyles.map(s => styleRuleTuples.add([s, rule])); - } + // If we haven't found any terminating states, we're targeting the discovered Block class. + if (blockClass && !foundStyles.length) { foundStyles.push(blockClass); } + + // If this is the key selector, save this ruleset on the created style. + if (isKey) { + foundStyles.map(s => styleRuleTuples.add([s, rule])); + } - currentCompoundSel = currentCompoundSel.next && currentCompoundSel.next.selector; + sel = sel.next && sel.next.selector; } }); }); @@ -268,6 +278,23 @@ function assertBlockObject(block: Block, sel: CompoundSelector, rule: postcss.Ru // Test each node in selector let result = sel.nodes.reduce( (found, n) => { + + // If this is an external Block reference, indicate we have encountered it. + // If this is not the first BlockType encountered, throw the appropriate error. + if (n.type === selectorParser.TAG) { + if (found === null) { + found = { + blockType: BlockType.block, + node: n, + }; + } else { + throw new errors.InvalidBlockSyntax( + `External Block ${n} must be the first selector in "${rule.selector}"`, + loc(file, rule, sel.nodes[0]), + ); + } + } + // If selecting the root element, indicate we have encountered it. If this // is not the first BlockType encountered, throw the appropriate error if (isRootNode(n)) { @@ -282,11 +309,6 @@ function assertBlockObject(block: Block, sel: CompoundSelector, rule: postcss.Ru `${n} cannot be on the same element as ${found.node}: ${rule.selector}`, loc(file, rule, sel.nodes[0]), ); - } else if (found.blockType === BlockType.attribute) { - throw new errors.InvalidBlockSyntax( - `It's redundant to specify a state with the an explicit .root: ${rule.selector}`, - loc(file, rule, n), - ); } } } @@ -308,7 +330,7 @@ function assertBlockObject(block: Block, sel: CompoundSelector, rule: postcss.Ru ); } else if (found.blockType === BlockType.class || found.blockType === BlockType.classAttribute) { found = { node: n, blockType: BlockType.classAttribute }; - } else if (found.blockType === BlockType.root || found.blockType === BlockType.attribute) { + } else if (found.blockType === BlockType.block || found.blockType === BlockType.root || found.blockType === BlockType.attribute) { found = { node: n, blockType: BlockType.attribute }; } } @@ -351,6 +373,20 @@ function assertBlockObject(block: Block, sel: CompoundSelector, rule: postcss.Ru loc(file, rule, sel.nodes[0])); } + if (isExternalBlock(result)) { + let external = block.getReferencedBlock(result.node.value!); + if (!external) { throw new errors.InvalidBlockSyntax(``, loc(file, rule, sel.nodes[0])); } + let globalStates = external.rootClass.allAttributeValues().filter((a) => a.isGlobal); + if (!globalStates.length) { + throw new errors.InvalidBlockSyntax( + `External Block '${result.node.value}' has no global states.`, + loc(file, rule, sel.nodes[0])); + } + throw new errors.InvalidBlockSyntax( + `Missing global state selector on external Block '${result.node.value}'. Did you mean one of: ${globalStates.map((s) => s.asSource()).join(" ")}`, + loc(file, rule, sel.nodes[0])); + } + // Otherwise, return the block, type and associated node. else { return { diff --git a/packages/@css-blocks/core/src/BlockParser/index.ts b/packages/@css-blocks/core/src/BlockParser/index.ts index 5a18c892c..325095c42 100644 --- a/packages/@css-blocks/core/src/BlockParser/index.ts +++ b/packages/@css-blocks/core/src/BlockParser/index.ts @@ -1,12 +1,9 @@ // These constructs are **only** used in "../Block/Block.ts"! // Can we make these internal to the package? export { - BlockType, - NodeAndType, isAttributeNode, isClassNode, isRootNode, - getBlockNode, toAttrToken, } from "./block-intermediates"; diff --git a/packages/@css-blocks/core/src/BlockSyntax/BlockPath.ts b/packages/@css-blocks/core/src/BlockSyntax/BlockPath.ts index be81af6ac..1a46716ac 100644 --- a/packages/@css-blocks/core/src/BlockSyntax/BlockPath.ts +++ b/packages/@css-blocks/core/src/BlockSyntax/BlockPath.ts @@ -2,7 +2,7 @@ import { BlockPathError, ErrorLocation } from "../errors"; import { ATTR_PRESENT, - CLASS_NAME_IDENT as CSS_IDENT, + CLASS_NAME_IDENT, ROOT_CLASS, STATE_NAMESPACE, } from "./BlockSyntax"; @@ -17,24 +17,26 @@ interface ClassToken { name: string; } -export interface IAttrToken { +interface IAttrToken { namespace?: string; + value?: string; name: string; - value: string; + quoted?: boolean; } -export interface AttrToken extends IAttrToken { +interface AttrToken extends IAttrToken { type: "attribute"; - quoted: boolean; } type Token = BlockToken | ClassToken | AttrToken; +export { IAttrToken as AttrToken }; + const isBlock = (token?: Partial): token is BlockToken => !!token && token.type === "block"; const isClass = (token?: Partial): token is ClassToken => !!token && token.type === "class"; const isAttribute = (token?: Partial): token is AttrToken => !!token && token.type === "attribute"; const isQuoted = (token?: Partial): boolean => !!token && !!token.quoted; -const isIdent = (ident?: string): boolean => !ident || CSS_IDENT.test(ident); +const isIdent = (ident?: string): boolean => !ident || CLASS_NAME_IDENT.test(ident); const hasName = (token?: Partial): boolean => !!token && !!token.name; const isValidNamespace = (token?: Partial): boolean => !!token && (token.namespace === undefined || token.namespace === STATE_NAMESPACE); @@ -343,7 +345,7 @@ export class BlockPath { /** * Get the parsed attribute name of this Block Path and return the `AttrInfo` */ - get attribute(): AttrToken | undefined { + get attribute(): IAttrToken | undefined { if (!this._attribute) return; return this._attribute; } diff --git a/packages/@css-blocks/core/src/BlockTree/Attribute.ts b/packages/@css-blocks/core/src/BlockTree/Attribute.ts index 29a6ecb98..76ac03af6 100644 --- a/packages/@css-blocks/core/src/BlockTree/Attribute.ts +++ b/packages/@css-blocks/core/src/BlockTree/Attribute.ts @@ -8,7 +8,7 @@ import { } from "@opticss/element-analysis"; import { ObjectDictionary, assertNever } from "@opticss/util"; -import { ATTR_PRESENT, IAttrToken as AttrToken } from "../BlockSyntax"; +import { ATTR_PRESENT, AttrToken } from "../BlockSyntax"; import { OutputMode, ResolvedConfiguration } from "../configuration"; import { AttrValue } from "./AttrValue"; diff --git a/packages/@css-blocks/core/src/BlockTree/BlockClass.ts b/packages/@css-blocks/core/src/BlockTree/BlockClass.ts index 460ff2fde..8c8a81d7e 100644 --- a/packages/@css-blocks/core/src/BlockTree/BlockClass.ts +++ b/packages/@css-blocks/core/src/BlockTree/BlockClass.ts @@ -2,7 +2,7 @@ import { Attribute as Attr, AttributeValue, attrValues } from "@opticss/element- import { assertNever } from "@opticss/util"; import { isString } from "util"; -import { ATTR_PRESENT, IAttrToken as AttrToken, ROOT_CLASS } from "../BlockSyntax"; +import { ATTR_PRESENT, AttrToken, ROOT_CLASS } from "../BlockSyntax"; import { BlockPath } from "../BlockSyntax"; import { OutputMode, ResolvedConfiguration } from "../configuration"; diff --git a/packages/@css-blocks/core/test/global-states-test.ts b/packages/@css-blocks/core/test/global-states-test.ts index eac43955d..84b48b8d4 100644 --- a/packages/@css-blocks/core/test/global-states-test.ts +++ b/packages/@css-blocks/core/test/global-states-test.ts @@ -33,6 +33,47 @@ export class BlockInheritance extends BEMProcessor { ); }); } + @test "Global state usage must be specify a global state if present"() { + let { imports, config } = setupImporting(); + imports.registerSource( + "app.block.css", + `@block-global [state|is-loading]; + :scope[state|is-loading] .profile { + pointer-events: none; + }`, + ); + + let filename = "widget.block.css"; + let inputCSS = `@block-reference app from "./app.block.css"; + app .b { + border: none; + }`; + + return assertError( + cssBlocks.InvalidBlockSyntax, + "Missing global state selector on external Block 'app'. Did you mean one of: :scope[state|is-loading] (widget.block.css:2:21)", + this.process(filename, inputCSS, config)); + } + @test "External block error has better error if mis-used but has no global states."() { + let { imports, config } = setupImporting(); + imports.registerSource( + "app.block.css", + `:scope[state|is-loading] .profile { + pointer-events: none; + }`, + ); + + let filename = "widget.block.css"; + let inputCSS = `@block-reference app from "./app.block.css"; + app .b { + border: none; + }`; + + return assertError( + cssBlocks.InvalidBlockSyntax, + "External Block 'app' has no global states. (widget.block.css:2:21)", + this.process(filename, inputCSS, config)); + } @test "Can't use non-global states"() { let { imports, config } = setupImporting(); imports.registerSource( @@ -50,7 +91,7 @@ export class BlockInheritance extends BEMProcessor { return assertError( cssBlocks.InvalidBlockSyntax, - "Can use global state[state|is-loading] is not global: app[state|is-loading] .b (widget.block.css:2:24)", + "[state|is-loading] is not global: app[state|is-loading] .b (widget.block.css:2:24)", this.process(filename, inputCSS, config)); } } diff --git a/packages/@css-blocks/core/test/validations/property-conflict-validator-test.ts b/packages/@css-blocks/core/test/validations/property-conflict-validator-test.ts index de45849df..2e76befbc 100644 --- a/packages/@css-blocks/core/test/validations/property-conflict-validator-test.ts +++ b/packages/@css-blocks/core/test/validations/property-conflict-validator-test.ts @@ -1,6 +1,6 @@ import { Template } from "@opticss/template-api"; import { assert } from "chai"; -import { suite, test } from "mocha-typescript"; +import { skip, suite, test } from "mocha-typescript"; import { postcss } from "opticss"; import { BlockFactory } from "../../src/BlockParser"; @@ -882,6 +882,29 @@ export class TemplateAnalysisTests { }); } + @test @skip "multiple states on a compound selector do not throw if only one state is used"() { + let imports = new MockImportRegistry(); + let options: Options = { importer: imports.importer() }; + + imports.registerSource( + "blocks/b.block.css", + ` + :scope { block-name: block-a; } + .klass-1 { color: blue; } + `, + ); + + let css = ` + @block-reference b from "./b.block.css"; + :scope { block-name: block-a; } + .klass-2[state|one][state|two] { color: red; color: } + `; + + return this.parseBlock(css, "blocks/foo.block.css", options).then(([block, _]) => { + constructElement(block, ".klass-2", "b.klass-1").addStateGroup(".klass-2", "[state|one]").end(); + }); + } + @test "conflicting classes pass when a property is explicitly resolved"() { let imports = new MockImportRegistry(); let options: Options = { importer: imports.importer() }; diff --git a/packages/@css-blocks/glimmer/test/fixtures/readme-app/src/ui/components/page-layout/stylesheet.css b/packages/@css-blocks/glimmer/test/fixtures/readme-app/src/ui/components/page-layout/stylesheet.css index eff74e272..16058c656 100644 --- a/packages/@css-blocks/glimmer/test/fixtures/readme-app/src/ui/components/page-layout/stylesheet.css +++ b/packages/@css-blocks/glimmer/test/fixtures/readme-app/src/ui/components/page-layout/stylesheet.css @@ -1,6 +1,6 @@ @block-reference grid from "./grid.css"; :scope { color: red; width: 100vw; } -[state|loading] { color: blue } +:scope[state|loading] { color: blue } .sidebar { float: left; } .sidebar[state|collapsed] { display: none; } .main { border-right: 2px groove gray; } diff --git a/packages/@css-blocks/glimmer/test/fixtures/styled-app/src/ui/components/my-app/stylesheet.css b/packages/@css-blocks/glimmer/test/fixtures/styled-app/src/ui/components/my-app/stylesheet.css index 8b0a6e825..a818d5e69 100644 --- a/packages/@css-blocks/glimmer/test/fixtures/styled-app/src/ui/components/my-app/stylesheet.css +++ b/packages/@css-blocks/glimmer/test/fixtures/styled-app/src/ui/components/my-app/stylesheet.css @@ -1,9 +1,9 @@ :scope { - color: red; + color: red; } -[state|is-loading] { - color: blue; +:scope[state|is-loading] { + color: blue; } .editor { diff --git a/packages/@css-blocks/glimmer/test/stylesheet-analysis-test.ts b/packages/@css-blocks/glimmer/test/stylesheet-analysis-test.ts index f1021ac1a..43eb2ce37 100644 --- a/packages/@css-blocks/glimmer/test/stylesheet-analysis-test.ts +++ b/packages/@css-blocks/glimmer/test/stylesheet-analysis-test.ts @@ -20,7 +20,7 @@ describe("Stylesheet analysis", function() { assert.deepEqual(serializedAnalysis.blocks, { "": "glimmer:stylesheet:/styled-app/components/my-app", // I think the identifier shouldn't be the resolved value from glimmer. }); - assert.deepEqual(serializedAnalysis.stylesFound, [".editor", ".editor[state|disabled]" , ":scope", "[state|is-loading]"]); + assert.deepEqual(serializedAnalysis.stylesFound, [".editor", ".editor[state|disabled]" , ":scope", ":scope[state|is-loading]"]); let expected: ElementsAnalysis = { a: { tagName: "div", staticStyles: [ 2, 3 ], dynamicClasses: [], dynamicAttributes: [], sourceLocation: { start: { line: 1, "filename": "template:/styled-app/components/my-app" }, end: { line: 1, "filename": "template:/styled-app/components/my-app" } } }, b: { tagName: "page-banner", staticStyles: [], dynamicClasses: [], dynamicAttributes: [], sourceLocation: { start: { line: 2, column: 2, "filename": "template:/styled-app/components/my-app" }, end: { line: 2, column: 2, "filename": "template:/styled-app/components/my-app" } } }, diff --git a/packages/@css-blocks/jsx/test/analyzer/root-states-objstr-test.ts b/packages/@css-blocks/jsx/test/analyzer/root-states-objstr-test.ts index a251a8654..d2a3d7596 100644 --- a/packages/@css-blocks/jsx/test/analyzer/root-states-objstr-test.ts +++ b/packages/@css-blocks/jsx/test/analyzer/root-states-objstr-test.ts @@ -39,7 +39,7 @@ export class Test { assert.deepEqual(elementAnalysis.dynamicClasses, []); assert.deepEqual(elementAnalysis.dynamicAttributes, []); assert.deepEqual(elementAnalysis.staticStyles, [0, 1]); - assert.deepEqual(analysis.stylesFound, ["bar:scope", "bar[state|color=yellow]"]); + assert.deepEqual(analysis.stylesFound, ["bar:scope", "bar:scope[state|color=yellow]"]); }); } @@ -73,7 +73,7 @@ export class Test { assert.deepEqual(elementAnalysis.dynamicClasses, []); assert.deepEqual(elementAnalysis.dynamicAttributes, [{condition: true, value: 1}]); assert.deepEqual(elementAnalysis.staticStyles, [0]); - assert.deepEqual(analysis.stylesFound, ["bar:scope", "bar[state|color=yellow]"]); + assert.deepEqual(analysis.stylesFound, ["bar:scope", "bar:scope[state|color=yellow]"]); }); } @@ -100,7 +100,7 @@ export class Test { let result = analyzer.serialize(); let analysis = result.analyses[0]; let elementAnalysis = analysis.elements.a; - assert.deepEqual(analysis.stylesFound, ["bar:scope", "bar[state|awesome]"]); + assert.deepEqual(analysis.stylesFound, ["bar:scope", "bar:scope[state|awesome]"]); assert.deepEqual(elementAnalysis.dynamicClasses, [{condition: true, whenTrue: [0]}]); assert.deepEqual(elementAnalysis.dynamicAttributes, [{container: 0, value: 1}]); assert.deepEqual(elementAnalysis.staticStyles, []); @@ -130,7 +130,7 @@ export class Test { let result = analyzer.serialize(); let analysis = result.analyses[0]; let elementAnalysis = analysis.elements.a; - assert.deepEqual(analysis.stylesFound, ["bar:scope", "bar[state|awesome]"]); + assert.deepEqual(analysis.stylesFound, ["bar:scope", "bar:scope[state|awesome]"]); assert.deepEqual(elementAnalysis.dynamicClasses, []); assert.deepEqual(elementAnalysis.dynamicAttributes, [{condition: true, value: 1}]); assert.deepEqual(elementAnalysis.staticStyles, [0]); @@ -198,7 +198,7 @@ export class Test { ).then((analyzer: Analyzer) => { let result = analyzer.serialize(); let analysis = result.analyses[0]; - assert.deepEqual(analysis.stylesFound, ["bar.pretty", "bar.pretty[state|awesome]", "bar:scope", "bar[state|awesome]"]); + assert.deepEqual(analysis.stylesFound, ["bar.pretty", "bar.pretty[state|awesome]", "bar:scope", "bar:scope[state|awesome]"]); let elementAnalysis = analysis.elements.a; assert.deepEqual(elementAnalysis.dynamicClasses, []); assert.deepEqual(elementAnalysis.dynamicAttributes, []); From aa523f8b4937cc94e0eb30ae393c166120bca2f3 Mon Sep 17 00:00:00 2001 From: Adam Miller Date: Thu, 19 Apr 2018 14:18:39 -0700 Subject: [PATCH 6/6] feat: Block Object asSource methods take optional Block scope. --- ARCHITECTURE.md | 2 +- .../property-conflict-validator.ts | 2 +- .../src/BlockParser/block-intermediates.ts | 92 +++++++------------ .../BlockParser/features/construct-block.ts | 5 +- .../core/src/BlockTree/AttrValue.ts | 11 ++- .../core/src/BlockTree/Attribute.ts | 18 +--- .../core/src/BlockTree/BlockClass.ts | 15 ++- .../@css-blocks/core/src/BlockTree/Style.ts | 3 +- .../core/test/global-states-test.ts | 2 +- packages/@css-blocks/core/test/syntax-test.ts | 2 +- .../property-conflict-validator-test.ts | 78 ++++++++-------- .../jsx/src/utils/ExpressionReader.ts | 2 +- .../test/analyzer/class-states-objstr-test.ts | 2 +- .../test/analyzer/inline-class-styles-test.ts | 2 +- .../test/analyzer/root-states-objstr-test.ts | 2 +- 15 files changed, 112 insertions(+), 126 deletions(-) diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 4fede323b..57ffe3af7 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -175,7 +175,7 @@ We can easily conceptualize the `RewriteMapping` data for each element in develo ```javascript // For Element 1: // - `.class-0` is always applied -// - `:scope[state|active]` is *only* applied when `isActive` is true +// - `.class-0[state|active]` is *only* applied when `isActive` is true const el1Classes = [ "block__class-0", isActive && "block__class-0--active" diff --git a/packages/@css-blocks/core/src/Analyzer/validations/property-conflict-validator.ts b/packages/@css-blocks/core/src/Analyzer/validations/property-conflict-validator.ts index 2eec665eb..9d58ffcd8 100644 --- a/packages/@css-blocks/core/src/Analyzer/validations/property-conflict-validator.ts +++ b/packages/@css-blocks/core/src/Analyzer/validations/property-conflict-validator.ts @@ -117,7 +117,7 @@ function printRulesetConflict(prop: string, rule: Ruleset) { for (let node of nodes) { let line = node.source.start && `:${node.source.start.line}`; let column = node.source.start && `:${node.source.start.column}`; - out.push(` ${rule.style.block.name}${rule.style.asSource()} (${rule.file}${line}${column})`); + out.push(` ${rule.style.asSource(true)} (${rule.file}${line}${column})`); } return out.join("\n"); } diff --git a/packages/@css-blocks/core/src/BlockParser/block-intermediates.ts b/packages/@css-blocks/core/src/BlockParser/block-intermediates.ts index 96c01386f..cb9a7bd6a 100644 --- a/packages/@css-blocks/core/src/BlockParser/block-intermediates.ts +++ b/packages/@css-blocks/core/src/BlockParser/block-intermediates.ts @@ -1,5 +1,5 @@ -import { assertNever, firstOfType, whatever } from "@opticss/util"; -import { CompoundSelector, postcssSelectorParser as selectorParser } from "opticss"; +import { assertNever, whatever } from "@opticss/util"; +import { postcssSelectorParser as selectorParser } from "opticss"; import { ATTR_PRESENT, AttrToken, ROOT_CLASS, STATE_NAMESPACE } from "../BlockSyntax"; @@ -11,21 +11,42 @@ export enum BlockType { classAttribute, } -export type NodeAndType = { - blockType: BlockType.attribute | BlockType.classAttribute; +export type RootAttributeNode = { + blockName?: string; + blockType: BlockType.attribute; node: selectorParser.Attribute; -} | { - blockType: BlockType.root | BlockType.class; - node: selectorParser.ClassName | selectorParser.Pseudo; -} | { - blockType: BlockType.block; - node: selectorParser.Tag; }; -export type BlockNodeAndType = NodeAndType & { +export type ClassAttributeNode = { + blockName?: string; + blockType: BlockType.classAttribute; + node: selectorParser.Attribute; +}; + +export type AttributeNode = RootAttributeNode | ClassAttributeNode; + +export type RootClassNode = { + blockName?: string; + blockType: BlockType.root; + node: selectorParser.Pseudo; +}; + +export type BlockClassNode = { + blockName?: string; + blockType: BlockType.class; + node: selectorParser.ClassName; +}; + +export type ClassNode = RootClassNode | BlockClassNode; + +export type BlockNode = { blockName?: string; + blockType: BlockType.block; + node: selectorParser.Tag; }; +export type NodeAndType = AttributeNode | ClassNode | BlockNode; + /** Extract an Attribute's value from a `selectorParser` attribute selector */ function attrValue(attr: selectorParser.Attribute): string { if (attr.value) { @@ -76,7 +97,7 @@ export function isExternalBlock(object: NodeAndType): boolean { * on the root element. * @param object The NodeAndType's descriptor object. */ -export function isRootLevelObject(object: NodeAndType): boolean { +export function isRootLevelObject(object: NodeAndType): object is RootAttributeNode | RootClassNode { return object.blockType === BlockType.root || object.blockType === BlockType.attribute; } @@ -85,7 +106,7 @@ export function isRootLevelObject(object: NodeAndType): boolean { * on an element contained by the root, not the root itself. * @param object The CompoundSelector's descriptor object. */ -export function isClassLevelObject(object: NodeAndType): boolean { +export function isClassLevelObject(object: NodeAndType): object is ClassAttributeNode | BlockClassNode { return object.blockType === BlockType.class || object.blockType === BlockType.classAttribute; } @@ -106,48 +127,3 @@ export const isClassNode = selectorParser.isClassName; export function isAttributeNode(node: selectorParser.Node): node is selectorParser.Attribute { return selectorParser.isAttribute(node) && node.namespace === STATE_NAMESPACE; } - -/** - * Similar to assertBlockObject except it doesn't check for well-formedness - * and doesn't ensure that you get a block object when not a legal selector. - * @param sel The `CompoundSelector` to search. - * @return Returns the block's name, type and node. - */ -export function getBlockNode(sel: CompoundSelector): BlockNodeAndType | null { - let blockName = sel.nodes.find(n => n.type === selectorParser.TAG); - let r = firstOfType(sel.nodes, isRootNode); - if (r) { - return { - blockName: blockName && blockName.value, - blockType: BlockType.root, - node: r, - }; - } - let s = firstOfType(sel.nodes, isAttributeNode); - if (s) { - let prev = s.prev(); - if (prev && isClassNode(prev)) { - return { - blockName: blockName && blockName.value, - blockType: BlockType.classAttribute, - node: s, - }; - } else { - return { - blockName: blockName && blockName.value, - blockType: BlockType.attribute, - node: s, - }; - } - } - let c = firstOfType(sel.nodes, isClassNode); - if (c) { - return { - blockName: blockName && blockName.value, - blockType: BlockType.class, - node: c, - }; - } else { - return null; - } -} diff --git a/packages/@css-blocks/core/src/BlockParser/features/construct-block.ts b/packages/@css-blocks/core/src/BlockParser/features/construct-block.ts index 5c51f8b1f..74069e91b 100644 --- a/packages/@css-blocks/core/src/BlockParser/features/construct-block.ts +++ b/packages/@css-blocks/core/src/BlockParser/features/construct-block.ts @@ -4,7 +4,6 @@ import { Block, BlockClass, Style } from "../../BlockTree"; import * as errors from "../../errors"; import { selectorSourceLocation as loc, sourceLocation } from "../../SourceLocation"; import { - BlockNodeAndType, BlockType, NodeAndType, blockTypeName, @@ -238,7 +237,7 @@ function assertValidSelector(block: Block, rule: postcss.Rule, selector: ParsedS * @param rule The full `postcss.Rule` for nice error reporting. * @return Returns the block's name, type and node. */ -function assertBlockObject(block: Block, sel: CompoundSelector, rule: postcss.Rule, file: string): BlockNodeAndType { +function assertBlockObject(block: Block, sel: CompoundSelector, rule: postcss.Rule, file: string): NodeAndType { // If selecting a block or tag, check that the referenced block has been imported. // Otherwise, referencing a tag name is not allowed in blocks, throw an error. @@ -325,7 +324,7 @@ function assertBlockObject(block: Block, sel: CompoundSelector, rule: postcss.Ru } if (!found) { throw new errors.InvalidBlockSyntax( - `States without an explicit :scope or class selector are not yet supported: ${rule.selector}`, + `States without an explicit :scope or class selector are not supported: ${rule.selector}`, loc(file, rule, n), ); } else if (found.blockType === BlockType.class || found.blockType === BlockType.classAttribute) { diff --git a/packages/@css-blocks/core/src/BlockTree/AttrValue.ts b/packages/@css-blocks/core/src/BlockTree/AttrValue.ts index 8b1595f14..0533fcb9f 100644 --- a/packages/@css-blocks/core/src/BlockTree/AttrValue.ts +++ b/packages/@css-blocks/core/src/BlockTree/AttrValue.ts @@ -74,8 +74,15 @@ export class AttrValue extends Style { return this._sourceAttributes.slice(); } - asSource(): string { - return this.parent.asSource(this.value); + /** + * Export as original AttrValue name. + * @param scope Optional scope to resolve this name relative to. If `true`, return the Block name instead of `:scope`. If a Block object, return with the local name instead of `:scope`. + * @returns String representing original AttrValue path. + */ + asSource(scope?: Block | boolean): string { + let namespace = this.attribute.namespace ? `${this.attribute.namespace}|` : ""; + let value = (this.value && this.value !== ATTR_PRESENT) ? `=${this.value}` : ""; + return this.attribute.blockClass.asSource(scope) + `[${namespace}${this.parent.name}${value}]`; } public cssClass(config: ResolvedConfiguration): string { diff --git a/packages/@css-blocks/core/src/BlockTree/Attribute.ts b/packages/@css-blocks/core/src/BlockTree/Attribute.ts index 76ac03af6..9b19ebf77 100644 --- a/packages/@css-blocks/core/src/BlockTree/Attribute.ts +++ b/packages/@css-blocks/core/src/BlockTree/Attribute.ts @@ -121,25 +121,15 @@ export class Attribute extends Inheritable { /** * Export as original class name. + * @param scope Optional scope to resolve this name relative to. If `true`, return the Block name instead of `:scope`. If a Block object, return with the local name instead of `:scope`. * @returns String representing original class. */ - public asSource(): string { return this.isRoot ? ROOT_CLASS : `.${this.name}`; } + public asSource(scope?: Block | boolean): string { + let blockName = this.block.name; + + if (scope instanceof Block) { + blockName = scope.getReferencedBlockLocalName(this.block) || blockName; + } + + if (scope && scope !== this.block) { + return this.isRoot ? blockName : `${blockName}.${this.name}`; + } + + return this.isRoot ? ROOT_CLASS : `.${this.name}`; + } /** * Emit analysis attributes for the class value this diff --git a/packages/@css-blocks/core/src/BlockTree/Style.ts b/packages/@css-blocks/core/src/BlockTree/Style.ts index bcfdbf0c5..8fa096637 100644 --- a/packages/@css-blocks/core/src/BlockTree/Style.ts +++ b/packages/@css-blocks/core/src/BlockTree/Style.ts @@ -45,9 +45,10 @@ export abstract class Style< /** * Return the source selector this `Style` was read from. + * @param scope Optional scope to resolve this name relative to. If `true`, return the Block name instead of `:scope`. If a Block object, return with the local name instead of `:scope`. * @returns The source selector. */ - public abstract asSource(): string; + public abstract asSource(scope?: Root | boolean): string; /** * Return an attribute for analysis using the authored source syntax. diff --git a/packages/@css-blocks/core/test/global-states-test.ts b/packages/@css-blocks/core/test/global-states-test.ts index 84b48b8d4..0ed704577 100644 --- a/packages/@css-blocks/core/test/global-states-test.ts +++ b/packages/@css-blocks/core/test/global-states-test.ts @@ -33,7 +33,7 @@ export class BlockInheritance extends BEMProcessor { ); }); } - @test "Global state usage must be specify a global state if present"() { + @test "Global state usage must specify a global state, not just a block name."() { let { imports, config } = setupImporting(); imports.registerSource( "app.block.css", diff --git a/packages/@css-blocks/core/test/syntax-test.ts b/packages/@css-blocks/core/test/syntax-test.ts index e4f7016d3..559579b37 100644 --- a/packages/@css-blocks/core/test/syntax-test.ts +++ b/packages/@css-blocks/core/test/syntax-test.ts @@ -424,7 +424,7 @@ export class StraightJacket extends BEMProcessor { [state|foo] { display: block; }`; return assertError( cssBlocks.InvalidBlockSyntax, - "States without an explicit :scope or class selector are not yet supported: [state|foo]" + + "States without an explicit :scope or class selector are not supported: [state|foo]" + " (foo/bar/illegal-class-combinator.css:2:21)", this.process(filename, inputCSS)); } diff --git a/packages/@css-blocks/core/test/validations/property-conflict-validator-test.ts b/packages/@css-blocks/core/test/validations/property-conflict-validator-test.ts index 2e76befbc..165ee97b7 100644 --- a/packages/@css-blocks/core/test/validations/property-conflict-validator-test.ts +++ b/packages/@css-blocks/core/test/validations/property-conflict-validator-test.ts @@ -66,9 +66,9 @@ export class TemplateAnalysisTests { The following property conflicts must be resolved for these co-located Styles: (templates/my-template.hbs:10:32) color: - block-a:scope (blocks/foo.block.css:3:37) - block-b:scope (blocks/b.block.css:1:31) - block-b:scope (blocks/b.block.css:1:43)`, + block-a (blocks/foo.block.css:3:37) + block-b (blocks/b.block.css:1:31) + block-b (blocks/b.block.css:1:43)`, this.parseBlock(css, "blocks/foo.block.css", options).then(([block, _]) => { constructElement(block, ":scope", "b").end(); @@ -117,10 +117,10 @@ export class TemplateAnalysisTests { The following property conflicts must be resolved for these co-located Styles: (templates/my-template.hbs:10:32) color: - block-a:scope (blocks/foo.block.css:3:37) - block-a:scope (blocks/foo.block.css:3:50) - block-b:scope (blocks/b.block.css:1:31) - block-b:scope (blocks/b.block.css:1:43)`, + block-a (blocks/foo.block.css:3:37) + block-a (blocks/foo.block.css:3:50) + block-b (blocks/b.block.css:1:31) + block-b (blocks/b.block.css:1:43)`, this.parseBlock(css, "blocks/foo.block.css", options).then(([block, _]) => { constructElement(block, ":scope", "b").end(); @@ -202,12 +202,12 @@ export class TemplateAnalysisTests { `The following property conflicts must be resolved for these co-located Styles: (templates/my-template.hbs:10:32) color: - block-a:scope (blocks/foo.block.css:3:37) - block-b:scope (blocks/b.block.css:1:31) + block-a (blocks/foo.block.css:3:37) + block-b (blocks/b.block.css:1:31) background-color: - block-a:scope (blocks/foo.block.css:3:49) - block-b:scope (blocks/b.block.css:1:44)`, + block-a (blocks/foo.block.css:3:49) + block-b (blocks/b.block.css:1:44)`, this.parseBlock(css, "blocks/foo.block.css", options).then(([block, _]) => { constructElement(block, ":scope", "b").end(); @@ -327,11 +327,11 @@ export class TemplateAnalysisTests { color: block-a.foo (blocks/foo.block.css:4:15) - block-b:scope (blocks/b.block.css:1:31) + block-b (blocks/b.block.css:1:31) background-color: block-a.foo (blocks/foo.block.css:4:27) - block-b:scope (blocks/b.block.css:1:44)`, + block-b (blocks/b.block.css:1:44)`, this.parseBlock(css, "blocks/foo.block.css", options).then(([block, _]) => { constructElement(block, ".foo", "b").end(); @@ -420,11 +420,11 @@ export class TemplateAnalysisTests { color: block-a.foo (blocks/foo.block.css:4:15) - block-b:scope (blocks/b.block.css:1:31) + block-b (blocks/b.block.css:1:31) background-color: block-a.foo (blocks/foo.block.css:4:27) - block-b:scope (blocks/b.block.css:1:44)`, + block-b (blocks/b.block.css:1:44)`, this.parseBlock(css, "blocks/foo.block.css", options).then(([block, _]) => { constructElement(block).addDynamic([".foo"]).addDynamic(["b"]).end(); @@ -480,11 +480,11 @@ export class TemplateAnalysisTests { color: block-a.foo (blocks/foo.block.css:4:15) - block-b:scope (blocks/b.block.css:1:31) + block-b (blocks/b.block.css:1:31) background-color: block-a.foo (blocks/foo.block.css:4:27) - block-b:scope (blocks/b.block.css:1:44)`, + block-b (blocks/b.block.css:1:44)`, this.parseBlock(css, "blocks/foo.block.css", options).then(([block, _]) => { constructElement(block).addDynamic([".foo", "b"]).end(); @@ -561,12 +561,12 @@ export class TemplateAnalysisTests { The following property conflicts must be resolved for these co-located Styles: (templates/my-template.hbs:10:32) color: - block-b:scope (blocks/b.block.css:1:31) - block-a:scope[state|foo] (blocks/foo.block.css:4:27) + block-b (blocks/b.block.css:1:31) + block-a[state|foo] (blocks/foo.block.css:4:27) background-color: - block-b:scope (blocks/b.block.css:1:44) - block-a:scope[state|foo] (blocks/foo.block.css:4:39)`, + block-b (blocks/b.block.css:1:44) + block-a[state|foo] (blocks/foo.block.css:4:39)`, this.parseBlock(css, "blocks/foo.block.css", options).then(([block, _]) => { constructElement(block, ":scope", "b").addDynamic("[state|foo]").end(); @@ -678,12 +678,12 @@ export class TemplateAnalysisTests { The following property conflicts must be resolved for these co-located Styles: (templates/my-template.hbs:10:32) color: - block-a:scope[state|foo] (blocks/foo.block.css:4:27) - block-b:scope[state|bar] (blocks/b.block.css:3:27) + block-a[state|foo] (blocks/foo.block.css:4:27) + block-b[state|bar] (blocks/b.block.css:3:27) background-color: - block-a:scope[state|foo] (blocks/foo.block.css:4:39) - block-b:scope[state|bar] (blocks/b.block.css:3:40)`, + block-a[state|foo] (blocks/foo.block.css:4:39) + block-b[state|bar] (blocks/b.block.css:3:40)`, this.parseBlock(css, "blocks/foo.block.css", options).then(([block, _]) => { constructElement(block, ":scope", "b").addDynamic("[state|foo]").addDynamic("b:scope[state|bar]").end(); @@ -741,12 +741,12 @@ export class TemplateAnalysisTests { The following property conflicts must be resolved for these co-located Styles: (templates/my-template.hbs:10:32) color: - block-b:scope (blocks/b.block.css:2:37) - block-a:scope[state|foo=one] (blocks/foo.block.css:4:31) + block-b (blocks/b.block.css:2:37) + block-a[state|foo=one] (blocks/foo.block.css:4:31) background-color: - block-b:scope (blocks/b.block.css:2:50) - block-a:scope[state|foo=one] (blocks/foo.block.css:4:43)`, + block-b (blocks/b.block.css:2:50) + block-a[state|foo=one] (blocks/foo.block.css:4:43)`, this.parseBlock(css, "blocks/foo.block.css", options).then(([block, _]) => { constructElement(block, ":scope", "b").addStateGroup(":scope", "[state|foo]").end(); @@ -802,16 +802,16 @@ export class TemplateAnalysisTests { The following property conflicts must be resolved for these co-located Styles: (templates/my-template.hbs:10:32) color: - block-b:scope (blocks/b.block.css:2:37) - block-a:scope[state|foo=one] (blocks/foo.block.css:4:31) - block-b:scope[state|bar=one] (blocks/b.block.css:3:31) - block-b:scope[state|bar=two] (blocks/b.block.css:4:31) + block-b (blocks/b.block.css:2:37) + block-a[state|foo=one] (blocks/foo.block.css:4:31) + block-b[state|bar=one] (blocks/b.block.css:3:31) + block-b[state|bar=two] (blocks/b.block.css:4:31) background-color: - block-b:scope (blocks/b.block.css:2:50) - block-a:scope[state|foo=one] (blocks/foo.block.css:4:46) - block-b:scope[state|bar=one] (blocks/b.block.css:3:43) - block-b:scope[state|bar=two] (blocks/b.block.css:4:46)`, + block-b (blocks/b.block.css:2:50) + block-a[state|foo=one] (blocks/foo.block.css:4:46) + block-b[state|bar=one] (blocks/b.block.css:3:43) + block-b[state|bar=two] (blocks/b.block.css:4:46)`, this.parseBlock(css, "blocks/foo.block.css", options).then(([block, _]) => { constructElement(block, ":scope", "b").addStateGroup(":scope", "[state|foo]").addStateGroup("b", "[state|bar]").end(); @@ -847,12 +847,12 @@ export class TemplateAnalysisTests { The following property conflicts must be resolved for these co-located Styles: (templates/my-template.hbs:10:32) color: - block-b:scope (blocks/b.block.css:1:31) + block-b (blocks/b.block.css:1:31) block-c.bar (blocks/c.block.css:3:14) block-a.foo (blocks/foo.block.css:5:15) background-color: - block-b:scope (blocks/b.block.css:1:44) + block-b (blocks/b.block.css:1:44) block-a.foo (blocks/foo.block.css:5:27)`, this.parseBlock(css, "blocks/foo.block.css", options).then(([block, _]) => { diff --git a/packages/@css-blocks/jsx/src/utils/ExpressionReader.ts b/packages/@css-blocks/jsx/src/utils/ExpressionReader.ts index 78ec5497e..eb2e5b0da 100644 --- a/packages/@css-blocks/jsx/src/utils/ExpressionReader.ts +++ b/packages/@css-blocks/jsx/src/utils/ExpressionReader.ts @@ -210,7 +210,7 @@ export class ExpressionReader { } else if (this.stateValue) { let state = stateGroup.resolveValue(this.stateValue); if (!state) { - let message = `No state ${stateGroup.asSource(this.stateValue)} found on block "${this.block}".`; + let message = `State "${stateGroup.asSource()}" has no value "${this.stateValue}" on Block "${this.block}".`; let valueNames = [...stateGroup.valuesMap().values()].map(s => s.asSource()); if (valueNames.length === 1) { message += `\n Did you mean: ${valueNames[0]}?`; diff --git a/packages/@css-blocks/jsx/test/analyzer/class-states-objstr-test.ts b/packages/@css-blocks/jsx/test/analyzer/class-states-objstr-test.ts index c0b532647..2e2130f80 100644 --- a/packages/@css-blocks/jsx/test/analyzer/class-states-objstr-test.ts +++ b/packages/@css-blocks/jsx/test/analyzer/class-states-objstr-test.ts @@ -295,7 +295,7 @@ export class Test { `).then((_analysis: Analyzer) => { assert.ok(false, "Should never get here"); }).catch((err) => { - assert.equal(err.message, '[css-blocks] MalformedBlockPath: No state .pretty[state|awesome=wat] found on block "bar".\n Did you mean: .pretty[state|awesome]? (7:9)'); + assert.equal(err.message, '[css-blocks] MalformedBlockPath: State ".pretty[state|awesome]" has no value "wat" on Block "bar".\n Did you mean: .pretty[state|awesome]? (7:9)'); }); } diff --git a/packages/@css-blocks/jsx/test/analyzer/inline-class-styles-test.ts b/packages/@css-blocks/jsx/test/analyzer/inline-class-styles-test.ts index ee8c9a5f4..71051495b 100644 --- a/packages/@css-blocks/jsx/test/analyzer/inline-class-styles-test.ts +++ b/packages/@css-blocks/jsx/test/analyzer/inline-class-styles-test.ts @@ -84,7 +84,7 @@ export class Test { ).then(() => { assert.equal("Should never get here", ""); }).catch((err: Error) => { - assert.equal(err.message, '[css-blocks] MalformedBlockPath: No state .foo[state|baz=biz] found on block "bar".\n Did you mean: .foo[state|baz]? (4:47)'); + assert.equal(err.message, '[css-blocks] MalformedBlockPath: State ".foo[state|baz]" has no value "biz" on Block "bar".\n Did you mean: .foo[state|baz]? (4:47)'); }); } } diff --git a/packages/@css-blocks/jsx/test/analyzer/root-states-objstr-test.ts b/packages/@css-blocks/jsx/test/analyzer/root-states-objstr-test.ts index d2a3d7596..0adb49601 100644 --- a/packages/@css-blocks/jsx/test/analyzer/root-states-objstr-test.ts +++ b/packages/@css-blocks/jsx/test/analyzer/root-states-objstr-test.ts @@ -161,7 +161,7 @@ export class Test { assert.ok(false, "should not have succeeded."); }, (err) => { - assert.equal(err.message, '[css-blocks] MalformedBlockPath: No state :scope[state|awesome=wat] found on block "bar".\n Did you mean: :scope[state|awesome]? (7:9)'); + assert.equal(err.message, '[css-blocks] MalformedBlockPath: State ":scope[state|awesome]" has no value "wat" on Block "bar".\n Did you mean: :scope[state|awesome]? (7:9)'); }); }