How to use the @stylable/core.process function in @stylable/core

To help you get started, we’ve selected a few @stylable/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wix / stylable / packages / core-test-kit / src / generate-test-util.ts View on Github external
export function processSource(
    source: string,
    options: { from?: string } = {},
    resolveNamespace?: typeof processNamespace
) {
    return process(postcss.parse(source, options), undefined, resolveNamespace);
}
github wix / stylable / packages / core-test-kit / src / diagnostics.ts View on Github external
export function expectWarnings(css: string, warnings: Diagnostic[]) {
    const source = findTestLocations(css);
    const root = safeParse(source.css);
    const res = process(root);

    res.diagnostics.reports.forEach((report, i) => {
        const expectedWarning = warnings[i];
        if (expectedWarning.skip) {
            return;
        }

        expect(report.message).to.equal(expectedWarning.message);
        expect(report.node.source!.start, 'start').to.eql(source.start);
        if (source.word !== null) {
            expect(report.options.word).to.equal(source.word);
        }

        if (expectedWarning.severity) {
            expect(
                report.type,
github wix / stylable / packages / core-test-kit / src / generate-test-util.ts View on Github external
(from, content) => {
            const meta = process(postcss.parse(content, { from }), diagnostics);
            meta.namespace = config.files[from].namespace || meta.namespace;
            return meta;
        },
        fs,
github wix / stylable / packages / language-service / src / lib / provider.ts View on Github external
for (const node of ast.nodes) {
                if (node.type === 'decl') {
                    const r = postcss.rule({ selector: node.prop + ':' + node.value });
                    r.source = node.source;
                    node.replaceWith(r);
                    fakes.push(r);
                }
            }
        }
        if (ast.raws.after && ast.raws.after.trim()) {
            const r = postcss.rule({ selector: ast.raws.after.trim() });
            ast.append(r);
            fakes.push(r);
        }

        meta = stylableProcess(ast);
    } catch (error) {
        return { meta: null, fakes };
    }
    return {
        meta,
        fakes
    };
}