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

@cobalt-ui/plugin-json

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-json - npm Package Compare versions

Comparing version 0.0.0 to 0.1.0

CHANGELOG.md

4

dist/index.d.ts

@@ -1,2 +0,2 @@

import type { Plugin, SchemaNode } from '@cobalt-ui/core';
import type { Plugin, Token } from '@cobalt-ui/core';
export interface JSONOutput {

@@ -17,4 +17,4 @@ name?: string;

/** modify values */
transformValue?: (value: any, token: SchemaNode) => any;
transformValue?: (token: Token, mode?: string) => any;
}
export default function json(options?: Options): Plugin;

@@ -10,20 +10,13 @@ export default function json(options) {

fileName,
contents: JSON.stringify(schema, (_, v) => {
// prevent circular refs for JSON
if (v.group)
delete v.group;
contents: JSON.stringify(schema, (_, token) => {
// apply transformValue()
if (transform && (v.type === 'token' || v.type === 'url' || v.type === 'file') && typeof v.value === 'object') {
if (Array.isArray(v.value)) {
for (let n = 0; n < v.value.length; n++) {
v.value[n] = transform(v.value[n], v);
if (transform && typeof token.type == 'string') {
token.value = transform(token);
if (token.mode) {
for (const mode of Object.keys(token.mode)) {
token.mode[mode] = transform(token, mode);
}
}
else {
for (const k of Object.keys(v.value)) {
v.value[k] = transform(v.value[k], v);
}
}
}
return v;
return token;
}, 2),

@@ -30,0 +23,0 @@ },

{
"name": "@cobalt-ui/plugin-json",
"description": "JSON builder for Cobalt UI design tokens",
"version": "0.0.0",
"version": "0.1.0",
"author": {

@@ -9,13 +9,21 @@ "name": "Drew Powers",

},
"repository": {
"type": "git",
"url": "https://github.com/drwpow/cobalt-ui.git",
"directory": "packages/plugin-json"
},
"homepage": "https://cobalt-ui.pages.dev",
"license": "MIT",
"type": "module",
"main": "./dist/index.js",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"devDependencies": {
"@cobalt-ui/core": "^0.1.0"
},
"scripts": {
"build": "rm -rf dist && tsc",
"build": "tsc",
"dev": "tsc -w"
},
"devDependencies": {
"@cobalt-ui/core": "^0.0.0"
}
}
"readme": "# @cobalt-ui/plugin-json\n\nGenerate JSON output from design tokens.\n\n```\nnpm i -D @cobalt-ui/plugin-json\n```\n\n```js\n// tokens.config.mjs\nimport json from \"@cobalt-ui/plugin-json\";\n\nexport default {\n plugins: [\n json({\n /** set the filename inside outDir */\n fileName: \"./tokens.json\",\n /** modify values */\n transformValue(value, token) {\n return value;\n },\n }),\n ],\n};\n```\n"
}

@@ -10,4 +10,4 @@ # @cobalt-ui/plugin-json

```js
// cobalt.config.mjs
import json from '@cobalt-ui/plugin-json';
// tokens.config.mjs
import json from "@cobalt-ui/plugin-json";

@@ -18,3 +18,3 @@ export default {

/** set the filename inside outDir */
fileName: './tokens.json',
fileName: "./tokens.json",
/** modify values */

@@ -21,0 +21,0 @@ transformValue(value, token) {

@@ -1,2 +0,2 @@

import type { BuildResult, Plugin, SchemaNode } from '@cobalt-ui/core';
import type { BuildResult, Plugin, Token } from '@cobalt-ui/core';

@@ -22,3 +22,3 @@ export interface JSONOutput {

/** modify values */
transformValue?: (value: any, token: SchemaNode) => any;
transformValue?: (token: Token, mode?: string) => any;
}

@@ -38,19 +38,13 @@

schema,
(_, v) => {
// prevent circular refs for JSON
if (v.group) delete v.group;
(_, token) => {
// apply transformValue()
if (transform && (v.type === 'token' || v.type === 'url' || v.type === 'file') && typeof v.value === 'object') {
if (Array.isArray(v.value)) {
for (let n = 0; n < v.value.length; n++) {
v.value[n] = transform(v.value[n], v);
if (transform && typeof token.type == 'string') {
token.value = transform(token);
if (token.mode) {
for (const mode of Object.keys(token.mode)) {
token.mode[mode] = transform(token, mode);
}
} else {
for (const k of Object.keys(v.value)) {
v.value[k] = transform(v.value[k], v);
}
}
}
return v;
return token;
},

@@ -57,0 +51,0 @@ 2

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