Skip to content

Commit

Permalink
website fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
GabiGrin committed Jan 12, 2024
1 parent 5ef7c17 commit 06ea566
Show file tree
Hide file tree
Showing 27 changed files with 166 additions and 2,459 deletions.
74 changes: 73 additions & 1 deletion resolver/src/serdes/deserialize.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { FlydeFlow, flydeFlowSchema } from "@flyde/core";
import {
FlydeFlow,
NodeInstance,
flydeFlowSchema,
isRefNodeInstance,
} from "@flyde/core";
import * as yaml from "yaml";
import _ = require("lodash");
import { readFileSync } from "fs";
Expand All @@ -11,6 +16,56 @@ require("ts-node").register({
// }
});

const macroMigrationsMap = {
"GET Request": {
id: "Http",
data: {
method: { mode: "static", value: "GET" },
url: { mode: "dynamic" },
headers: { mode: "static", value: {} },
params: { mode: "static", value: {} },
},
},
"POST Request": {
id: "Http",
data: {
method: { mode: "static", value: "POST" },
data: { mode: "dynamic" },
url: { mode: "dynamic" },
headers: { mode: "static", value: {} },
params: { mode: "static", value: {} },
},
},
Debounce: {
id: "Debounce",
data: {
mode: "static",
timeMs: 1000,
},
},
Delay: {
id: "Delay",
data: {
type: "static",
timeMs: 1000,
},
},
Throttle: {
id: "Throttle",
data: {
type: "static",
timeMs: 1000,
},
},
Interval: {
id: "Interval",
data: {
type: "static",
timeMs: 1000,
},
},
};

