Skip to content

Commit

Permalink
resolving of ui bundle missed path by 1 level #120 (#124)
Browse files Browse the repository at this point in the history
---
Co-authored-by: akim-muto <akim_muto@MyComputer>
  • Loading branch information
akim-muto authored Jun 13, 2024
1 parent affaaa6 commit e5fddd1
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const node: MacroNode<number> = {
},
editorConfig: {
type: "custom",
editorComponentBundlePath: "../../../dist/Duplicate.js",
editorComponentBundlePath: "../../dist/Duplicate.js",
},
defaultData: 2,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const node: MacroNode<any> = {
},
editorConfig: {
type: "custom",
editorComponentBundlePath: "../../../dist/InlineValue.js",
editorComponentBundlePath: "../../dist/InlineValue.js",
},
defaultData: "",
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const node: MacroNode<number> = {
displayNameBuilder: (times) => `Duplicate x ${times}`,
editorConfig: {
type: "custom",
editorComponentBundlePath: "../../../dist/Duplicate.js",
editorComponentBundlePath: "../../dist/Duplicate.js",
},
defaultData: 2,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const node: MacroNode<any> = {
displayNameBuilder: () => `Emit Value`,
editorConfig: {
type: "custom",
editorComponentBundlePath: "../../../dist/InlineValue.js",
editorComponentBundlePath: "../../dist/InlineValue.js",
},
defaultData: "",
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
MacroNode,
MacroNodeDefinition,
} from "@flyde/core";
import { readFileSync } from "fs";
import { readFileSync, existsSync } from "fs";
import { join } from "path";

export function macroNodeToDefinition<T>(
Expand All @@ -21,10 +21,18 @@ export function macroNodeToDefinition<T>(
editorComponentBundleContent: "",
} as MacroEditorConfigCustomDefinition,
};
const editorComponentPath = join(
let editorComponentPath = join(
importPath,
macro.editorConfig.editorComponentBundlePath
"..",
macro.editorConfig.editorComponentBundlePath,
);
// fallback for backwards compatibility (see issue #120)
if (!existsSync(editorComponentPath)) {
editorComponentPath = join(
importPath,
macro.editorConfig.editorComponentBundlePath,
)
}

try {
const content = readFileSync(editorComponentPath, "utf8");
Expand Down
14 changes: 7 additions & 7 deletions stdlib/src/ControlFlow/Conditional.flyde.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ export interface ConditionalConfig {
propertyPath: string;
condition: { type: ConditionType; data?: string };
compareTo:
| { mode: "static"; value: any; type: "number" | "string" | "json" }
| { mode: "dynamic"; propertyPath: string };
| { mode: "static"; value: any; type: "number" | "string" | "json" }
| { mode: "dynamic"; propertyPath: string };
trueValue:
| { type: "value" | "compareTo" }
| { type: "expression"; data: string };
| { type: "value" | "compareTo" }
| { type: "expression"; data: string };
falseValue:
| { type: "value" | "compareTo" }
| { type: "expression"; data: string };
| { type: "value" | "compareTo" }
| { type: "expression"; data: string };
}

function conditionalConfigToDisplayName(config: ConditionalConfig) {
Expand Down Expand Up @@ -185,7 +185,7 @@ export const Conditional: MacroNode<ConditionalConfig> = {
},
editorConfig: {
type: "custom",
editorComponentBundlePath: "../../../dist/ui/Conditional.js",
editorComponentBundlePath: "../../dist/ui/Conditional.js",
},
};

Expand Down
16 changes: 8 additions & 8 deletions stdlib/src/ControlFlow/Switch.flyde.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ export interface SwitchConfig {
outputExpression: string;
}[];
defaultCase:
| {
enabled: true;
outputExpression: string;
}
| {
enabled: false;
};
| {
enabled: true;
outputExpression: string;
}
| {
enabled: false;
};
}

export const Switch: MacroNode<SwitchConfig> = {
Expand Down Expand Up @@ -108,6 +108,6 @@ export const Switch: MacroNode<SwitchConfig> = {
},
editorConfig: {
type: "custom",
editorComponentBundlePath: "../../../dist/ui/Switch.js",
editorComponentBundlePath: "../../dist/ui/Switch.js",
},
};
2 changes: 1 addition & 1 deletion stdlib/src/Lists/Collect/Collect.flyde.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,6 @@ export const Collect: MacroNode<CollectConfig> = {
},
editorConfig: {
type: "custom",
editorComponentBundlePath: "../../../../dist/ui/Collect.js",
editorComponentBundlePath: "../../../dist/ui/Collect.js",
},
};
2 changes: 1 addition & 1 deletion stdlib/src/Values/CodeExpression.flyde.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ export const CodeExpression: MacroNode<CodeExpressionConfig> = {
},
editorConfig: {
type: "custom",
editorComponentBundlePath: "../../../dist/ui/CodeExpression.js",
editorComponentBundlePath: "../../dist/ui/CodeExpression.js",
},
};
2 changes: 1 addition & 1 deletion stdlib/src/Values/InlineValue.flyde.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ export const InlineValue: MacroNode<InlineValueConfig> = {
},
editorConfig: {
type: "custom",
editorComponentBundlePath: "../../../dist/ui/InlineValue.js",
editorComponentBundlePath: "../../dist/ui/InlineValue.js",
},
};

0 comments on commit e5fddd1

Please sign in to comment.