From cc36a18fdac7c0b4d672cd83b15b81c8452f6fc6 Mon Sep 17 00:00:00 2001 From: nlaitine Date: Tue, 29 Jan 2019 18:57:35 +0200 Subject: [PATCH 1/6] Added formats and fixed registerFormat --- types/theo/index.d.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/types/theo/index.d.ts b/types/theo/index.d.ts index f1aacfe038..271cfce8ed 100644 --- a/types/theo/index.d.ts +++ b/types/theo/index.d.ts @@ -27,7 +27,12 @@ export type Format = | "list.scss" | "module.js" | "common.js" - | "html"; + | "html" + | "json" + | "raw.json" + | "ios.json" + | "android.xml" + | "aura.tokens"; export type Transform = "raw" | "ios" | "android" | "web"; @@ -43,7 +48,7 @@ export type ValueTransform = export function convert(options: ConvertOptions): Promise; export function convertSync(options: ConvertOptions): string; export function registerFormat( - name: Format, + name: string, format: FormatResultFn | string ): void; export function registerTransform( @@ -77,6 +82,8 @@ export interface ImmutableStyleMap extends Map { export interface ConvertOptions { transform: TransformOptions; format: FormatOptions; + resolveAliases?: boolean; + resolveMetaAliases?: boolean; } export interface TransformOptions { From b84616f46c08b84855eecdf75cb8d9e0b3fac966 Mon Sep 17 00:00:00 2001 From: nlaitine Date: Tue, 29 Jan 2019 19:01:04 +0200 Subject: [PATCH 2/6] Upgraded immutable npm package --- types/theo/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/theo/package.json b/types/theo/package.json index 12231bb461..6c119dd781 100644 --- a/types/theo/package.json +++ b/types/theo/package.json @@ -1,6 +1,6 @@ { "private": true, "dependencies": { - "immutable": "^3.8.2" + "immutable": "4.0.0-rc.12" } } From b54b861785a2cc51529525a641d96afb9f30766d Mon Sep 17 00:00:00 2001 From: nlaitine Date: Tue, 29 Jan 2019 19:34:14 +0200 Subject: [PATCH 3/6] Tests updated --- types/theo/index.d.ts | 7 ++++--- types/theo/theo-tests.ts | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/types/theo/index.d.ts b/types/theo/index.d.ts index 271cfce8ed..870123fadc 100644 --- a/types/theo/index.d.ts +++ b/types/theo/index.d.ts @@ -1,10 +1,11 @@ -// Type definitions for theo 8.0 +// Type definitions for theo 8.1.1 // Project: https://github.com/salesforce-ux/theo // Definitions by: Pete Petrash +// Niko Laitinen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 3.2.4 -import { Iterable, Collection, Map, List, OrderedMap } from "immutable"; +import { Collection, Map, List, OrderedMap } from "immutable"; export type StyleProperty = | "name" diff --git a/types/theo/theo-tests.ts b/types/theo/theo-tests.ts index ceaaf9649c..154817793f 100644 --- a/types/theo/theo-tests.ts +++ b/types/theo/theo-tests.ts @@ -24,6 +24,7 @@ theo.registerValueTransform( "relative/pixelValue", prop => prop.get("category") === "sizing", prop => { + // @ts-ignore: prop can be undefined const value = prop.get("value").toString(); return parseFloat(value.replace(/rem/g, "")) * 16; } From d2e3e052c6388db1535cb7114db5db4e36bcf388 Mon Sep 17 00:00:00 2001 From: nlaitine Date: Fri, 1 Feb 2019 16:39:49 +0200 Subject: [PATCH 4/6] Changed Immutable version to match Theo --- types/theo/index.d.ts | 4 +++- types/theo/package.json | 2 +- types/theo/theo-tests.ts | 11 ++++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/types/theo/index.d.ts b/types/theo/index.d.ts index 870123fadc..3747a69fcf 100644 --- a/types/theo/index.d.ts +++ b/types/theo/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Pete Petrash // Niko Laitinen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 3.2.4 +// TypeScript Version: 3.2 import { Collection, Map, List, OrderedMap } from "immutable"; @@ -70,6 +70,8 @@ export type FormatResultFn = (result: ImmutableStyleMap) => string; export interface StyleMap { aliases: Aliases; + global?: Props; + imports?: string[]; props: Props; meta: Meta; options: object; diff --git a/types/theo/package.json b/types/theo/package.json index 6c119dd781..33339a3f75 100644 --- a/types/theo/package.json +++ b/types/theo/package.json @@ -1,6 +1,6 @@ { "private": true, "dependencies": { - "immutable": "4.0.0-rc.12" + "immutable": "3.8.2" } } diff --git a/types/theo/theo-tests.ts b/types/theo/theo-tests.ts index 154817793f..d7692e4265 100644 --- a/types/theo/theo-tests.ts +++ b/types/theo/theo-tests.ts @@ -21,11 +21,12 @@ theo.registerFormat( ); theo.registerValueTransform( - "relative/pixelValue", - prop => prop.get("category") === "sizing", + "easing/web", + prop => prop.get("category") === "easing", prop => { - // @ts-ignore: prop can be undefined - const value = prop.get("value").toString(); - return parseFloat(value.replace(/rem/g, "")) * 16; + const [x1, y1, x2, y2] = prop.get("value").toArray(); + return `cubic-bezier(${x1}, ${y1}, ${x2}, ${y2})`; } ); + +theo.registerTransform("web", ["color/rgb", "easing/web"]); From eb45679057a3b5cdf4f048bc0222896c20c212ed Mon Sep 17 00:00:00 2001 From: nlaitine Date: Fri, 1 Feb 2019 16:54:30 +0200 Subject: [PATCH 5/6] Removed type definition illegal patch version --- types/theo/index.d.ts | 2 +- types/theo/theo-tests.ts | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/types/theo/index.d.ts b/types/theo/index.d.ts index 3747a69fcf..3ff3770fdd 100644 --- a/types/theo/index.d.ts +++ b/types/theo/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for theo 8.1.1 +// Type definitions for theo 8.1 // Project: https://github.com/salesforce-ux/theo // Definitions by: Pete Petrash // Niko Laitinen diff --git a/types/theo/theo-tests.ts b/types/theo/theo-tests.ts index d7692e4265..ceaaf9649c 100644 --- a/types/theo/theo-tests.ts +++ b/types/theo/theo-tests.ts @@ -21,12 +21,10 @@ theo.registerFormat( ); theo.registerValueTransform( - "easing/web", - prop => prop.get("category") === "easing", + "relative/pixelValue", + prop => prop.get("category") === "sizing", prop => { - const [x1, y1, x2, y2] = prop.get("value").toArray(); - return `cubic-bezier(${x1}, ${y1}, ${x2}, ${y2})`; + const value = prop.get("value").toString(); + return parseFloat(value.replace(/rem/g, "")) * 16; } ); - -theo.registerTransform("web", ["color/rgb", "easing/web"]); From e83edb718ecda3f1f7b23a4600cdbbc8b60617d7 Mon Sep 17 00:00:00 2001 From: nlaitine Date: Fri, 1 Feb 2019 19:38:14 +0200 Subject: [PATCH 6/6] Loosen Transform and ValueTransform to string to allow registered custom values --- types/theo/index.d.ts | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/types/theo/index.d.ts b/types/theo/index.d.ts index 3ff3770fdd..ffc5dceaf7 100644 --- a/types/theo/index.d.ts +++ b/types/theo/index.d.ts @@ -35,17 +35,6 @@ export type Format = | "android.xml" | "aura.tokens"; -export type Transform = "raw" | "ios" | "android" | "web"; - -export type ValueTransform = - | "color/rgb" - | "color/hex" - | "color/hex8rgba" - | "color/hex8argb" - | "percentage/float" - | "relative/pixel" - | "relative/pixelValue"; - export function convert(options: ConvertOptions): Promise; export function convertSync(options: ConvertOptions): string; export function registerFormat( @@ -53,11 +42,11 @@ export function registerFormat( format: FormatResultFn | string ): void; export function registerTransform( - name: Transform, - valueTransforms: ValueTransform[] + name: string, + valueTransforms: string[] ): void; export function registerValueTransform( - name: ValueTransform, + name: string, predicate: (prop: Prop) => boolean, transform: (prop: Prop) => string | number ): void; @@ -90,7 +79,7 @@ export interface ConvertOptions { } export interface TransformOptions { - type?: Transform; + type?: string; file: string; data?: string; }