Socket
Book a DemoInstallSign in
Socket

@cobalt-ui/plugin-ts

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cobalt-ui/plugin-ts - npm Package Compare versions

Comparing version

to
0.2.0

dist/index.js.map
# @cobalt-ui/plugin-ts
## 0.2.0
### Minor Changes
- 26bfb4c: Convert to JSON, follow design tokens spec
### Patch Changes
- Updated dependencies [26bfb4c]
- @cobalt-ui/utils@0.2.0
## 0.1.0
### Minor Changes

@@ -5,0 +17,0 @@

2

dist/index.d.ts
import type { ParsedToken, Plugin } from '@cobalt-ui/core';
export interface Options {
/** output file (default: "./tokens/index.ts") */
filename?: string;
fileName?: string;
/** modify values */

@@ -6,0 +6,0 @@ transformValue?: (token: ParsedToken) => string;

export default function ts(options) {
let fileName = options?.filename || './index.ts';
let fileName = options?.fileName || './index.ts';
let transformer = options?.transformValue;

@@ -48,11 +48,11 @@ function printTokensExport(schemaTokens) {

function printAltFunction() {
return `/** Get alternate values */
export function getAlt<T = string>(tokenID: keyof TokensFlat, mode: string): T {
return `/** Get mode value */
export function getMode<T = string>(tokenID: keyof TokensFlat, mode: string): T {
let defaultVal = tokens;
let altVal = modes;
let modeVal = modes;
for (const next of tokenID.split('.')) {
defaultVal = defaultVal[next];
if (altVal[next] !== undefined) altVal = altVal[next];
if (modeVal[next] !== undefined) modeVal = modeVal[next];
}
return (altVal && altVal[mode]) || defaultVal;
return (modeVal && modeVal[mode]) || defaultVal;
}`;

@@ -62,4 +62,4 @@ }

name: '@cobalt-ui/plugin-ts',
async build({ schema }) {
let code = [printTokensExport(schema.tokens), printModesExport(schema.tokens), printAltFunction()];
async build({ tokens }) {
let code = [printTokensExport(tokens), printModesExport(tokens), printAltFunction()];
return [

@@ -74,1 +74,2 @@ {

}
//# sourceMappingURL=index.js.map
{
"name": "@cobalt-ui/plugin-ts",
"description": "TypeScript builder for Cobalt UI design tokens",
"version": "0.1.0",
"version": "0.2.0",
"author": {

@@ -20,6 +20,6 @@ "name": "Drew Powers",

"dependencies": {
"@cobalt-ui/utils": "^0.1.0"
"@cobalt-ui/utils": "^0.2.0"
},
"devDependencies": {
"@cobalt-ui/core": "^0.1.0"
"@cobalt-ui/core": "^0.2.0"
},

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

@@ -5,3 +5,3 @@ import type { BuildResult, ParsedToken, Plugin } from '@cobalt-ui/core';

/** output file (default: "./tokens/index.ts") */
filename?: string;
fileName?: string;
/** modify values */

@@ -12,3 +12,3 @@ transformValue?: (token: ParsedToken) => string;

export default function ts(options?: Options): Plugin {
let fileName = options?.filename || './index.ts';
let fileName = options?.fileName || './index.ts';
let transformer = options?.transformValue;

@@ -63,11 +63,11 @@

function printAltFunction(): string {
return `/** Get alternate values */
export function getAlt<T = string>(tokenID: keyof TokensFlat, mode: string): T {
return `/** Get mode value */
export function getMode<T = string>(tokenID: keyof TokensFlat, mode: string): T {
let defaultVal = tokens;
let altVal = modes;
let modeVal = modes;
for (const next of tokenID.split('.')) {
defaultVal = defaultVal[next];
if (altVal[next] !== undefined) altVal = altVal[next];
if (modeVal[next] !== undefined) modeVal = modeVal[next];
}
return (altVal && altVal[mode]) || defaultVal;
return (modeVal && modeVal[mode]) || defaultVal;
}`;

@@ -78,4 +78,4 @@ }

name: '@cobalt-ui/plugin-ts',
async build({ schema }): Promise<BuildResult[]> {
let code = [printTokensExport(schema.tokens), printModesExport(schema.tokens), printAltFunction()];
async build({ tokens }): Promise<BuildResult[]> {
let code = [printTokensExport(tokens), printModesExport(tokens), printAltFunction()];
return [

@@ -82,0 +82,0 @@ {

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.