@builder.io/dev-tools 1.0.20 → 1.1.0-rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/cli/index.cjs +1008 -1
- package/core/index.cjs +1 -1
- package/core/index.mjs +1 -1
- package/figma/index.cjs +1 -0
- package/figma/index.d.ts +1 -0
- package/figma/index.mjs +1 -0
- package/figma/jsx-runtime/index.cjs +7 -0
- package/figma/jsx-runtime/index.d.ts +46 -0
- package/figma/jsx-runtime/index.js +7 -0
- package/figma/jsx-runtime/react.d.ts +5220 -0
- package/package.json +38 -6
- package/server/index.cjs +29 -28
- package/server/index.mjs +29 -28
- package/types/cli/add.d.ts +53 -0
- package/types/cli/credentials.d.ts +31 -0
- package/types/cli/download.d.ts +10 -0
- package/types/cli/figma-publish.d.ts +39 -0
- package/types/cli/figma.d.ts +9 -0
- package/types/cli/help.d.ts +1 -0
- package/types/cli/prettier.d.ts +1 -0
- package/types/figma/index.d.ts +70 -0
- package/types/figma/jsx-runtime/index.d.cts +2 -0
- package/types/figma/jsx-runtime/index.d.ts +2 -0
package/package.json
CHANGED
|
@@ -1,17 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder.io/dev-tools",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0-rc1",
|
|
4
4
|
"description": "Builder.io Visual CMS Devtools",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./core/index.cjs",
|
|
7
7
|
"module": "./core/index.mjs",
|
|
8
8
|
"types": "./core/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./core/index.mjs",
|
|
12
|
+
"require": "./core/index.cjs",
|
|
13
|
+
"types": "./core/index.d.ts"
|
|
14
|
+
},
|
|
10
15
|
"./core": {
|
|
11
16
|
"import": "./core/index.mjs",
|
|
12
17
|
"require": "./core/index.cjs",
|
|
13
18
|
"types": "./core/index.d.ts"
|
|
14
19
|
},
|
|
20
|
+
"./figma": {
|
|
21
|
+
"import": "./figma/index.mjs",
|
|
22
|
+
"require": "./figma/index.cjs",
|
|
23
|
+
"types": "./figma/index.d.ts"
|
|
24
|
+
},
|
|
25
|
+
"./figma/jsx-runtime": {
|
|
26
|
+
"import": "./figma/jsx-runtime/index.mjs",
|
|
27
|
+
"require": "./figma/jsx-runtime/index.cjs",
|
|
28
|
+
"types": "./figma/jsx-runtime/index.d.ts"
|
|
29
|
+
},
|
|
15
30
|
"./next": {
|
|
16
31
|
"import": "./next/index.mjs",
|
|
17
32
|
"require": "./next/index.cjs",
|
|
@@ -54,7 +69,9 @@
|
|
|
54
69
|
}
|
|
55
70
|
},
|
|
56
71
|
"bin": {
|
|
57
|
-
"builder-dev-tools": "./cli/index.cjs"
|
|
72
|
+
"builder-dev-tools": "./cli/index.cjs",
|
|
73
|
+
"builder.io": "./cli/index.cjs",
|
|
74
|
+
"bio": "./cli/index.cjs"
|
|
58
75
|
},
|
|
59
76
|
"files": [
|
|
60
77
|
"core",
|
|
@@ -65,12 +82,14 @@
|
|
|
65
82
|
"types",
|
|
66
83
|
"vite",
|
|
67
84
|
"webpack",
|
|
68
|
-
"angular"
|
|
85
|
+
"angular",
|
|
86
|
+
"figma"
|
|
69
87
|
],
|
|
70
88
|
"dependencies": {
|
|
71
89
|
"launch-editor": "^2.6.0",
|
|
72
90
|
"prettier": "^2.8.8",
|
|
73
|
-
"typescript": "^5.1.6"
|
|
91
|
+
"typescript": "^5.1.6",
|
|
92
|
+
"open": "^10.1.0"
|
|
74
93
|
},
|
|
75
94
|
"homepage": "https://builder.io/",
|
|
76
95
|
"keywords": [
|
|
@@ -84,7 +103,20 @@
|
|
|
84
103
|
"react",
|
|
85
104
|
"remix",
|
|
86
105
|
"next",
|
|
87
|
-
"qwik"
|
|
106
|
+
"qwik",
|
|
107
|
+
"vcp",
|
|
108
|
+
"visual copilot",
|
|
109
|
+
"figma to code",
|
|
110
|
+
"design to code",
|
|
111
|
+
"figma to react",
|
|
112
|
+
"figma"
|
|
88
113
|
],
|
|
89
|
-
"license": "MIT"
|
|
114
|
+
"license": "MIT",
|
|
115
|
+
"devDependencies": {
|
|
116
|
+
"@types/prompts": "^2.4.9",
|
|
117
|
+
"@clack/prompts": "^0.7.0",
|
|
118
|
+
"emphasize": "^7.0.0",
|
|
119
|
+
"enquirer": "^2.4.1",
|
|
120
|
+
"prompts": "^2.4.2"
|
|
121
|
+
}
|
|
90
122
|
}
|
package/server/index.cjs
CHANGED
|
@@ -161,43 +161,44 @@ Visit https://www.docs.developers.amplitude.com/data/sdks/browser-2/#tracking-de
|
|
|
161
161
|
<!-- Route message for react -->
|
|
162
162
|
<div id="react-message-section" hidden>
|
|
163
163
|
<span
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
164
|
+
>Next, add the following path and component in your React app
|
|
165
|
+
routing setup</span
|
|
166
|
+
>
|
|
167
|
+
<ol id="react-router-steps">
|
|
168
|
+
<li>
|
|
169
|
+
Update path to <strong>'/builder-demo'</strong> or
|
|
170
|
+
<strong>'/*'</strong>
|
|
171
|
+
</li>
|
|
172
|
+
<li>
|
|
173
|
+
Add <strong>'BuilderPage'</strong> component from
|
|
174
|
+
<code>builder-page</code> file
|
|
175
|
+
</li>
|
|
176
|
+
</ol>
|
|
177
177
|
</div>
|
|
178
178
|
|
|
179
179
|
<!-- Route message for angular -->
|
|
180
180
|
<div id="angular-message-section" hidden>
|
|
181
|
-
<span
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
181
|
+
<span
|
|
182
|
+
>Next, add the following path for Builder page in your Angular
|
|
183
|
+
routes</span
|
|
184
|
+
>
|
|
185
|
+
<ol id="angular-router-steps">
|
|
186
|
+
<li>
|
|
187
|
+
Update path to <strong>'builder-demo'</strong> or
|
|
188
|
+
<strong>'**'</strong>
|
|
189
|
+
</li>
|
|
190
|
+
<li>
|
|
191
|
+
Add <strong>'BuilderPage'</strong> component from
|
|
192
|
+
<code>builder-page.component</code> file
|
|
193
|
+
</li>
|
|
194
|
+
</ol>
|
|
192
195
|
</div>
|
|
193
|
-
|
|
196
|
+
|
|
194
197
|
<a id="need-help" href="#" hidden>
|
|
195
198
|
<span id="help-text">Need help?</span>
|
|
196
199
|
<span id="help-icon"></span>
|
|
197
200
|
</a>
|
|
198
|
-
<div id="router-checkbox-div">
|
|
199
|
-
</div>
|
|
200
|
-
|
|
201
|
+
<div id="router-checkbox-div"></div>
|
|
201
202
|
</div>
|
|
202
203
|
<div id="router-finish-button" hidden>
|
|
203
204
|
<a class="button next-step" href="#">
|
package/server/index.mjs
CHANGED
|
@@ -161,43 +161,44 @@ Visit https://www.docs.developers.amplitude.com/data/sdks/browser-2/#tracking-de
|
|
|
161
161
|
<!-- Route message for react -->
|
|
162
162
|
<div id="react-message-section" hidden>
|
|
163
163
|
<span
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
164
|
+
>Next, add the following path and component in your React app
|
|
165
|
+
routing setup</span
|
|
166
|
+
>
|
|
167
|
+
<ol id="react-router-steps">
|
|
168
|
+
<li>
|
|
169
|
+
Update path to <strong>'/builder-demo'</strong> or
|
|
170
|
+
<strong>'/*'</strong>
|
|
171
|
+
</li>
|
|
172
|
+
<li>
|
|
173
|
+
Add <strong>'BuilderPage'</strong> component from
|
|
174
|
+
<code>builder-page</code> file
|
|
175
|
+
</li>
|
|
176
|
+
</ol>
|
|
177
177
|
</div>
|
|
178
178
|
|
|
179
179
|
<!-- Route message for angular -->
|
|
180
180
|
<div id="angular-message-section" hidden>
|
|
181
|
-
<span
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
181
|
+
<span
|
|
182
|
+
>Next, add the following path for Builder page in your Angular
|
|
183
|
+
routes</span
|
|
184
|
+
>
|
|
185
|
+
<ol id="angular-router-steps">
|
|
186
|
+
<li>
|
|
187
|
+
Update path to <strong>'builder-demo'</strong> or
|
|
188
|
+
<strong>'**'</strong>
|
|
189
|
+
</li>
|
|
190
|
+
<li>
|
|
191
|
+
Add <strong>'BuilderPage'</strong> component from
|
|
192
|
+
<code>builder-page.component</code> file
|
|
193
|
+
</li>
|
|
194
|
+
</ol>
|
|
192
195
|
</div>
|
|
193
|
-
|
|
196
|
+
|
|
194
197
|
<a id="need-help" href="#" hidden>
|
|
195
198
|
<span id="help-text">Need help?</span>
|
|
196
199
|
<span id="help-icon"></span>
|
|
197
200
|
</a>
|
|
198
|
-
<div id="router-checkbox-div">
|
|
199
|
-
</div>
|
|
200
|
-
|
|
201
|
+
<div id="router-checkbox-div"></div>
|
|
201
202
|
</div>
|
|
202
203
|
<div id="router-finish-button" hidden>
|
|
203
204
|
<a class="button next-step" href="#">
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/// <reference types="@figma/plugin-typings" />
|
|
2
|
+
import type { ComponentInfo, ComponentInput, ComponentRegistry, DevToolsSys } from "../types";
|
|
3
|
+
import type { FigmaArgs } from "./figma";
|
|
4
|
+
export declare const runFigmaAdd: (sys: DevToolsSys, args: FigmaArgs) => Promise<void>;
|
|
5
|
+
export interface FigmaComponentInput {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
value?: any;
|
|
9
|
+
type: string;
|
|
10
|
+
baseType: "text" | "variant" | "boolean" | "slot";
|
|
11
|
+
variantOptions?: string[];
|
|
12
|
+
isDefault: boolean;
|
|
13
|
+
ref?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface FigmaComponentInfo {
|
|
16
|
+
documentName: string;
|
|
17
|
+
key: string;
|
|
18
|
+
tree: string;
|
|
19
|
+
jsx: string;
|
|
20
|
+
name: string;
|
|
21
|
+
inputs: FigmaComponentInput[];
|
|
22
|
+
description: string;
|
|
23
|
+
documentationLinks: string[];
|
|
24
|
+
instanceId: string;
|
|
25
|
+
}
|
|
26
|
+
export declare const parseFigmaURL: (str: string) => {
|
|
27
|
+
fileID: string;
|
|
28
|
+
nodeId: string;
|
|
29
|
+
} | null;
|
|
30
|
+
export declare const getFigmaNodeData: (auth: {
|
|
31
|
+
access_token: string;
|
|
32
|
+
oauth: boolean;
|
|
33
|
+
}, fileId: string, nodeId: string) => Promise<any>;
|
|
34
|
+
export declare function getInputsSlotsFromComponentPropertyDefinitions(mainComponent: ComponentSetNode | ComponentNode): {
|
|
35
|
+
inputs: FigmaComponentInput[];
|
|
36
|
+
nameMap: (key: string) => string;
|
|
37
|
+
};
|
|
38
|
+
export declare const REMOVE_EMOJI: RegExp;
|
|
39
|
+
export declare function getFigmaComponentName(name: string): string;
|
|
40
|
+
export interface MappingCodeV2 {
|
|
41
|
+
figmaInterface: string;
|
|
42
|
+
reactInterface: string;
|
|
43
|
+
componentRegistry: string;
|
|
44
|
+
figmaComponentName: string;
|
|
45
|
+
figmaTree: string;
|
|
46
|
+
meta?: Record<string, any>;
|
|
47
|
+
previousCode?: string;
|
|
48
|
+
prompt?: string;
|
|
49
|
+
}
|
|
50
|
+
export declare function getMappingData(figmaNode: FigmaComponentInfo, registeredCmp: ComponentInfo, cmpRegistry: ComponentRegistry, useJSX: boolean): MappingCodeV2;
|
|
51
|
+
export declare const getTypeFromComponentInput: (input: ComponentInput) => string;
|
|
52
|
+
export declare const getPropertyAccessor: (name: string) => string;
|
|
53
|
+
export declare function getMappingPrompt(figmaNode: FigmaComponentInfo, registeredCmp: ComponentInfo, cmpRegistry: ComponentRegistry, useJSX?: boolean): string;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { DevToolsSys } from "../types";
|
|
2
|
+
import type { FigmaArgs } from "./figma";
|
|
3
|
+
export interface CredentialsOptions {
|
|
4
|
+
builderPublicKey?: boolean;
|
|
5
|
+
builderPrivateKey?: boolean;
|
|
6
|
+
figmaAuth?: boolean;
|
|
7
|
+
force?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface FigmaAuth {
|
|
10
|
+
access_token: string;
|
|
11
|
+
oauth: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface BuilderAuth {
|
|
14
|
+
privateKey: string;
|
|
15
|
+
spaceId: string;
|
|
16
|
+
name: string;
|
|
17
|
+
userId: string;
|
|
18
|
+
}
|
|
19
|
+
export interface Credentials {
|
|
20
|
+
figmaAuth?: FigmaAuth;
|
|
21
|
+
builderPublicKey?: string;
|
|
22
|
+
builderPrivateKey?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare const isCI: (args: FigmaArgs) => boolean;
|
|
25
|
+
export declare const getCredentials: (sys: DevToolsSys, args: FigmaArgs, opts: CredentialsOptions) => Promise<{
|
|
26
|
+
figmaAuth: FigmaAuth | undefined;
|
|
27
|
+
builderPublicKey: string | undefined;
|
|
28
|
+
builderPrivateKey: string | undefined;
|
|
29
|
+
}>;
|
|
30
|
+
export declare function getFigmaAuth(): Promise<FigmaAuth>;
|
|
31
|
+
export declare function getBuilderAuth(sys: DevToolsSys): Promise<BuilderAuth>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FigmaArgs } from "./figma";
|
|
2
|
+
import type { DevToolsSys } from "../types";
|
|
3
|
+
import { type FigmaBuilderLink } from "./figma-publish";
|
|
4
|
+
interface KVGetRequest {
|
|
5
|
+
privateKey: string;
|
|
6
|
+
spaceId: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const runFigmaMigrate: (sys: DevToolsSys, args: FigmaArgs) => Promise<void>;
|
|
9
|
+
export declare function getBuilderSpaceFigmaLinks(kvReq: KVGetRequest): Promise<FigmaBuilderLink[]>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { DevToolsSys, ExportType } from "../types";
|
|
2
|
+
import type { FigmaArgs } from "./figma";
|
|
3
|
+
export interface FigmaBuilderLink {
|
|
4
|
+
builderName: string;
|
|
5
|
+
figmaName: string;
|
|
6
|
+
figmaKey: string;
|
|
7
|
+
inputMapper?: string;
|
|
8
|
+
originalInputMapper?: string;
|
|
9
|
+
exportType?: ExportType;
|
|
10
|
+
importName?: string;
|
|
11
|
+
importPath?: string;
|
|
12
|
+
source: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const runFigmaPublish: (sys: DevToolsSys, args: FigmaArgs) => Promise<void>;
|
|
15
|
+
export declare const FIGMA_CONNECT_CALL = "figmaMapping";
|
|
16
|
+
export declare function findAllMappingFiles(sys: DevToolsSys): Promise<string[]>;
|
|
17
|
+
export interface BuilderSpace {
|
|
18
|
+
privateKey: string;
|
|
19
|
+
spaceId: string;
|
|
20
|
+
userId: string;
|
|
21
|
+
name?: string;
|
|
22
|
+
}
|
|
23
|
+
interface KVGetRequest extends BuilderSpace {
|
|
24
|
+
docId: string;
|
|
25
|
+
}
|
|
26
|
+
interface KVPutRequest extends KVGetRequest {
|
|
27
|
+
/**
|
|
28
|
+
* Must be an object but not an array. TS is a fool sometimes.
|
|
29
|
+
* https://stackoverflow.com/a/70448528/1520787
|
|
30
|
+
*/
|
|
31
|
+
data: Record<string, any> & {
|
|
32
|
+
length?: never;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export interface FigmaBuilderData {
|
|
36
|
+
figmaBuilderLinks: FigmaBuilderLink[];
|
|
37
|
+
}
|
|
38
|
+
export declare function putBuilderSpaceKv(kvReq: KVPutRequest): Promise<void>;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DevToolsSys } from "../types";
|
|
2
|
+
export interface FigmaArgs {
|
|
3
|
+
privateKey?: string;
|
|
4
|
+
figmaToken?: string;
|
|
5
|
+
ci?: boolean;
|
|
6
|
+
help?: boolean;
|
|
7
|
+
_: string[];
|
|
8
|
+
}
|
|
9
|
+
export declare const runFigmaCommand: (sys: DevToolsSys, subCommand: string, args: FigmaArgs) => Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function printHelp(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatCode(code: string): Promise<string>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/// <reference types="@figma/plugin-typings" />
|
|
2
|
+
export type FigmaNodeType = "COMPONENT" | "ELLIPSE" | "FRAME" | "GROUP" | "INSTANCE" | "LINE" | "POLYGON" | "RECTANGLE" | "STAR" | "TEXT" | "VECTOR";
|
|
3
|
+
export interface FigmaComponentInput {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
value?: any;
|
|
7
|
+
type: string;
|
|
8
|
+
baseType: "text" | "variant" | "boolean" | "slot";
|
|
9
|
+
variantOptions?: string[];
|
|
10
|
+
isDefault: boolean;
|
|
11
|
+
ref?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface FigmaNode {
|
|
14
|
+
"@type": "passedNode";
|
|
15
|
+
$id: string;
|
|
16
|
+
$name: string;
|
|
17
|
+
$type: FigmaNodeType;
|
|
18
|
+
$inputs: readonly FigmaComponentInput[];
|
|
19
|
+
$componentName?: string;
|
|
20
|
+
$rawNode: SceneNode;
|
|
21
|
+
/** Represents the text content of the node and its descendants */
|
|
22
|
+
$textContent: string;
|
|
23
|
+
/** URL to the rasterized image of this node */
|
|
24
|
+
$imageUrl: string;
|
|
25
|
+
$children: readonly FigmaNode[];
|
|
26
|
+
/** Recursively finds the first node that matches the callback */
|
|
27
|
+
$findOne(callback: (node: SceneNode) => boolean): FigmaNode | undefined;
|
|
28
|
+
/** Recursively finds the first figma child with the given name */
|
|
29
|
+
$findOneByName(name: string | RegExp): FigmaNode | undefined;
|
|
30
|
+
/** @deprecated Use $type instead */
|
|
31
|
+
type: FigmaNodeType;
|
|
32
|
+
/** @deprecated - */
|
|
33
|
+
props: {};
|
|
34
|
+
/** @deprecated - */
|
|
35
|
+
key: string | null;
|
|
36
|
+
}
|
|
37
|
+
export interface BaseFigmaProps {
|
|
38
|
+
$id: string;
|
|
39
|
+
$name: string;
|
|
40
|
+
$type: FigmaNodeType;
|
|
41
|
+
$inputs: readonly FigmaComponentInput[];
|
|
42
|
+
$componentName?: string;
|
|
43
|
+
/** Represents the text content of the node and its descendants */
|
|
44
|
+
$textContent: string;
|
|
45
|
+
$css: Readonly<Record<string, string>>;
|
|
46
|
+
/** URL to the rasterized image of this node */
|
|
47
|
+
$imageUrl: string;
|
|
48
|
+
/** Direct children of the root component node or instance */
|
|
49
|
+
$children: readonly FigmaNode[];
|
|
50
|
+
/** Recursively finds the first figma child with the given name */
|
|
51
|
+
$findOneByName(name: string | RegExp): FigmaNode | undefined;
|
|
52
|
+
/** Recursively finds the first node that matches the callback */
|
|
53
|
+
$findOne(callback: (node: SceneNode) => boolean): FigmaNode | undefined;
|
|
54
|
+
}
|
|
55
|
+
interface FigmaProps extends BaseFigmaProps {
|
|
56
|
+
[key: string]: any;
|
|
57
|
+
}
|
|
58
|
+
export interface FigmaMappingWithKeyMapper<T extends BaseFigmaProps> {
|
|
59
|
+
url?: string;
|
|
60
|
+
componentKey: string;
|
|
61
|
+
mapper?: (figma: T) => any;
|
|
62
|
+
}
|
|
63
|
+
export interface FigmaGenericMapper {
|
|
64
|
+
genericMapper: (figma: FigmaProps) => any;
|
|
65
|
+
}
|
|
66
|
+
export interface FigmaTokenMapper {
|
|
67
|
+
designTokenMapper: (token: string) => string | undefined | boolean;
|
|
68
|
+
}
|
|
69
|
+
export declare function figmaMapping<T extends BaseFigmaProps = FigmaProps>(_config: FigmaMappingWithKeyMapper<T> | FigmaGenericMapper | FigmaTokenMapper): void;
|
|
70
|
+
export {};
|