Skip to content

Commit

Permalink
Merge branch 'master' into flip-curve
Browse files Browse the repository at this point in the history
  • Loading branch information
mck authored Nov 7, 2024
2 parents a9e949c + 030b8a0 commit 1e1e81f
Show file tree
Hide file tree
Showing 35 changed files with 338 additions and 91 deletions.
5 changes: 0 additions & 5 deletions .changeset/curvy-peaches-pump.md

This file was deleted.

10 changes: 0 additions & 10 deletions .changeset/eight-pans-reflect.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/fresh-starfishes-sniff.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/giant-impalas-greet.md

This file was deleted.

8 changes: 0 additions & 8 deletions .changeset/grumpy-donuts-sit.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/khaki-jokes-sit.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/quiet-moose-drive.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/rude-tables-happen.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/shaggy-readers-shout.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/silver-carpets-kiss.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/slimy-ways-appear.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/wild-rice-kiss.md

This file was deleted.

22 changes: 22 additions & 0 deletions packages/graph-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# @tokens-studio/graph-editor

## 4.3.0

### Minor Changes

- 9fed81e: Removes tsup completely to prevent bundling, and rather to use raw typescript compilation
- fb46f15: Upgrade mafs library to latest & remove mathjax

### Patch Changes

- 02c859b: Fix an issue where create subgraph did not make the create inputs deletable
- Updated dependencies [02c859b]
- Updated dependencies [9fed81e]
- Updated dependencies [64d2acd]
- Updated dependencies [02c859b]
- Updated dependencies [02c859b]
- Updated dependencies [02c859b]
- Updated dependencies [7b4a564]
- Updated dependencies [02c859b]
- Updated dependencies [02c859b]
- Updated dependencies [fb46f15]
- @tokens-studio/graph-engine@4.0.0

## 4.2.0

### Minor Changes
Expand Down
9 changes: 4 additions & 5 deletions packages/graph-editor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tokens-studio/graph-editor",
"version": "4.2.0",
"version": "4.3.0",
"description": "UI for the graph engine",
"author": "[email protected]",
"type": "module",
Expand Down Expand Up @@ -59,7 +59,6 @@
"@tokens-studio/ui": "^0.6.9",
"@xzdarcy/react-timeline-editor": "^0.1.9",
"array-move": "^4.0.0",
"better-react-mathjax": "^2.0.3",
"classnames": "^2.3.2",
"cmdk": "^0.2.0",
"copy-to-clipboard": "^3.3.3",
Expand All @@ -70,7 +69,7 @@
"iconoir-react": "^7.6.0",
"json5": "^2.2.3",
"jszip": "^3.10.1",
"mafs": "^0.17.1",
"mafs": "^0.20.0",
"mdn-data": "^2.3.2",
"mobx-react-lite": "^4.0.5",
"rc-dock": "^3.3.0",
Expand Down Expand Up @@ -108,7 +107,6 @@
"@storybook/addon-mdx-gfm": "^8.0.9",
"@storybook/react": "^8.0.9",
"@storybook/react-vite": "^8.0.9",
"postcss-scss": "^4.0.9",
"@tokens-studio/eslint-config-custom": "*",
"@tokens-studio/prettier-config-custom": "*",
"@types/graphlib": "^2.1.8",
Expand All @@ -126,6 +124,7 @@
"postcss-import": "^16.1.0",
"postcss-nested": "^6.2.0",
"postcss-preset-env": "^10.0.5",
"postcss-scss": "^4.0.9",
"resp": "^0.1.1",
"resq": "^1.11.0",
"start-server-and-test": "^2.0.4",
Expand All @@ -138,4 +137,4 @@
"publishConfig": {
"access": "public"
}
}
}
11 changes: 3 additions & 8 deletions packages/graph-editor/src/components/preview/mathExpression.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import { MathJax, MathJaxContext } from 'better-react-mathjax';
import { Text } from '@tokens-studio/ui';
import React from 'react';

