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

@vanilla-extract/babel-plugin-debug-ids

Package Overview
Dependencies
Maintainers
4
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vanilla-extract/babel-plugin-debug-ids - npm Package Compare versions

Comparing version 0.0.0-dts-bundle-20228303510 to 0.0.0-experimental-macros-20236175227

6

dist/vanilla-extract-babel-plugin-debug-ids.cjs.d.ts
import { PluginObj, PluginPass } from '@babel/core';
declare const styleFunctions: string[];
declare type StyleFunction = typeof styleFunctions[number];
declare type Context = PluginPass & {
declare const styleFunctions: readonly [...("style" | "style$" | "createTheme" | "createTheme$" | "styleVariants" | "styleVariants$" | "fontFace" | "fontFace$" | "keyframes" | "keyframes$" | "createVar" | "createVar$" | "recipe" | "recipe$" | "createContainer" | "createContainer$" | "layer" | "layer$")[], "globalStyle", "createGlobalTheme", "createThemeContract", "globalFontFace", "globalKeyframes", "globalLayer", "recipe"];
type StyleFunction = typeof styleFunctions[number];
type Context = PluginPass & {
namespaceImport: string;

@@ -7,0 +7,0 @@ importIdentifiers: Map<string, StyleFunction>;

@@ -12,26 +12,79 @@ 'use strict';

},
style$: {
maxParams: 2
},
createTheme: {
maxParams: 3
},
styleVariants: {
createTheme$: {
maxParams: 3
},
styleVariants: {
maxParams: 3,
hasDebugId: ({
arguments: args
}) => {
const previousArg = args[args.length - 1];
return core.types.isStringLiteral(previousArg) || core.types.isTemplateLiteral(previousArg);
}
},
styleVariants$: {
maxParams: 3,
hasDebugId: ({
arguments: args
}) => {
const previousArg = args[args.length - 1];
return core.types.isStringLiteral(previousArg) || core.types.isTemplateLiteral(previousArg);
}
},
fontFace: {
maxParams: 2
},
fontFace$: {
maxParams: 2
},
keyframes: {
maxParams: 2
},
keyframes$: {
maxParams: 2
},
createVar: {
maxParams: 1
},
createVar$: {
maxParams: 1
},
recipe: {
maxParams: 2
},
recipe$: {
maxParams: 2
},
createContainer: {
maxParams: 1
},
createContainer$: {
maxParams: 1
},
layer: {
maxParams: 2,
hasDebugId: ({
arguments: args
}) => {
const previousArg = args[args.length - 1];
return core.types.isStringLiteral(previousArg) || core.types.isTemplateLiteral(previousArg);
}
},
layer$: {
maxParams: 2,
hasDebugId: ({
arguments: args
}) => {
const previousArg = args[args.length - 1];
return core.types.isStringLiteral(previousArg) || core.types.isTemplateLiteral(previousArg);
}
}
};
const styleFunctions = [...Object.keys(debuggableFunctionConfig), 'globalStyle', 'createGlobalTheme', 'createThemeContract', 'globalFontFace', 'globalKeyframes', 'recipe'];
const styleFunctions = [...Object.keys(debuggableFunctionConfig), 'globalStyle', 'createGlobalTheme', 'createThemeContract', 'globalFontFace', 'globalKeyframes', 'globalLayer', 'recipe'];
const extractName = node => {

@@ -42,2 +95,4 @@ if (core.types.isObjectProperty(node) && core.types.isIdentifier(node.key)) {

return node.id.name;
} else if (core.types.isAssignmentExpression(node) && core.types.isIdentifier(node.left)) {
return node.left.name;
} else if (core.types.isExportDefaultDeclaration(node)) {

@@ -49,3 +104,2 @@ return 'default';

};
const getDebugId = path => {

@@ -55,6 +109,7 @@ const firstRelevantParentPath = path.findParent(({

}) => !(core.types.isCallExpression(node) || core.types.isSequenceExpression(node)));
if (!firstRelevantParentPath) {
return;
} // Special case: Handle `export const [themeClass, vars] = createTheme({});`
}
// Special case: Handle `export const [themeClass, vars] = createTheme({});`
// when it's already been compiled into this:

@@ -66,7 +121,4 @@ //

// vars = _createTheme2[1];
if (core.types.isVariableDeclaration(firstRelevantParentPath.parent) && firstRelevantParentPath.parent.declarations.length === 4) {
const [themeDeclarator,, classNameDeclarator] = firstRelevantParentPath.parent.declarations;
if (core.types.isCallExpression(themeDeclarator.init) && core.types.isIdentifier(themeDeclarator.init.callee, {

@@ -78,5 +130,3 @@ name: 'createTheme'

}
const relevantParent = firstRelevantParentPath.node;
if (core.types.isObjectProperty(relevantParent) || core.types.isReturnStatement(relevantParent) || core.types.isArrowFunctionExpression(relevantParent) || core.types.isArrayExpression(relevantParent) || core.types.isSpreadElement(relevantParent)) {

@@ -88,8 +138,6 @@ const names = [];

const name = extractName(node);
if (name) {
names.unshift(name);
} // Traverse all the way to the root
}
// Traverse all the way to the root
return false;

@@ -102,3 +150,2 @@ });

};
const getRelevantCall = (node, namespaceImport, importIdentifiers) => {

@@ -108,3 +155,2 @@ const {

} = node;
if (namespaceImport && core.types.isMemberExpression(callee) && core.types.isIdentifier(callee.object, {

@@ -120,3 +166,2 @@ name: namespaceImport

}));
if (importInfo) {

@@ -127,3 +172,2 @@ return importInfo[1];

};
function index () {

@@ -135,3 +179,2 @@ return {

},
visitor: {

@@ -149,3 +192,2 @@ ImportDeclaration(path) {

const importName = core.types.isIdentifier(imported) ? imported.name : imported.value;
if (styleFunctions.includes(importName)) {

@@ -158,3 +200,2 @@ this.importIdentifiers.set(local.name, importName);

},
CallExpression(path) {

@@ -165,7 +206,9 @@ const {

const usedExport = getRelevantCall(node, this.namespaceImport, this.importIdentifiers);
if (usedExport && usedExport in debuggableFunctionConfig) {
if (node.arguments.length < debuggableFunctionConfig[usedExport].maxParams) {
const {
maxParams,
hasDebugId
} = debuggableFunctionConfig[usedExport];
if (node.arguments.length < maxParams && !(hasDebugId !== null && hasDebugId !== void 0 && hasDebugId(node))) {
const debugIdent = getDebugId(path);
if (debugIdent) {

@@ -177,3 +220,2 @@ node.arguments.push(core.types.stringLiteral(debugIdent));

}
}

@@ -180,0 +222,0 @@ };

@@ -12,26 +12,79 @@ 'use strict';

},
style$: {
maxParams: 2
},
createTheme: {
maxParams: 3
},
styleVariants: {
createTheme$: {
maxParams: 3
},
styleVariants: {
maxParams: 3,
hasDebugId: ({
arguments: args
}) => {
const previousArg = args[args.length - 1];
return core.types.isStringLiteral(previousArg) || core.types.isTemplateLiteral(previousArg);
}
},
styleVariants$: {
maxParams: 3,
hasDebugId: ({
arguments: args
}) => {
const previousArg = args[args.length - 1];
return core.types.isStringLiteral(previousArg) || core.types.isTemplateLiteral(previousArg);
}
},
fontFace: {
maxParams: 2
},
fontFace$: {
maxParams: 2
},
keyframes: {
maxParams: 2
},
keyframes$: {
maxParams: 2
},
createVar: {
maxParams: 1
},
createVar$: {
maxParams: 1
},
recipe: {
maxParams: 2
},
recipe$: {
maxParams: 2
},
createContainer: {
maxParams: 1
},
createContainer$: {
maxParams: 1
},
layer: {
maxParams: 2,
hasDebugId: ({
arguments: args
}) => {
const previousArg = args[args.length - 1];
return core.types.isStringLiteral(previousArg) || core.types.isTemplateLiteral(previousArg);
}
},
layer$: {
maxParams: 2,
hasDebugId: ({
arguments: args
}) => {
const previousArg = args[args.length - 1];
return core.types.isStringLiteral(previousArg) || core.types.isTemplateLiteral(previousArg);
}
}
};
const styleFunctions = [...Object.keys(debuggableFunctionConfig), 'globalStyle', 'createGlobalTheme', 'createThemeContract', 'globalFontFace', 'globalKeyframes', 'recipe'];
const styleFunctions = [...Object.keys(debuggableFunctionConfig), 'globalStyle', 'createGlobalTheme', 'createThemeContract', 'globalFontFace', 'globalKeyframes', 'globalLayer', 'recipe'];
const extractName = node => {

@@ -42,2 +95,4 @@ if (core.types.isObjectProperty(node) && core.types.isIdentifier(node.key)) {

return node.id.name;
} else if (core.types.isAssignmentExpression(node) && core.types.isIdentifier(node.left)) {
return node.left.name;
} else if (core.types.isExportDefaultDeclaration(node)) {

@@ -49,3 +104,2 @@ return 'default';

};
const getDebugId = path => {

@@ -55,6 +109,7 @@ const firstRelevantParentPath = path.findParent(({

}) => !(core.types.isCallExpression(node) || core.types.isSequenceExpression(node)));
if (!firstRelevantParentPath) {
return;
} // Special case: Handle `export const [themeClass, vars] = createTheme({});`
}
// Special case: Handle `export const [themeClass, vars] = createTheme({});`
// when it's already been compiled into this:

@@ -66,7 +121,4 @@ //

// vars = _createTheme2[1];
if (core.types.isVariableDeclaration(firstRelevantParentPath.parent) && firstRelevantParentPath.parent.declarations.length === 4) {
const [themeDeclarator,, classNameDeclarator] = firstRelevantParentPath.parent.declarations;
if (core.types.isCallExpression(themeDeclarator.init) && core.types.isIdentifier(themeDeclarator.init.callee, {

@@ -78,5 +130,3 @@ name: 'createTheme'

}
const relevantParent = firstRelevantParentPath.node;
if (core.types.isObjectProperty(relevantParent) || core.types.isReturnStatement(relevantParent) || core.types.isArrowFunctionExpression(relevantParent) || core.types.isArrayExpression(relevantParent) || core.types.isSpreadElement(relevantParent)) {

@@ -88,8 +138,6 @@ const names = [];

const name = extractName(node);
if (name) {
names.unshift(name);
} // Traverse all the way to the root
}
// Traverse all the way to the root
return false;

@@ -102,3 +150,2 @@ });

};
const getRelevantCall = (node, namespaceImport, importIdentifiers) => {

@@ -108,3 +155,2 @@ const {

} = node;
if (namespaceImport && core.types.isMemberExpression(callee) && core.types.isIdentifier(callee.object, {

@@ -120,3 +166,2 @@ name: namespaceImport

}));
if (importInfo) {

@@ -127,3 +172,2 @@ return importInfo[1];

};
function index () {

@@ -135,3 +179,2 @@ return {

},
visitor: {

@@ -149,3 +192,2 @@ ImportDeclaration(path) {

const importName = core.types.isIdentifier(imported) ? imported.name : imported.value;
if (styleFunctions.includes(importName)) {

@@ -158,3 +200,2 @@ this.importIdentifiers.set(local.name, importName);

},
CallExpression(path) {

@@ -165,7 +206,9 @@ const {

const usedExport = getRelevantCall(node, this.namespaceImport, this.importIdentifiers);
if (usedExport && usedExport in debuggableFunctionConfig) {
if (node.arguments.length < debuggableFunctionConfig[usedExport].maxParams) {
const {
maxParams,
hasDebugId
} = debuggableFunctionConfig[usedExport];
if (node.arguments.length < maxParams && !(hasDebugId !== null && hasDebugId !== void 0 && hasDebugId(node))) {
const debugIdent = getDebugId(path);
if (debugIdent) {

@@ -177,3 +220,2 @@ node.arguments.push(core.types.stringLiteral(debugIdent));

}
}

@@ -180,0 +222,0 @@ };

@@ -8,26 +8,79 @@ import { types } from '@babel/core';

},
style$: {
maxParams: 2
},
createTheme: {
maxParams: 3
},
styleVariants: {
createTheme$: {
maxParams: 3
},
styleVariants: {
maxParams: 3,
hasDebugId: ({
arguments: args
}) => {
const previousArg = args[args.length - 1];
return types.isStringLiteral(previousArg) || types.isTemplateLiteral(previousArg);
}
},
styleVariants$: {
maxParams: 3,
hasDebugId: ({
arguments: args
}) => {
const previousArg = args[args.length - 1];
return types.isStringLiteral(previousArg) || types.isTemplateLiteral(previousArg);
}
},
fontFace: {
maxParams: 2
},
fontFace$: {
maxParams: 2
},
keyframes: {
maxParams: 2
},
keyframes$: {
maxParams: 2
},
createVar: {
maxParams: 1
},
createVar$: {
maxParams: 1
},
recipe: {
maxParams: 2
},
recipe$: {
maxParams: 2
},
createContainer: {
maxParams: 1
},
createContainer$: {
maxParams: 1
},
layer: {
maxParams: 2,
hasDebugId: ({
arguments: args
}) => {
const previousArg = args[args.length - 1];
return types.isStringLiteral(previousArg) || types.isTemplateLiteral(previousArg);
}
},
layer$: {
maxParams: 2,
hasDebugId: ({
arguments: args
}) => {
const previousArg = args[args.length - 1];
return types.isStringLiteral(previousArg) || types.isTemplateLiteral(previousArg);
}
}
};
const styleFunctions = [...Object.keys(debuggableFunctionConfig), 'globalStyle', 'createGlobalTheme', 'createThemeContract', 'globalFontFace', 'globalKeyframes', 'recipe'];
const styleFunctions = [...Object.keys(debuggableFunctionConfig), 'globalStyle', 'createGlobalTheme', 'createThemeContract', 'globalFontFace', 'globalKeyframes', 'globalLayer', 'recipe'];
const extractName = node => {

@@ -38,2 +91,4 @@ if (types.isObjectProperty(node) && types.isIdentifier(node.key)) {

return node.id.name;
} else if (types.isAssignmentExpression(node) && types.isIdentifier(node.left)) {
return node.left.name;
} else if (types.isExportDefaultDeclaration(node)) {

@@ -45,3 +100,2 @@ return 'default';

};
const getDebugId = path => {

@@ -51,6 +105,7 @@ const firstRelevantParentPath = path.findParent(({

}) => !(types.isCallExpression(node) || types.isSequenceExpression(node)));
if (!firstRelevantParentPath) {
return;
} // Special case: Handle `export const [themeClass, vars] = createTheme({});`
}
// Special case: Handle `export const [themeClass, vars] = createTheme({});`
// when it's already been compiled into this:

@@ -62,7 +117,4 @@ //

// vars = _createTheme2[1];
if (types.isVariableDeclaration(firstRelevantParentPath.parent) && firstRelevantParentPath.parent.declarations.length === 4) {
const [themeDeclarator,, classNameDeclarator] = firstRelevantParentPath.parent.declarations;
if (types.isCallExpression(themeDeclarator.init) && types.isIdentifier(themeDeclarator.init.callee, {

@@ -74,5 +126,3 @@ name: 'createTheme'

}
const relevantParent = firstRelevantParentPath.node;
if (types.isObjectProperty(relevantParent) || types.isReturnStatement(relevantParent) || types.isArrowFunctionExpression(relevantParent) || types.isArrayExpression(relevantParent) || types.isSpreadElement(relevantParent)) {

@@ -84,8 +134,6 @@ const names = [];

const name = extractName(node);
if (name) {
names.unshift(name);
} // Traverse all the way to the root
}
// Traverse all the way to the root
return false;

@@ -98,3 +146,2 @@ });

};
const getRelevantCall = (node, namespaceImport, importIdentifiers) => {

@@ -104,3 +151,2 @@ const {

} = node;
if (namespaceImport && types.isMemberExpression(callee) && types.isIdentifier(callee.object, {

@@ -116,3 +162,2 @@ name: namespaceImport

}));
if (importInfo) {

@@ -123,3 +168,2 @@ return importInfo[1];

};
function index () {

@@ -131,3 +175,2 @@ return {

},
visitor: {

@@ -145,3 +188,2 @@ ImportDeclaration(path) {

const importName = types.isIdentifier(imported) ? imported.name : imported.value;
if (styleFunctions.includes(importName)) {

@@ -154,3 +196,2 @@ this.importIdentifiers.set(local.name, importName);

},
CallExpression(path) {

@@ -161,7 +202,9 @@ const {

const usedExport = getRelevantCall(node, this.namespaceImport, this.importIdentifiers);
if (usedExport && usedExport in debuggableFunctionConfig) {
if (node.arguments.length < debuggableFunctionConfig[usedExport].maxParams) {
const {
maxParams,
hasDebugId
} = debuggableFunctionConfig[usedExport];
if (node.arguments.length < maxParams && !(hasDebugId !== null && hasDebugId !== void 0 && hasDebugId(node))) {
const debugIdent = getDebugId(path);
if (debugIdent) {

@@ -173,3 +216,2 @@ node.arguments.push(types.stringLiteral(debugIdent));

}
}

@@ -176,0 +218,0 @@ };

{
"name": "@vanilla-extract/babel-plugin-debug-ids",
"version": "0.0.0-dts-bundle-20228303510",
"version": "0.0.0-experimental-macros-20236175227",
"description": "Zero-runtime Stylesheets-in-TypeScript",

@@ -23,7 +23,7 @@ "main": "dist/vanilla-extract-babel-plugin-debug-ids.cjs.js",

"dependencies": {
"@babel/core": "^7.13.10"
"@babel/core": "^7.20.7"
},
"devDependencies": {
"@types/babel__core": "^7.1.19"
"@types/babel__core": "^7.1.20"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc