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

@pandacss/token-dictionary

Package Overview
Dependencies
Maintainers
1
Versions
1133
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pandacss/token-dictionary - npm Package Compare versions

Comparing version 0.0.0-dev-20240521123052 to 0.0.0-dev-20240521142947

170

dist/index.js

@@ -35,3 +35,3 @@ "use strict";

// src/dictionary.ts
var import_shared5 = require("@pandacss/shared");
var import_shared6 = require("@pandacss/shared");
var import_ts_pattern3 = require("ts-pattern");

@@ -722,2 +722,134 @@

// src/expand-token-references.ts
var import_shared5 = require("@pandacss/shared");
var expandTokenReferences = (str, resolve) => {
let expanded = "";
let index = 0;
let state = "char";
let tokenPath = "";
let fallback = "";
const currentStates = [];
while (index < str.length) {
const char = str[index];
if (char === "{") {
const endIndex = str.indexOf("}", index);
if (endIndex === -1) {
break;
}
const path = str.slice(index + 1, endIndex);
const resolved = resolve(path);
expanded += resolved ?? path;
index = endIndex + 1;
continue;
}
if (state === "token") {
if (char === ",") {
if (str[index] === "") {
index++;
}
state = "fallback";
currentStates.push(state);
const resolved = resolve(tokenPath);
if (resolved?.endsWith(")")) {
expanded += resolved.slice(0, -1);
}
tokenPath = "";
fallback = "";
continue;
}
}
if (state === "fallback") {
const nextFallback = fallback + char;
if (nextFallback === ", var(") {
const innerEndIndex = cssVarParser(str.slice(index + 1));
const endIndex = innerEndIndex + index + 1;
const cssVar2 = str.slice(index + 1, endIndex);
if (endIndex === -1) {
break;
}
expanded += ", var(" + cssVar2 + ")";
index = endIndex + 1;
state = currentStates.pop() ?? state;
fallback = "";
continue;
}
}
if (state === "token" || state === "fallback") {
index++;
if (char === ")") {
state = currentStates.pop() ?? state ?? "char";
fallback += char;
const resolved = tokenPath ? resolve(tokenPath) ?? (0, import_shared5.esc)(tokenPath) : tokenPath;
if (fallback) {
fallback = fallback.slice(1).trim();
if (!fallback.startsWith("token(") && fallback.endsWith(")")) {
fallback = fallback.slice(0, -1);
}
if (fallback.includes("token(")) {
const parsed = expandTokenReferences(fallback, resolve);
if (parsed) {
fallback = parsed.slice(0, -1);
}
} else if (fallback) {
const resolvedFallback = resolve(fallback);
if (resolvedFallback) {
fallback = resolvedFallback;
}
}
}
const lastChar = expanded.at(-1);
if (fallback) {
if (lastChar?.trim()) {
expanded += resolved.slice(0, -1) + (", " + fallback + ")");
} else {
expanded += fallback;
}
} else {
expanded += resolved || ")";
}
tokenPath = "";
fallback = "";
state = "char";
continue;
}
if (state === "token") {
tokenPath += char;
}
if (state === "fallback") {
fallback += char;
}
continue;
}
const tokenIndex = str.indexOf("token(", index);
if (tokenIndex !== -1) {
const innerTokenIndex = tokenIndex + "token(".length;
expanded += str.slice(index, tokenIndex);
index = innerTokenIndex;
state = "token";
currentStates.push(state);
continue;
}
expanded += char;
index++;
}
return expanded;
};
var cssVarParser = (str) => {
let index = 0;
const openedParenthesises = ["("];
while (index < str.length) {
const char = str[index];
if (char === "(") {
openedParenthesises.push(char);
} else if (char === ")") {
openedParenthesises.pop();
if (openedParenthesises.length === 0) {
return index;
}
}
index++;
}
return index;
};
// src/dictionary.ts