export const MathExpression = ({ value }) => {
return (
<>
{value && (
<MathJaxContext>
<Text
css={{ fontFamily: '$mono', fontSize: 'x-large', padding: '$5' }}
>
<MathJax>$${value}$$</MathJax>
</Text>
</MathJaxContext>
<Text css={{ fontFamily: '$mono', fontSize: 'x-large', padding: '$5' }}>
{value}
</Text>
)}
</>
);
Expand Down
18 changes: 18 additions & 0 deletions packages/graph-engine/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# @tokens-studio/graph-engine

## 4.0.0

### Major Changes

- 02c859b: Removed .getInput and .getRawInput from the Node. Direct access to the underlying ports are preferred over these utility methods
- 02c859b: Removed .setOutput from the Node class, this should be replaced with direct port manipulation
- 02c859b: Removed .getOutput from the node. This was never used and can rather be implemented as a utility method
- 02c859b: Removed getAllOutputs from the Node definition, this was never used and can rather be implemented as a utility

### Minor Changes

- 9fed81e: Removes tsup completely to prevent bundling, and rather to use raw typescript compilation
- 64d2acd: Add Replace Item node which lets you replace a specific item of an array.
- 02c859b: Add typing/hasValue node that lets you check if a value is present
- 02c859b: Add pad node that lets you fill a string to a certain lenght with a given character, like 25 to 025
- 7b4a564: Add support for all colorjs color spaces in the color nodes like color to string
- fb46f15: Upgrade mafs library to latest & remove mathjax

## 3.1.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/graph-engine/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tokens-studio/graph-engine",
"version": "3.1.0",
"version": "4.0.0",
"description": "An execution engine to handle Token Studios generators and resolvers",
"license": "MPL-2.0",
"author": "[email protected]",
Expand Down
2 changes: 2 additions & 0 deletions packages/graph-engine/src/nodes/array/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import flatten from './flatten.js';
import indexArray from './indexArray.js';
import inject from './inject.js';
import push from './push.js';
import replace from './replace.js';
import reverse from './reverse.js';
import slice from './slice.js';
import sort from './sort.js';
Expand All @@ -21,6 +22,7 @@ export const nodes = [
indexArray,
inject,
push,
replace,
reverse,
slice,
sort
Expand Down
59 changes: 59 additions & 0 deletions packages/graph-engine/src/nodes/array/replace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import {
AnyArraySchema,
AnySchema,
NumberSchema
} from '../../schemas/index.js';
import { INodeDefinition, ToInput, ToOutput } from '../../index.js';
import { Node } from '../../programmatic/node.js';

export default class NodeDefinition<T> extends Node {
static title = 'Replace Item';
static type = 'studio.tokens.array.replace';
static description = 'Replaces an item in an array at a specified index.';

declare inputs: ToInput<{
array: T[];
item: T;
index: number;
}>;

declare outputs: ToOutput<{
array: T[];
}>;

constructor(props: INodeDefinition) {
super(props);
this.addInput('array', {
type: AnyArraySchema
});
this.addInput('item', {
type: AnySchema
});
this.addInput('index', {
type: NumberSchema
});
this.addOutput('array', {
type: AnyArraySchema
});
}

execute(): void | Promise<void> {
const { item, index, array } = this.getAllInputs();
const arrayType = this.inputs.array.type;
this.inputs.item.setType(arrayType.items);

// Create a copy of the array value
const result = [...array];

if (index >= 0 && index < result.length) {
result[index] = item;
} else if (index < 0 && Math.abs(index) <= result.length) {
// Handle negative indices by counting from the end
const actualIndex = result.length + index;
result[actualIndex] = item;
}

// Set the output using the modified result and the original array type
this.outputs.array.set(result, arrayType);
}
}
6 changes: 5 additions & 1 deletion packages/graph-engine/src/nodes/preview/mathExpression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ export default class NodeDefinition extends Node {
static title = 'Math Expression';
static type = 'studio.tokens.preview.mathExpression';

static description = 'Visuaize a math expression';
static description = 'Visualize a math expression';

static annotations: Record<string, unknown> = {
deprecated: true
};

constructor(props) {
super(props);
Expand Down
58 changes: 58 additions & 0 deletions packages/graph-engine/tests/suites/nodes/array/replace.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { Graph } from '../../../../src/graph/graph.js';
import { describe, expect, test } from 'vitest';
import Node from '../../../../src/nodes/array/replace.js';

describe('array/replace', () => {
test('replaces an item at a positive index', async () => {
const graph = new Graph();
const node = new Node({ graph });

node.inputs.array.setValue([1, 2, 3]);
node.inputs.item.setValue(4);
node.inputs.index.setValue(1);

await node.execute();

expect(node.outputs.array.value).to.eql([1, 4, 3]);
});

test('replaces an item at a negative index', async () => {
const graph = new Graph();
const node = new Node({ graph });

node.inputs.array.setValue([1, 2, 3]);
node.inputs.item.setValue(4);
node.inputs.index.setValue(-2);

await node.execute();

expect(node.outputs.array.value).to.eql([1, 4, 3]);
});

test('does not modify array when index is out of bounds', async () => {
const graph = new Graph();
const node = new Node({ graph });

node.inputs.array.setValue([1, 2, 3]);
node.inputs.item.setValue(4);
node.inputs.index.setValue(5);

await node.execute();

expect(node.outputs.array.value).to.eql([1, 2, 3]);
});

test('does not mutate the original array', async () => {
const graph = new Graph();
const node = new Node({ graph });

const originalArray = [1, 2, 3];
node.inputs.array.setValue(originalArray);
node.inputs.item.setValue(4);
node.inputs.index.setValue(1);

await node.execute();

expect(originalArray).to.eql([1, 2, 3]);
});
});
20 changes: 20 additions & 0 deletions packages/migrations/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# @tokens-studio/graph-engine

## 0.14.0

### Minor Changes

- 9fed81e: Removes tsup completely to prevent bundling, and rather to use raw typescript compilation

### Patch Changes

- Updated dependencies [02c859b]
- Updated dependencies [9fed81e]
- Updated dependencies [64d2acd]
- Updated dependencies [02c859b]
- Updated dependencies [02c859b]
- Updated dependencies [02c859b]
- Updated dependencies [7b4a564]
- Updated dependencies [02c859b]
- Updated dependencies [02c859b]
- Updated dependencies [fb46f15]
- @tokens-studio/graph-engine@4.0.0

## 0.13.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/migrations/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tokens-studio/graph-engine-migration",
"version": "0.13.0",
"version": "0.14.0",
"description": "A package to upgrade old graph engine files to the new format",
"license": "MPL-2.0",
"author": "[email protected]",
Expand Down
Loading

0 comments on commit 1e1e81f

Please sign in to comment.