export function deserializeFlow(flowContents: string, path: string): FlydeFlow {
const unsafeflow = yaml.parse(flowContents);

Expand All @@ -27,6 +82,23 @@ export function deserializeFlow(flowContents: string, path: string): FlydeFlow {

data.imports = imports;

// migrate old stdlib nodes
for (const ins of data.node?.instances) {
if (isRefNodeInstance(ins as NodeInstance) && !ins.macroId) {
const migration = macroMigrationsMap[ins.nodeId];
if (macroMigrationsMap[ins.nodeId]) {
ins.macroId = migration.id;
ins.macroData = migration.data;

const stdlibImports = (data.imports["@flyde/stdlib"] as string[]) ?? [];
if (!stdlibImports.includes(migration.id)) {
stdlibImports.push(migration.id);
data.imports["@flyde/stdlib"] = stdlibImports;
}
}
}
}

if (!data.node.inputsPosition) {
data.node.inputsPosition = {};
}
Expand Down
4 changes: 2 additions & 2 deletions stdlib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
"dev": "pnpm run watch",
"bundle": "webpack --config webpack.config.js",
"bundle:watch": "webpack --config webpack.config.js --watch",
"build": "tsc -p . && pnpm run bundle && pnpm run build:docs-data",
"build": "rm -rf dist && tsc -p . && pnpm run bundle && pnpm run build:docs-data",
"build:docs-data": "ts-node scripts/docs-data.ts",
"prod": "node dist/index.js",
"__publish": "npm version patch && npm publish"
}
}
}
4 changes: 3 additions & 1 deletion stdlib/src/ControlFlow/ControlFlow.flyde.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export const RoundRobin: MacroNode<number> = {
displayName: `Round Robin ${count}`,
description: `Item will be emitted to one of the ${count} outputs in a round robin fashion`,
inputs: { value: { mode: "required", description: "The value to emit" } },
completionOutputs: [],
reactiveInputs: ["value"],
outputs: Array.from({ length: count }).reduce<OutputPinMap>(
(obj, _, i) => ({
...obj,
Expand Down Expand Up @@ -81,8 +83,8 @@ export const RoundRobin: MacroNode<number> = {

const nextCurr = (curr + 1) % count;

o.next(inputs.item);
state.set("curr", nextCurr);
o.next(inputs.item);
};
},
editorComponentBundlePath: "../../../dist/ui/RoundRobin.js",
Expand Down
10 changes: 4 additions & 6 deletions stdlib/src/Http/Http.flyde.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ export interface HttpConfig {
}
| { mode: "dynamic" };
url: { mode: "static"; value: string } | { mode: "dynamic" };
headers?:
headers:
| { mode: "static"; value: Record<string, string> }
| { mode: "dynamic" };
params?:
| { mode: "static"; value: Record<string, string> }
| { mode: "dynamic" };
data?:
params:
| { mode: "static"; value: Record<string, string> }
| { mode: "dynamic" };
data: { mode: "static"; value: Record<string, string> } | { mode: "dynamic" };
}

export const Http: MacroNode<HttpConfig> = {
Expand All @@ -45,7 +43,7 @@ export const Http: MacroNode<HttpConfig> = {
};
return axios
.request({ url: urlValue, data: dataValue, ...requestConfig })
.then((res) => outputs.data.next(res.data))
.then((res) => outputs.data!.next(res.data))
.catch((e) => adv.onError(e));
};
},
Expand Down
4 changes: 2 additions & 2 deletions stdlib/src/Http/HttpConfigEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const HttpConfigEditor: MacroEditorComp<HttpConfig> = function HttpConfigEditor(
<option value="dynamic">Dynamic (via input)</option>
</HTMLSelect>
</FormGroup>
{value.data.mode === "static" && (
{value.data?.mode === "static" && (
<SimpleJsonEditor
label="Data:"
value={value.data.value}
Expand Down Expand Up @@ -77,7 +77,7 @@ const HttpConfigEditor: MacroEditorComp<HttpConfig> = function HttpConfigEditor(
{value.headers.mode === "static" && (
<SimpleJsonEditor
label="Headers:"
value={value.headers.value}
value={value.headers?.value}
onChange={(data) =>
onChange({ ...value, headers: { mode: "static", value: data } })
}
Expand Down
3 changes: 1 addition & 2 deletions stdlib/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"noFallthroughCasesInSwitch": true
"outDir": "dist"
},
"include": ["src/**/*.ts", "src/**/*.tsx"],
"exclude": ["node_modules", "dist"]
Expand Down
55 changes: 29 additions & 26 deletions website/src/pages/_hero-example/ExampleDebounceThrottle.flyde

Large diffs are not rendered by default.

39 changes: 32 additions & 7 deletions website/src/pages/_hero-example/ExampleHTTPRequests.flyde
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
imports:
"@flyde/stdlib":
- GET Request
- POST Request
- Get Attribute
- Http
node:
instances:
- pos:
Expand All @@ -19,7 +18,20 @@ node:
visibleOutputs:
- data
- __error
nodeId: GET Request
nodeId: Http__GET Request-907
macroId: Http
macroData:
method:
mode: static
value: GET
url:
mode: dynamic
headers:
mode: static
value: {}
params:
mode: static
value: {}
style:
size: regular
icon: fa-server
Expand Down Expand Up @@ -67,12 +79,25 @@ node:
mode: static
value: https://countriesnow.space/api/v0.1/countries/capital
visibleInputs:
- url
- headers
- params
- data
- url
- __trigger
nodeId: POST Request
nodeId: Http__POST Request-624
macroId: Http
macroData:
method:
mode: static
value: POST
data:
mode: dynamic
url:
mode: dynamic
headers:
mode: static
value: {}
params:
mode: static
value: {}
style:
size: regular
icon: fa-server
Expand Down
18 changes: 11 additions & 7 deletions website/src/pages/_hero-example/ExampleHelloWorld.flyde
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ imports:
node:
instances:
- pos:
x: -745.6308628148531
y: -164.62084499951794
x: -743.4960971898531
y: -180.6268874799867
id: hvnxp46iusf1g91k6dua576w
inputConfig:
delay:
mode: static
value: 4200
nodeId: Delay
nodeId: Delay__hvnxp46iusf1g91k6dua576w
macroId: Delay
macroData:
type: static
timeMs: 1000
style:
size: small
icon: fa-clock
Expand Down Expand Up @@ -50,8 +54,8 @@ node:
fontFamily: monospace
fontWeight: "500"
- pos:
x: -769.3590283203125
y: -276.35265625
x: -781.0328564453125
y: -277.4243420410156
id: ApisCombination-4z1481x
inputConfig: {}
node:
Expand Down Expand Up @@ -136,7 +140,7 @@ node:
Bob:
x: -464.39225613814307
y: -267.86263932413937
"גכעכגע":
"גכעכגע":
x: -879.2823974609375
y: -510.9079638671875
outputsPosition:
Expand All @@ -158,6 +162,6 @@ node:
Bob 42:
x: -736.217912287027
y: 209.40813992513762
"גככג":
"גככג":
x: -589.98
y: -561
13 changes: 9 additions & 4 deletions website/src/pages/_hero-example/ExampleReactivity.flyde
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ imports:
node:
instances:
- pos:
x: -628.0026402763253
y: -420.65284818026043
x: -670.4256749442941
y: -418.16716092440106
id: ghunnjxvc8lzz9ir1n7a5cv9
inputConfig:
interval:
Expand All @@ -18,8 +18,13 @@ node:
mode: static
value: ""
visibleInputs:
- interval
nodeId: Interval
- value
- __trigger
nodeId: Interval__ghunnjxvc8lzz9ir1n7a5cv9
macroId: Interval
macroData:
type: static
timeMs: 1000
- pos:
x: -621.8109288505441
y: -147.24308865877606
Expand Down
17 changes: 0 additions & 17 deletions website/src/pages/playground/_OutputLogs/OutputJsx.tsx

This file was deleted.

Loading

0 comments on commit 06ea566

Please sign in to comment.