@@ -728,3 +860,3 @@ function expandBreakpoints(breakpoints) {

return {
breakpoints: (0, import_shared5.mapObject)(breakpoints, (value) => ({ value })),
breakpoints: (0, import_shared6.mapObject)(breakpoints, (value) => ({ value })),
sizes: Object.fromEntries(Object.entries(breakpoints).map(([key, value]) => [`breakpoint-${key}`, { value }]))

@@ -762,7 +894,7 @@ };

formatTokenName = (path) => path.join(".");
formatCssVar = (path, options) => (0, import_shared5.cssVar)(path.join("-"), options);
formatCssVar = (path, options) => (0, import_shared6.cssVar)(path.join("-"), options);
registerTokens() {
const { tokens = {}, semanticTokens = {}, breakpoints, themes = {} } = this.options;
const breakpointTokens = expandBreakpoints(breakpoints);
const computedTokens = (0, import_shared5.compact)({
const computedTokens = (0, import_shared6.compact)({
...tokens,

@@ -797,3 +929,3 @@ breakpoints: breakpointTokens.breakpoints,

const name = this.formatTokenName(path);
const normalizedToken = (0, import_shared5.isString)(token.value) || isCompositeTokenValue(token.value) ? { value: { base: token.value } } : token;
const normalizedToken = (0, import_shared6.isString)(token.value) || isCompositeTokenValue(token.value) ? { value: { base: token.value } } : token;
const { value, ...restData } = normalizedToken;

@@ -816,3 +948,3 @@ const node = new Token({

};
(0, import_shared5.walkObject)(
(0, import_shared6.walkObject)(
computedTokens,

@@ -825,3 +957,3 @@ (token, path) => {

);
(0, import_shared5.walkObject)(
(0, import_shared6.walkObject)(
semanticTokens,

@@ -835,4 +967,4 @@ (token, path) => {

Object.entries(themes).forEach(([theme, themeVariant]) => {
const condName = "_theme" + (0, import_shared5.capitalize)(theme);
(0, import_shared5.walkObject)(
const condName = "_theme" + (0, import_shared6.capitalize)(theme);
(0, import_shared6.walkObject)(
themeVariant.tokens ?? {},

@@ -847,3 +979,3 @@ (token, path) => {

);
(0, import_shared5.walkObject)(
(0, import_shared6.walkObject)(
themeVariant.semanticTokens ?? {},

@@ -908,3 +1040,3 @@ (token, path) => {

const conditions = token.extensions.conditions;
const transformedConditions = (0, import_shared5.walkObject)(conditions, (value) => exec({ value }), {
const transformedConditions = (0, import_shared6.walkObject)(conditions, (value) => exec({ value }), {
stop: isCompositeTokenValue

@@ -948,3 +1080,3 @@ });

usesReference(value) {
if (!(0, import_shared5.isString)(value))
if (!(0, import_shared6.isString)(value))
return false;

@@ -1015,3 +1147,5 @@ return this.getReferences(value).length > 0;

expandReferenceInValue(value) {
return expandReferences(value, (path) => {
return expandTokenReferences(value, (path) => {
if (!path)
return;
if (path.includes("/")) {

@@ -1024,3 +1158,6 @@ const mix = this.colorMix(path, this.view.get.bind(this.view));

}
return this.view.get(path);
const resolved = this.view.get(path);
if (resolved)
return resolved;
return tokenPathRegex.test(path) ? (0, import_shared6.esc)(path) : path;
});

@@ -1108,6 +1245,6 @@ }

valuesByCategory,
get: (0, import_shared5.memo)((path, fallback) => {
get: (0, import_shared6.memo)((path, fallback) => {
return flatValues.get(path) ?? fallback;
}),
getCategoryValues: (0, import_shared5.memo)((category) => {
getCategoryValues: (0, import_shared6.memo)((category) => {
const result = json[category];

@@ -1204,2 +1341,3 @@ if (result != null) {

}
var tokenPathRegex = /\w+\.\w+/;
// Annotate the CommonJS export names for ESM import in node:

@@ -1206,0 +1344,0 @@ 0 && (module.exports = {

8

package.json
{
"name": "@pandacss/token-dictionary",
"version": "0.0.0-dev-20240521123052",
"version": "0.0.0-dev-20240521142947",
"description": "Common error messages for css panda",

@@ -36,5 +36,5 @@ "main": "dist/index.js",

"ts-pattern": "5.0.8",
"@pandacss/logger": "^0.0.0-dev-20240521123052",
"@pandacss/shared": "0.0.0-dev-20240521123052",
"@pandacss/types": "0.0.0-dev-20240521123052"
"@pandacss/logger": "^0.0.0-dev-20240521142947",
"@pandacss/shared": "0.0.0-dev-20240521142947",
"@pandacss/types": "0.0.0-dev-20240521142947"
},

@@ -41,0 +41,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

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