Skip to content

Commit

Permalink
feat: package noflo stdlib and show componentList
Browse files Browse the repository at this point in the history
  • Loading branch information
linonetwo committed Jul 17, 2023
1 parent a547597 commit aa9edcb
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 5 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
"beautiful-react-hooks": "4.3.0",
"chai": "4.3.7",
"circular-dependency-plugin": "5.2.2",
"coffee-loader": "^4.0.0",
"copy-webpack-plugin": "11.0.0",
"cross-env": "7.0.3",
"csp-html-webpack-plugin": "5.1.0",
Expand All @@ -156,13 +157,17 @@
"eslint-config-tidgi": "1.1.2",
"event-hooks-webpack-plugin": "2.3.0",
"fbp-graph": "^0.7.0",
"fbp-loader": "^0.1.2",
"fbp-manifest": "^0.3.1",
"font-awesome": "^4.7.0",
"fork-ts-checker-webpack-plugin": "8.0.0",
"glob": "^10.3.2",
"graphql-hooks": "6.2.3",
"json5": "^2.2.3",
"node-loader": "2.0.0",
"node-polyfill-webpack-plugin": "^2.0.1",
"noflo": "^1.4.3",
"noflo-component-loader": "^0.4.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-helmet": "6.1.0",
Expand Down
60 changes: 56 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file removed scripts/tryfbp.mjs
Empty file.
13 changes: 13 additions & 0 deletions src/pages/Workflow/GraphEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { sidebarWidth } from '@/constants/style';
import type { Graph } from 'fbp-graph';
import { ComponentLoader } from 'noflo';
import components from 'noflo/lib/loader/register';
import styled from 'styled-components';
import TheGraph from 'the-graph';
import type { IFBPLibrary, ITheGraphProps } from 'the-graph';
Expand Down Expand Up @@ -123,6 +125,17 @@ export function GraphEditor(props: Partial<ITheGraphProps> & IGraphEditorProps)
buildInitialLibrary(graph);
}, [buildInitialLibrary]);

useEffect(() => {
void (async function IIFE() {
const loader = new ComponentLoader('');
const componentList = await loader.listComponents();
// DEBUG: console componentList
// DEBUG: console components
console.log(`components`, components.getSource(loader, 'BaseName', console.log));
console.log(`componentList`, componentList);
})();
}, []);

// Attach nav
function fitGraphInView() {
// editor.triggerFit();
Expand Down
2 changes: 2 additions & 0 deletions webpack.plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ exports.main = _.compact([
exports.renderer = _.compact([
new webpack.DefinePlugin({
'process.env.NODE_ENV': `"${process.env.NODE_ENV ?? 'production'}"`,
// some noflo modules use process.env.NODE_DEBUG
'process.env.NODE_DEBUG': 'false',
// global: {},
}),
// new CspHtmlWebpackPlugin(
Expand Down
2 changes: 1 addition & 1 deletion webpack.renderer.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = {
resolve: {
alias: webpackAlias,
extensions: ['.js', '.ts', '.jsx', '.tsx', '.css'],
fallback: { crypto: false, fs: false },
fallback: { crypto: false, fs: false, process: false },
},
output: {
chunkFilename: 'main_window/[name].chunk.js',
Expand Down
36 changes: 36 additions & 0 deletions webpack.rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,40 @@ module.exports = [
filename: 'images/[name].[ext]',
},
},
{
test: /noflo(\\+|\/)lib(\\+|\/)loader(\\+|\/)register.js$/,
use: [
{
loader: 'noflo-component-loader',
options: {
// Only include components used by this graph
// Set to NULL if you want all installed components
graph: null,
// Whether to include the original component sources
// in the build
debug: true,
baseDir: __dirname,
manifest: {
runtimes: ['noflo'],
discover: true,
recursive: true,
},
runtimes: [
'noflo',
'noflo-browser',
],
},
},
],
},
{
test: /\.coffee$/,
// load noflo-interaction standard lib, which provide some component in this format
use: ['coffee-loader'],
},
{
test: /\.fbp$/,
// load noflo-strings standard lib, which provide some component in this format
use: ['fbp-loader'],
},
];

0 comments on commit aa9edcb

Please sign in to comment.