Skip to content

Initial Widget declaration docgen support (for React, React native, SolidJS) #168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 70 commits into from
Jul 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
62ea077
init with simple blueprints
softmarshmallow Jul 12, 2022
d86629e
add fresh packages
softmarshmallow Jul 14, 2022
23c16aa
update doc package with readme
softmarshmallow Jul 14, 2022
d46708e
add dts support package (empty)
softmarshmallow Jul 14, 2022
5d591fd
refactor
softmarshmallow Jul 14, 2022
e016962
add single file multi widget composition doc
softmarshmallow Jul 18, 2022
d2eeb23
init default props pkg
softmarshmallow Jul 18, 2022
de8a5af
add child props deligation doc
softmarshmallow Jul 18, 2022
99f51a6
cleanup
softmarshmallow Jul 18, 2022
363487b
update declare docs
softmarshmallow Jul 18, 2022
f60c54e
rename default props to builtin props
softmarshmallow Jul 18, 2022
3042d51
add module tokens
softmarshmallow Jul 18, 2022
08d1fd6
update nextjs config with new pkg
softmarshmallow Jul 18, 2022
27d6c14
add module readme gen
softmarshmallow Jul 18, 2022
9c11890
update module support pkg exports
softmarshmallow Jul 18, 2022
ae8eedc
add declare token handling
softmarshmallow Jul 18, 2022
e280d14
update types
softmarshmallow Jul 18, 2022
c1f1e7e
add module tokens to main special token exports
softmarshmallow Jul 18, 2022
2b826b4
update react styled components module builder class name
softmarshmallow Jul 18, 2022
133f3ec
bump subpackages
softmarshmallow Jul 18, 2022
0ba46c3
update class names
softmarshmallow Jul 19, 2022
6246c6c
update pkgs
softmarshmallow Jul 19, 2022
1c1b319
update doc
softmarshmallow Jul 19, 2022
eac7af6
sync
softmarshmallow Jul 19, 2022
6d9436a
reserve
softmarshmallow Jul 19, 2022
46c9e38
reserve
softmarshmallow Jul 19, 2022
ec27b02
reserve
softmarshmallow Jul 19, 2022
1fb9471
add jsx widget tsdoc
softmarshmallow Jul 19, 2022
ed0a396
rename
softmarshmallow Jul 19, 2022
249d181
update widget docs example
softmarshmallow Jul 20, 2022
b4db2e0
add doc meta module
softmarshmallow Jul 20, 2022
d310e43
widget declaration doc builder wip
softmarshmallow Jul 20, 2022
e88e2d3
fix build
softmarshmallow Jul 20, 2022
645384b
Merge branch 'support-module' of https://github.com/gridaco/designto-…
softmarshmallow Jul 20, 2022
918e41a
update coli with comments support
softmarshmallow Jul 21, 2022
49beadc
bump coli with comemnts support
softmarshmallow Jul 21, 2022
74ac267
b config
softmarshmallow Jul 21, 2022
3832c29
bump coli with jsx text nesting
softmarshmallow Jul 21, 2022
4927653
fix meta manager formatting
softmarshmallow Jul 21, 2022
0ce5dab
add widget declaration info type for doc
softmarshmallow Jul 21, 2022
9223234
initial experimental tsdoc support on react styled components widget
softmarshmallow Jul 21, 2022
6664410
add platforms field to meta
softmarshmallow Jul 21, 2022
2162eb9
Merge branch 'staging' of https://github.com/gridaco/designto-code in…
softmarshmallow Jul 21, 2022
5ec4de5
rm log
softmarshmallow Jul 23, 2022
09fd4d3
add dirty package
softmarshmallow Jul 23, 2022
e146bf0
add debugger package
softmarshmallow Jul 23, 2022
e5ac8f3
replace console logs to debugger logs
softmarshmallow Jul 23, 2022
696c87a
add mute, unmute command with postmessage interface to debugger
softmarshmallow Jul 23, 2022
68b4abc
bump packages
softmarshmallow Jul 23, 2022
8ff6a45
format
softmarshmallow Jul 23, 2022
c7fe952
add docs gen with widget meta
softmarshmallow Jul 23, 2022
2d8f60d
add resolutions & fix `@reflect-ui/core`version to 0.0.3
softmarshmallow Jul 23, 2022
6993f00
bump coli with fixed astformatter
softmarshmallow Jul 23, 2022
8da1f10
link version info to doc
softmarshmallow Jul 23, 2022
0de24fd
update prettier config on monaco to use double quote
softmarshmallow Jul 23, 2022
73e93b1
update function formatting
softmarshmallow Jul 23, 2022
986035f
remove explicit filekey extension type for editor - now natively supp…
softmarshmallow Jul 23, 2022
abbef6b
update figma converters to seed filekey (mandatory)
softmarshmallow Jul 23, 2022
3d69aa8
update default indentations
softmarshmallow Jul 23, 2022
2a7ef65
mimic fixes
softmarshmallow Jul 23, 2022
44e2ff0
add FigmaWidgetKey support with filekey info
softmarshmallow Jul 23, 2022
2d85f5d
bump reflect core with update widget key - copyWith, rename
softmarshmallow Jul 23, 2022
02bcd54
remove web widget key, use core widget key. update usage (might have …
softmarshmallow Jul 23, 2022
304b77b
add design origin link building feature to widget declaration docgen
softmarshmallow Jul 23, 2022
8441f1f
fix serializer
softmarshmallow Jul 24, 2022
48a2c80
add preview image & name info to docgen
softmarshmallow Jul 24, 2022
16c6ff3
rm test
softmarshmallow Jul 24, 2022
967ef8c
add example output
softmarshmallow Jul 24, 2022
4133140
add docgen support for react native, solidjs (with some abstraction)
softmarshmallow Jul 25, 2022
dd5a037
bump reflect core with new widget key interface
softmarshmallow Jul 25, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion editor-packages/base-sdk
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ export function CanvasEventTarget({
set_drag_start_emitted(false);
onDragEnd(s);
},
// @ts-ignore
onMouseDown: onPointerDown,
onMoveStart: onPointerMoveStart,
onMoveEnd: onPointerMoveEnd,
Expand Down Expand Up @@ -209,6 +210,7 @@ export function CanvasEventTarget({
WebkitUserSelect: "none",
}}
id="gesture-event-listener"
// @ts-ignore
ref={interactionEventTargetRef}
>
{children}
Expand Down
5 changes: 2 additions & 3 deletions editor-packages/editor-canvas/canvas/canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ interface CanvasState {
type CanvasCustomRenderers = HudCustomRenderers & {
renderItem: (
p: {
node: ReflectSceneNode & { filekey: string };
node: ReflectSceneNode;
} & FrameOptimizationFactors
) => React.ReactNode;
};
Expand Down Expand Up @@ -309,14 +309,13 @@ export function Canvas({

const items = useMemo(() => {
return nodes?.map((node) => {
node["filekey"] = filekey;
return (
<LazyFrame key={node.id} xy={[node.x, node.y]} size={node}>
{/* 👇 dev only (for performance tracking) 👇 */}
{/* <div style={{ width: "100%", height: "100%", background: "grey" }} /> */}
{/* 👆 ----------------------------------- 👆 */}
{renderItem({
node: node as ReflectSceneNode & { filekey: string },
node: node as ReflectSceneNode,
zoom, // ? use scaled_zoom ?
inViewport: true, // TODO:
isZooming: isZooming,
Expand Down
1 change: 1 addition & 0 deletions editor-packages/editor-preview-pip/lib/pip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ function PIP({
backgroundColor?: string;
}) {
return (
// @ts-ignore
<Draggable handle=".handle" bounds="parent">
<PipWindow
className="handle"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ const options = {
printWidth: 100,
semi: true,
useTabs: false,
singleQuote: true,
singleQuote: false,
}),
typescript: async () => ({
parser: "babel",
plugins: [await import("prettier/parser-babel")],
printWidth: 100,
semi: true,
useTabs: false,
singleQuote: true,
singleQuote: false,
}),
};

Expand Down
5 changes: 3 additions & 2 deletions editor/hooks/use-design.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ export function useDesign({
}

if (targetnodeconfig) {
const filekey = targetnodeconfig.file;
// load design from local storage or remote figma

const cacheStore = new RemoteDesignSessionCacheStore({
file: targetnodeconfig.file,
node: targetnodeconfig.node,
Expand All @@ -116,7 +116,8 @@ export function useDesign({
const _2_converted_to_reflect = convert.intoReflectNode(
_1_converted_to_figma,
null,
"rest"
"rest",
filekey
);

const res = <TargetNodeConfig>{
Expand Down
5 changes: 5 additions & 0 deletions editor/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const TerserPlugin = require("terser-webpack-plugin");
const withTM = require("next-transpile-modules")([
"dirty",

// region @editor-app
"@editor-app/live-session",
"@code-editor/preview-pip", // TODO: remove me. this is for development. for production, use npm ver instead.
Expand All @@ -12,6 +14,7 @@ const withTM = require("next-transpile-modules")([

// -----------------------------
// region @designto-code
"@designto/debugger",
"@designto/config",
"@grida/builder-config-preset",
"@grida/builder-platform-types",
Expand All @@ -26,6 +29,8 @@ const withTM = require("next-transpile-modules")([
"@designto/react-native",

"@code-features/assets",
"@code-features/module",
"@code-features/documentation",
"@code-features/component",
"@code-features/flags",
// -----------------------------
Expand Down
4 changes: 2 additions & 2 deletions editor/pages/files/[key]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { EditorSnapshot, StateProvider } from "core/states";
import { WorkspaceAction } from "core/actions";
import { useDesignFile, TUseDesignFile } from "hooks";
import { warmup } from "scaffolds/editor";
import { FileResponse } from "@design-sdk/figma-remote-types";
import { EditorBrowserMetaHead } from "components/editor";
import type { FileResponse } from "@design-sdk/figma-remote-types";

export default function FileEntryEditor() {
const router = useRouter();
Expand Down Expand Up @@ -78,7 +78,7 @@ function SetupEditor({
// ->> file.styles;

const components = warmup.componentsFrom(file);
const pages = warmup.pagesFrom(file);
const pages = warmup.pagesFrom(filekey, file);

if (prevstate) {
val = {
Expand Down
7 changes: 5 additions & 2 deletions editor/scaffolds/editor/warmup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,16 @@ export function initialReducer(
}
}

export function pagesFrom(file: FileResponse): FigmaReflectRepository["pages"] {
export function pagesFrom(
filekey: string,
file: FileResponse
): FigmaReflectRepository["pages"] {
return file.document.children.map((page) => ({
id: page.id,
name: page.name,
children: page["children"]?.map((child) => {
const _mapped = mapper.mapFigmaRemoteToFigma(child);
return convert.intoReflectNode(_mapped, null, "rest");
return convert.intoReflectNode(_mapped, null, "rest", filekey);
}),
type: "design",
}));
Expand Down
9 changes: 5 additions & 4 deletions editor/scaffolds/preview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ const blurred_bg_fill = (target: ReflectSceneNode) => {
};

type VanillaPreviewProps = {
target: ReflectSceneNode & {
filekey: string;
};
target: ReflectSceneNode;
} & FrameOptimizationFactors;

export function D2CVanillaPreview({
Expand All @@ -80,7 +78,10 @@ export function D2CVanillaPreview({
}
}
setPreview(result);
cache.set(target.filekey, { ...result, __image });

if (typeof target.filekey == "string") {
cache.set(target.filekey, { ...result, __image });
}
};

const hide_preview = isZooming || isPanning;
Expand Down
2 changes: 1 addition & 1 deletion externals/coli
Submodule coli updated 81 files
+71 −0 packages/coli-builder-tsdoc/README.md
+6 −0 packages/coli-builder-tsdoc/package.json
+21 −16 packages/coli-builder/jsx/index.ts
+21 −14 packages/coli-core/_abstract/index.ts
+0 −1 packages/coli-core/_internal/node-name/expressions-name.ts
+24 −0 packages/coli-core/comments/_base.ts
+3 −0 packages/coli-core/comments/index.ts
+14 −0 packages/coli-core/comments/multiline-commnet-trivia.ts
+14 −0 packages/coli-core/comments/singleline-comment-trivia.ts
+12 −0 packages/coli-core/declarations/declaration.base.ts
+0 −15 packages/coli-core/expressions/comment.ts
+0 −1 packages/coli-core/expressions/index.ts
+4 −0 packages/coli-core/index.ts
+0 −13 packages/coli-export-string/__test__/comment-expression.stringfy.test.ts
+23 −0 packages/coli-export-string/__test__/comment-trivia.stringfy.test.ts
+3 −6 packages/coli-export-string/__test__/function-declaration.stringfy.test.ts
+41 −2 packages/coli-export-string/__test__/jsx-element.stringfy.test.ts
+71 −0 packages/coli-export-string/__test__/jsx-function.test.ts
+81 −0 packages/coli-export-string/__test__/options-indentation.test.ts
+3 −17 packages/coli-export-string/core/block-statement.ts
+2 −2 packages/coli-export-string/core/boolean-keyword.ts
+3 −3 packages/coli-export-string/core/call-expression.ts
+7 −31 packages/coli-export-string/core/comment-expression.ts
+3 −11 packages/coli-export-string/core/export-assignment.ts
+3 −3 packages/coli-export-string/core/expression-statement.ts
+3 −18 packages/coli-export-string/core/function-declaration.ts
+3 −3 packages/coli-export-string/core/identifier-ast.ts
+3 −3 packages/coli-export-string/core/import-declaration.ts
+3 −3 packages/coli-export-string/core/import-default-specifier.ts
+3 −3 packages/coli-export-string/core/import-specifier.ts
+3 −3 packages/coli-export-string/core/interface-declaration.ts
+3 −8 packages/coli-export-string/core/jsx/jsx-atrribute.ts
+5 −7 packages/coli-export-string/core/jsx/jsx-closing-element.ts
+7 −25 packages/coli-export-string/core/jsx/jsx-element.ts
+3 −3 packages/coli-export-string/core/jsx/jsx-expression.ts
+3 −3 packages/coli-export-string/core/jsx/jsx-opening-element.ts
+3 −3 packages/coli-export-string/core/jsx/jsx-self-closing-element.ts
+2 −2 packages/coli-export-string/core/jsx/jsx-text.ts
+3 −3 packages/coli-export-string/core/literal-ast.ts
+3 −3 packages/coli-export-string/core/literal-type.ts
+2 −2 packages/coli-export-string/core/number-keyword.ts
+3 −3 packages/coli-export-string/core/object-literal-expression.ts
+3 −3 packages/coli-export-string/core/property-access-expression.ts
+3 −4 packages/coli-export-string/core/property-assignment.ts
+3 −4 packages/coli-export-string/core/property-signature.ts
+3 −4 packages/coli-export-string/core/return-statement.ts
+2 −2 packages/coli-export-string/core/string-keyword.ts
+3 −3 packages/coli-export-string/core/tagged-template-expression.ts
+3 −3 packages/coli-export-string/core/type-reference.ts
+3 −3 packages/coli-export-string/core/union-type.ts
+3 −4 packages/coli-export-string/core/variable-declaration.ts
+5 −1 packages/coli-export-string/index.ts
+82 −34 packages/coli-export-string/stringfy.ts
+10 −4 packages/coli-formatter-token/format.ts
+4 −5 packages/coli-formatter-token/formatters/block-statement.ts
+0 −33 packages/coli-formatter-token/formatters/comment-expression.ts
+57 −0 packages/coli-formatter-token/formatters/comment-trivia.ts
+8 −8 packages/coli-formatter-token/formatters/function-declaration.ts
+1 −1 packages/coli-formatter-token/formatters/index.ts
+1 −1 packages/coli-formatter-token/formatters/interface-declaration.ts
+1 −0 packages/coli-formatter-token/formatters/jsx/jsx-closing-element.ts
+12 −5 packages/coli-formatter-token/formatters/jsx/jsx-element.ts
+2 −1 packages/coli-formatter-token/formatters/jsx/jsx-text.ts
+1 −1 packages/coli-formatter-token/formatters/object-literal-expression.ts
+5 −6 packages/coli-formatter-token/formatters/return-statement.ts
+1 −0 packages/coli-formatter-token/tokens/index.ts
+10 −0 packages/coli-formatter-token/utils/indents.ts
+2 −0 packages/coli-formatter-token/utils/index.ts
+61 −0 packages/coli-formatter-token/utils/on-each-line.ts
+86 −0 packages/coli-naming/namer/namer.ts
+9 −68 packages/coli-naming/namer/scoped-namer.ts
+1 −1 packages/coli-naming/reserved/index.ts
+21 −0 packages/coli-plugin-postprocessing/LICENSE
+83 −0 packages/coli-plugin-postprocessing/README.md
+22 −0 packages/coli-plugin-postprocessing/__test__/replacer.test.ts
+3 −0 packages/coli-plugin-postprocessing/index.ts
+4 −0 packages/coli-plugin-postprocessing/jest.config.js
+43 −0 packages/coli-plugin-postprocessing/package.json
+85 −0 packages/coli-plugin-postprocessing/postprocessing.ts
+13 −0 packages/coli-plugin-postprocessing/tsconfig.json
+1,086 −3 yarn.lock
2 changes: 1 addition & 1 deletion externals/design-sdk
2 changes: 1 addition & 1 deletion externals/reflect-core
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,9 @@
"externals/reflect-core/packages/*",
"externals/design-sdk/*",
"externals/coli/packages/*"
]
],
"resolutions": {
"@reflect-ui/core": "0.0.3",
"csstype": "3.1.0"
}
}
5 changes: 4 additions & 1 deletion packages/builder-config/input/design-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ export class DesignInput implements IDesignInput {
nodes: this._flat_all(design),
});

return new DesignInput({ entry: design, repository: repository });
return new DesignInput({
entry: design,
repository: repository,
});
}

static fromDesignWithComponents({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ProjectPart } from "../output-part-project";
import type { File } from "../output-file";
import type { Module } from "../output-module";
import type { ModuleFile } from "../output-module";
import * as k from "../../k";

export function make_project_part_output({
Expand All @@ -16,7 +16,7 @@ export function make_project_part_output({
version?: string;
main: string;
files: File[];
modules: Module[];
modules: ModuleFile[];
os?: string[];
engines?: {
[key: string]: string;
Expand Down
16 changes: 14 additions & 2 deletions packages/builder-config/output/output-module/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
export interface Module extends File {
type SupportedLanguagesExt =
| "ts"
| "tsx"
| "js"
| "jsx"
| "vue"
| "dart"
| "svelte";

/**
* a
*/
export interface ModuleFile extends File {
_type: "module";
language: "ts" | "tsx" | "js" | "jsx" | "vue" | "dart" | "svelte";
language: SupportedLanguagesExt;

/**
* list of exporting member identifiers
Expand Down
6 changes: 4 additions & 2 deletions packages/builder-config/output/output-part-project/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { File } from "../output-file";
import type { Module } from "../output-module";
import type { ModuleFile } from "../output-module";

/**
* PartProject interface.
Expand Down Expand Up @@ -36,7 +36,7 @@ export interface ProjectPart {

license?: string;

modules: Module[];
modules: ModuleFile[];

files: File[];

Expand All @@ -61,6 +61,8 @@ export interface ProjectPart {

/**
* the main entry point of the project (just like in package.json for example)
*
* to locate the main file
*/
main: string;
}
46 changes: 24 additions & 22 deletions packages/builder-css-styles/font-weight/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@ export type CSSFontWeight =
type CSSNumericFontWeight =
| "normal"
| "bold"
| "100"
| "200"
| "300"
| "400"
| "500"
| "600"
| "700"
| "800"
| "900";
| 100
| 200
| 300
| 400
| 500
| 600
| 700
| 800
| 900;

export function convertToCssFontWeight(fontWeight: FontWeight): CSSFontWeight {
export function convertToCssFontWeight(
fontWeight: FontWeight
): CSSFontWeight | undefined {
if (fontWeight === undefined) {
return "initial";
}
Expand Down Expand Up @@ -60,34 +62,34 @@ export function convertToCssFontWeight(fontWeight: FontWeight): CSSFontWeight {

export function numericFontWeight(
fontWeight: FontWeight
): CSSNumericFontWeight {
): CSSNumericFontWeight | undefined {
switch (fontWeight) {
case FontWeight.normal:
return "normal";
case FontWeight.bold:
return "bold";
case FontWeight.lighter:
return "300";
return 300;
case FontWeight.bolder:
return "900";
return 900;
case FontWeight.w100:
return "100";
return 100;
case FontWeight.w200:
return "200";
return 200;
case FontWeight.w300:
return "300";
return 300;
case FontWeight.w400:
return "400";
return 400;
case FontWeight.w500:
return "500";
return 500;
case FontWeight.w600:
return "600";
return 600;
case FontWeight.w700:
return "700";
return 700;
case FontWeight.w800:
return "800";
return 800;
case FontWeight.w900:
return "900";
return 900;
default:
return undefined;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/builder-css-styles/length/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { calc, operation } from "../calc";
import { px, vw, vh } from "../dimensions";
import { percent } from "../percent";

export function length(d: DimensionLength | string, a?: Axis) {
export function length(d: DimensionLength | string | undefined, a?: Axis) {
if (d === undefined || d === null) {
return;
}
Expand Down Expand Up @@ -50,7 +50,7 @@ export function length(d: DimensionLength | string, a?: Axis) {
}

if (d.type == "calc") {
return calc(d.operations, a);
return calc(d.operations, a!);
}

if (d.type == "op") {
Expand Down
Loading