@keload/node-red-dxp 1.2.0
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 +52 -0
- package/dist/builder/index.cjs +46 -0
- package/dist/builder/index.d.cts +109 -0
- package/dist/builder/index.d.ts +109 -0
- package/dist/builder/index.js +46 -0
- package/dist/cli/index.cjs +47 -0
- package/dist/editor/assets/styles.scss +182 -0
- package/dist/editor/index.cjs +1 -0
- package/dist/editor/index.d.cts +23 -0
- package/dist/editor/index.d.ts +23 -0
- package/dist/editor/index.js +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +1 -0
- package/package.json +81 -0
package/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<br/>
|
|
2
|
+
<div align="center">
|
|
3
|
+
<a href="https://github.com/clement-berard/node-red-dxp">
|
|
4
|
+
<img src="https://nodered.org/about/resources/media/node-red-icon-2.svg" alt="Logo" width="80" height="80">
|
|
5
|
+
</a>
|
|
6
|
+
<h3 align="center">Node-Red</h3>
|
|
7
|
+
<p align="center">
|
|
8
|
+
Developer eXPerience
|
|
9
|
+
<br/>
|
|
10
|
+
<br/>
|
|
11
|
+
<a href="https://github.com/clement-berard/node-red-dxp"><strong>Explore the docs »</strong></a>
|
|
12
|
+
<br/>
|
|
13
|
+
<br/>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
Welcome to **node-red-dxp**, a comprehensive library designed to simplify and accelerate the development of custom nodes for Node-RED. 🚀
|
|
17
|
+
|
|
18
|
+
With **node-red-dxp**, you get everything you need to build, style, and document your nodes—all in one package! Here's what makes it special:
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## ✨ Features
|
|
23
|
+
|
|
24
|
+
- **⚙️ Powerful Builder**:
|
|
25
|
+
- Leverages **esbuild** for lightning-fast JavaScript builds (controller & editor).
|
|
26
|
+
- Supports SCSS styles for polished, modern editor UIs.
|
|
27
|
+
- Automatically converts Markdown documentation into Node-RED compatible HTML.
|
|
28
|
+
|
|
29
|
+
- **🎨 Effortless Styling**:
|
|
30
|
+
- Includes clean, minimal CSS styles tailored for Node-RED.
|
|
31
|
+
- Fully customizable SCSS for editor components.
|
|
32
|
+
|
|
33
|
+
- **🛠️ Development Helpers**:
|
|
34
|
+
- Utility functions to streamline building custom node editors.
|
|
35
|
+
- Hassle-free configuration for common Node-RED workflows.
|
|
36
|
+
|
|
37
|
+
- **⚡ Ultra-Fast Commands**:
|
|
38
|
+
- `build`: Quickly generate production-ready assets.
|
|
39
|
+
- `watch`: Monitor changes with blazing-fast incremental builds.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## 🚀 Why Choose node-red-dxp?
|
|
44
|
+
|
|
45
|
+
- **Blazing Speed**: Thanks to **esbuild**, both builds and watches are ultra-fast, letting you focus on development, not waiting.
|
|
46
|
+
- **All-in-One Toolkit**: No need to juggle multiple tools—**node-red-dxp** handles everything from JavaScript bundling to CSS and Markdown processing.
|
|
47
|
+
- **Developer-Centric**: Designed with developer experience (DX) at its core, making custom node creation as seamless as possible.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
## License
|
|
51
|
+
|
|
52
|
+
MIT
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';var x=require('fs'),ne=require('path'),ue=require('del'),V=require('esbuild'),cosmiconfig=require('cosmiconfig'),glob=require('glob'),radash=require('radash'),htmlMinifierTerser=require('html-minifier-terser'),A=require('sass');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var x__namespace=/*#__PURE__*/_interopNamespace(x);var ne__default=/*#__PURE__*/_interopDefault(ne);var ue__default=/*#__PURE__*/_interopDefault(ue);var V__default=/*#__PURE__*/_interopDefault(V);var A__namespace=/*#__PURE__*/_interopNamespace(A);var m=(e,t,r)=>new Promise((o,s)=>{var d=i=>{try{l(r.next(i));}catch(c){s(c);}},h=i=>{try{l(r.throw(i));}catch(c){s(c);}},l=i=>i.done?o(i.value):Promise.resolve(i.value).then(d,h);l((r=r.apply(e,t)).next());});function y(e){return Object.prototype.toString.call(e).slice(8,-1)}function u(e){if(y(e)!=="Object")return !1;let t=Object.getPrototypeOf(e);return !!t&&t.constructor===Object&&t===Object.prototype}function b(e){return y(e)==="Symbol"}function I(e,t,r,o){let s={}.propertyIsEnumerable.call(o,t)?"enumerable":"nonenumerable";s==="enumerable"&&(e[t]=r),s==="nonenumerable"&&Object.defineProperty(e,t,{value:r,enumerable:!1,writable:!0,configurable:!0});}function O(e,t,r){if(!u(t))return t;let o={};if(u(e)){let l=Object.getOwnPropertyNames(e),i=Object.getOwnPropertySymbols(e);o=[...l,...i].reduce((c,a)=>{let S=e[a];return (!b(a)&&!Object.getOwnPropertyNames(t).includes(a)||b(a)&&!Object.getOwnPropertySymbols(t).includes(a))&&I(c,a,S,e),c},{});}let s=Object.getOwnPropertyNames(t),d=Object.getOwnPropertySymbols(t);return [...s,...d].reduce((l,i)=>{let c=t[i],a=u(e)?e[i]:void 0;a!==void 0&&u(c)&&(c=O(a,c));let S=c;return I(l,i,S,t),l},o)}function w(e,...t){return t.reduce((r,o)=>O(r,o),e)}var C={libCacheDir:".node-red-dx",srcDir:"src",nodesDirName:"nodes",nodes:{controllerName:"index",editor:{dirName:"editor",htmlName:"index",tsName:"index"}},builder:{outputDir:"dist"},watcher:{nodeRed:{enabled:!0,path:"~/.node-red",url:"http://localhost:1880"}}};var z="node-red-dx",K=e=>e.replace("@","").replace("/","-");function Q(){let e=cosmiconfig.cosmiconfigSync(z);try{let t=e.search();return w(C,t?t.config:{})}catch(t){throw console.error("Error while loading configuration",t),t}}var p=Q(),f=process.cwd(),v=JSON.parse(x.readFileSync(`${f}/package.json`,"utf-8")),F=`${f}/${p.srcDir}`,X=`${f}/resources`,$=`${F}/${p.nodesDirName}`,D=`${f}/${p.libCacheDir}`;function Y(){return glob.globSync(`${$}/*`,{withFileTypes:!0}).map(t=>{let r=t.fullpath(),o=`${r}/${p.nodes.editor.dirName}`,s=r.replace(f,"").slice(1),d=`${s}/${p.nodes.editor.dirName}`,h=glob.globSync(`${o}/**/*.scss`),l=glob.globSync(`${r}/doc.mdx`),i=glob.globSync(`${r}/doc.md`),c=radash.dash(t.name);return {fullEditorPath:o,fullPath:r,name:t.name,pascalName:radash.pascal(t.name),dashName:c,relativeEditorPath:d,relativePath:s,nodeIdentifier:`${n.packageNameSlug}-${c}`,fullControllerPath:`${r}/${p.nodes.controllerName}.ts`,editor:{tsPath:`${o}/${p.nodes.editor.tsName}.ts`,htmlPath:`${o}/${p.nodes.editor.htmlName}.html`,scssFiles:h},doc:{mdxFiles:l,mdFiles:i}}})}function Z(){return {currentDir:f,pathSrcDir:F,pathSrcNodesDir:$,additionalResourcesDir:X,pathDist:`${f}/${p.builder.outputDir}`,cacheDirFiles:{controllerIndex:`${D}/controller-index.ts`,editorIndex:`${D}/editor-index.ts`},pathLibCacheDir:D,packageName:v.name,packageNameSlug:K(v.name),config:p,getResolvedSrcPathsScss:()=>glob.globSync(`${F}/**/*.scss`,{ignore:`${$}/**/*.scss`}),getResolvedNodesPaths:()=>glob.globSync(`${$}/*`),getListNodesFull:()=>Y()}}var n=Z();function re(e){return m(this,null,function*(){let t=x.readFileSync(e,"utf8");return htmlMinifierTerser.minify(t,{collapseWhitespace:!0,removeComments:!0,removeRedundantAttributes:!1,useShortDoctype:!0,removeEmptyAttributes:!1,minifyCSS:!1,minifyJS:!1})})}function oe(e,t,r,o){return `
|
|
2
|
+
<script type="text/html" data-template-name="${e}">
|
|
3
|
+
<div class="${r}">
|
|
4
|
+
<div class="${t}">${o}</div>
|
|
5
|
+
</div>
|
|
6
|
+
</script>
|
|
7
|
+
`}function E(){return m(this,null,function*(){let e=n.getListNodesFull(),t=[];for(let r of e){let o=yield re(r.editor.htmlPath);t.push(oe(r.name,r.nodeIdentifier,n.packageNameSlug,o));}return t.join("").trim()})}function ie(e){return A__namespace.compile(e,{style:"compressed"}).css}function P(e){let t={};for(let r=0;r<e.length;r++){let o=e[r];t[o]=ie(o);}return t}function ce(){let e=n.getListNodesFull();return e.some(r=>r.editor.scssFiles.length)?e.map(r=>{let o=P(r.editor.scssFiles),s=Object.values(o).join("");return {name:r.name,styles:P(r.editor.scssFiles),mergedCompiledStyles:s,scssFinal:`#${r.nodeIdentifier}{${s}}`,hasStyles:!!r.editor.scssFiles.length}}).filter(r=>r.hasStyles):[]}function le(){let e=n.getResolvedSrcPathsScss(),t=glob.globSync(`${ne__default.default.resolve(__dirname,"..")}/editor/**/*.scss`),r=P([...e,...t]);return Object.values(r).join("")}function R(){let e=le(),t=ce();return !e&&!t.length?"":`.${n.packageNameSlug}{${e}${t.map(r=>r.scssFinal).join("")}}`}function L(e){return e.trim().replace(/\n\s+/g,"")}function ae(e=!0){return m(this,null,function*(){let t=yield E(),r=yield H(e),o=R(),s=M();return `${e?L(t):t}
|
|
8
|
+
<style>${o}</style>
|
|
9
|
+
<script type="application/javascript">
|
|
10
|
+
${r.trim()}
|
|
11
|
+
</script>
|
|
12
|
+
${s}`})}function k(e=!1){return m(this,null,function*(){let t=yield ae(e);x__namespace.writeFileSync(`${n.pathDist}/index.html`,t);})}var N=n.getListNodesFull(),W=`
|
|
13
|
+
// generated by @keload/node-red-dev-xp
|
|
14
|
+
// do not modify this file
|
|
15
|
+
// do not commit this file
|
|
16
|
+
`;function me(){return `
|
|
17
|
+
${W}
|
|
18
|
+
import type { NodeAPI } from 'node-red';
|
|
19
|
+
${N.map(e=>`import ${e.pascalName} from '${e.fullControllerPath}';`).join(`
|
|
20
|
+
`)}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
export default async (RED: NodeAPI): Promise<void> => {
|
|
24
|
+
global.RED = RED;
|
|
25
|
+
|
|
26
|
+
${N.map(e=>`// @ts-ignore
|
|
27
|
+
global.RED.nodes.registerType('${e.name}', ${e.pascalName});`).join(`
|
|
28
|
+
`)}
|
|
29
|
+
};
|
|
30
|
+
`.trim()}function pe(){return `
|
|
31
|
+
${W}
|
|
32
|
+
import type { NodeAPI } from 'node-red';
|
|
33
|
+
${N.map(e=>`import ${e.pascalName} from '${e.editor.tsPath}';`).join(`
|
|
34
|
+
`)}
|
|
35
|
+
|
|
36
|
+
declare const RED: NodeAPI;
|
|
37
|
+
|
|
38
|
+
${N.map(e=>`// @ts-ignore
|
|
39
|
+
window.RED.nodes.registerType('${e.name}', ${e.pascalName});`).join(`
|
|
40
|
+
`)}
|
|
41
|
+
`.trim()}function _(){x__namespace.writeFileSync(`${n.cacheDirFiles.controllerIndex}`,me());}function J(){x__namespace.writeFileSync(`${n.cacheDirFiles.editorIndex}`,pe());}function M(){let e=n.getListNodesFull(),t=[];for(let r of e)if(r.doc.mdFiles[0]){let s=x__namespace.default.readFileSync(r.doc.mdFiles[0],"utf-8"),d=`
|
|
42
|
+
<script type="text/markdown" data-help-name="${r.name}">
|
|
43
|
+
${s}
|
|
44
|
+
</script>
|
|
45
|
+
`;t.push(d);}return t.length?t.join(`
|
|
46
|
+
`):""}function ge(e=!1){return m(this,null,function*(){return V__default.default.build({entryPoints:[n.cacheDirFiles.controllerIndex],outfile:`${n.pathDist}/index.js`,bundle:!0,minify:e,minifyWhitespace:e,minifyIdentifiers:e,minifySyntax:e,platform:"node",format:"cjs",target:"es2018",loader:{".ts":"ts"},packages:"external"})})}function H(e=!1){return m(this,null,function*(){let t=yield V__default.default.build({entryPoints:[n.cacheDirFiles.editorIndex],bundle:!0,platform:"browser",format:"iife",target:"es6",sourcemap:!1,minify:e,minifyWhitespace:e,minifySyntax:e,minifyIdentifiers:e,legalComments:"none",write:!1,loader:{".ts":"ts"}});return t.outputFiles&&t.outputFiles.length>0?t.outputFiles[0].text:""})}function xe(){ue__default.default.sync([n.pathDist]);}function he(){x__namespace.writeFileSync(`${n.pathLibCacheDir}/config.json`,JSON.stringify(n.config,null,2),"utf-8");}function ye(e){let t=ne__default.default.resolve(e);x__namespace.existsSync(t)||x__namespace.mkdirSync(t,{recursive:!0});}function pt(e=!1){return m(this,null,function*(){ye(n.pathLibCacheDir),xe(),he(),_(),J(),yield ge(e),yield k(e);})}exports.buildAllPackage=pt;exports.buildFinalDistIndexContent=ae;exports.buildNodeController=ge;exports.buildNodeEditor=H;exports.cleanDist=xe;exports.currentInstance=n;exports.getAllCompiledStyles=R;exports.getControllerIndex=me;exports.getEditorIndex=pe;exports.getNodeHtml=re;exports.getNodesHtml=E;exports.getNodesStyles=ce;exports.getSrcStyles=le;exports.handleAllDoc=M;exports.writeCacheConfigFile=he;exports.writeControllerIndex=_;exports.writeEditorIndex=J;exports.writeFinalDistIndexContent=k;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import esbuild from 'esbuild';
|
|
2
|
+
|
|
3
|
+
type Config = {
|
|
4
|
+
libCacheDir: string;
|
|
5
|
+
srcDir: string;
|
|
6
|
+
nodesDirName: string;
|
|
7
|
+
nodes: {
|
|
8
|
+
controllerName: string;
|
|
9
|
+
editor: {
|
|
10
|
+
dirName: string;
|
|
11
|
+
htmlName: string;
|
|
12
|
+
tsName: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
builder: {
|
|
16
|
+
outputDir: string;
|
|
17
|
+
};
|
|
18
|
+
watcher: {
|
|
19
|
+
nodeRed: {
|
|
20
|
+
enabled: boolean;
|
|
21
|
+
path: string | undefined;
|
|
22
|
+
url: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
declare const currentInstance: {
|
|
28
|
+
currentDir: string;
|
|
29
|
+
pathSrcDir: string;
|
|
30
|
+
pathSrcNodesDir: string;
|
|
31
|
+
additionalResourcesDir: string;
|
|
32
|
+
pathDist: string;
|
|
33
|
+
cacheDirFiles: {
|
|
34
|
+
controllerIndex: string;
|
|
35
|
+
editorIndex: string;
|
|
36
|
+
};
|
|
37
|
+
pathLibCacheDir: string;
|
|
38
|
+
packageName: any;
|
|
39
|
+
packageNameSlug: string;
|
|
40
|
+
config: Config;
|
|
41
|
+
getResolvedSrcPathsScss: () => string[];
|
|
42
|
+
getResolvedNodesPaths: () => string[];
|
|
43
|
+
getListNodesFull: () => {
|
|
44
|
+
fullEditorPath: string;
|
|
45
|
+
fullPath: string;
|
|
46
|
+
name: string;
|
|
47
|
+
pascalName: string;
|
|
48
|
+
dashName: string;
|
|
49
|
+
relativeEditorPath: string;
|
|
50
|
+
relativePath: string;
|
|
51
|
+
nodeIdentifier: string;
|
|
52
|
+
fullControllerPath: string;
|
|
53
|
+
editor: {
|
|
54
|
+
tsPath: string;
|
|
55
|
+
htmlPath: string;
|
|
56
|
+
scssFiles: string[];
|
|
57
|
+
};
|
|
58
|
+
doc: {
|
|
59
|
+
mdxFiles: string[];
|
|
60
|
+
mdFiles: string[];
|
|
61
|
+
};
|
|
62
|
+
}[];
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
declare function getControllerIndex(): string;
|
|
66
|
+
declare function getEditorIndex(): string;
|
|
67
|
+
declare function writeControllerIndex(): void;
|
|
68
|
+
declare function writeEditorIndex(): void;
|
|
69
|
+
|
|
70
|
+
declare function getNodesStyles(): {
|
|
71
|
+
name: string;
|
|
72
|
+
styles: Record<string, string>;
|
|
73
|
+
mergedCompiledStyles: string;
|
|
74
|
+
scssFinal: string;
|
|
75
|
+
hasStyles: boolean;
|
|
76
|
+
}[];
|
|
77
|
+
declare function getSrcStyles(): string;
|
|
78
|
+
declare function getAllCompiledStyles(): string;
|
|
79
|
+
|
|
80
|
+
declare function getNodeHtml(filePath: string): Promise<string>;
|
|
81
|
+
declare function getNodesHtml(): Promise<string>;
|
|
82
|
+
|
|
83
|
+
declare function buildFinalDistIndexContent(minify?: boolean): Promise<string>;
|
|
84
|
+
declare function writeFinalDistIndexContent(minify?: boolean): Promise<void>;
|
|
85
|
+
|
|
86
|
+
declare function handleAllDoc(): string;
|
|
87
|
+
|
|
88
|
+
declare function buildNodeController(minify?: boolean): Promise<esbuild.BuildResult<{
|
|
89
|
+
entryPoints: string[];
|
|
90
|
+
outfile: string;
|
|
91
|
+
bundle: true;
|
|
92
|
+
minify: boolean;
|
|
93
|
+
minifyWhitespace: boolean;
|
|
94
|
+
minifyIdentifiers: boolean;
|
|
95
|
+
minifySyntax: boolean;
|
|
96
|
+
platform: "node";
|
|
97
|
+
format: "cjs";
|
|
98
|
+
target: string;
|
|
99
|
+
loader: {
|
|
100
|
+
'.ts': "ts";
|
|
101
|
+
};
|
|
102
|
+
packages: "external";
|
|
103
|
+
}>>;
|
|
104
|
+
declare function buildNodeEditor(minify?: boolean): Promise<string>;
|
|
105
|
+
declare function cleanDist(): void;
|
|
106
|
+
declare function writeCacheConfigFile(): void;
|
|
107
|
+
declare function buildAllPackage(minify?: boolean): Promise<void>;
|
|
108
|
+
|
|
109
|
+
export { buildAllPackage, buildFinalDistIndexContent, buildNodeController, buildNodeEditor, cleanDist, currentInstance, getAllCompiledStyles, getControllerIndex, getEditorIndex, getNodeHtml, getNodesHtml, getNodesStyles, getSrcStyles, handleAllDoc, writeCacheConfigFile, writeControllerIndex, writeEditorIndex, writeFinalDistIndexContent };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import esbuild from 'esbuild';
|
|
2
|
+
|
|
3
|
+
type Config = {
|
|
4
|
+
libCacheDir: string;
|
|
5
|
+
srcDir: string;
|
|
6
|
+
nodesDirName: string;
|
|
7
|
+
nodes: {
|
|
8
|
+
controllerName: string;
|
|
9
|
+
editor: {
|
|
10
|
+
dirName: string;
|
|
11
|
+
htmlName: string;
|
|
12
|
+
tsName: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
builder: {
|
|
16
|
+
outputDir: string;
|
|
17
|
+
};
|
|
18
|
+
watcher: {
|
|
19
|
+
nodeRed: {
|
|
20
|
+
enabled: boolean;
|
|
21
|
+
path: string | undefined;
|
|
22
|
+
url: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
declare const currentInstance: {
|
|
28
|
+
currentDir: string;
|
|
29
|
+
pathSrcDir: string;
|
|
30
|
+
pathSrcNodesDir: string;
|
|
31
|
+
additionalResourcesDir: string;
|
|
32
|
+
pathDist: string;
|
|
33
|
+
cacheDirFiles: {
|
|
34
|
+
controllerIndex: string;
|
|
35
|
+
editorIndex: string;
|
|
36
|
+
};
|
|
37
|
+
pathLibCacheDir: string;
|
|
38
|
+
packageName: any;
|
|
39
|
+
packageNameSlug: string;
|
|
40
|
+
config: Config;
|
|
41
|
+
getResolvedSrcPathsScss: () => string[];
|
|
42
|
+
getResolvedNodesPaths: () => string[];
|
|
43
|
+
getListNodesFull: () => {
|
|
44
|
+
fullEditorPath: string;
|
|
45
|
+
fullPath: string;
|
|
46
|
+
name: string;
|
|
47
|
+
pascalName: string;
|
|
48
|
+
dashName: string;
|
|
49
|
+
relativeEditorPath: string;
|
|
50
|
+
relativePath: string;
|
|
51
|
+
nodeIdentifier: string;
|
|
52
|
+
fullControllerPath: string;
|
|
53
|
+
editor: {
|
|
54
|
+
tsPath: string;
|
|
55
|
+
htmlPath: string;
|
|
56
|
+
scssFiles: string[];
|
|
57
|
+
};
|
|
58
|
+
doc: {
|
|
59
|
+
mdxFiles: string[];
|
|
60
|
+
mdFiles: string[];
|
|
61
|
+
};
|
|
62
|
+
}[];
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
declare function getControllerIndex(): string;
|
|
66
|
+
declare function getEditorIndex(): string;
|
|
67
|
+
declare function writeControllerIndex(): void;
|
|
68
|
+
declare function writeEditorIndex(): void;
|
|
69
|
+
|
|
70
|
+
declare function getNodesStyles(): {
|
|
71
|
+
name: string;
|
|
72
|
+
styles: Record<string, string>;
|
|
73
|
+
mergedCompiledStyles: string;
|
|
74
|
+
scssFinal: string;
|
|
75
|
+
hasStyles: boolean;
|
|
76
|
+
}[];
|
|
77
|
+
declare function getSrcStyles(): string;
|
|
78
|
+
declare function getAllCompiledStyles(): string;
|
|
79
|
+
|
|
80
|
+
declare function getNodeHtml(filePath: string): Promise<string>;
|
|
81
|
+
declare function getNodesHtml(): Promise<string>;
|
|
82
|
+
|
|
83
|
+
declare function buildFinalDistIndexContent(minify?: boolean): Promise<string>;
|
|
84
|
+
declare function writeFinalDistIndexContent(minify?: boolean): Promise<void>;
|
|
85
|
+
|
|
86
|
+
declare function handleAllDoc(): string;
|
|
87
|
+
|
|
88
|
+
declare function buildNodeController(minify?: boolean): Promise<esbuild.BuildResult<{
|
|
89
|
+
entryPoints: string[];
|
|
90
|
+
outfile: string;
|
|
91
|
+
bundle: true;
|
|
92
|
+
minify: boolean;
|
|
93
|
+
minifyWhitespace: boolean;
|
|
94
|
+
minifyIdentifiers: boolean;
|
|
95
|
+
minifySyntax: boolean;
|
|
96
|
+
platform: "node";
|
|
97
|
+
format: "cjs";
|
|
98
|
+
target: string;
|
|
99
|
+
loader: {
|
|
100
|
+
'.ts': "ts";
|
|
101
|
+
};
|
|
102
|
+
packages: "external";
|
|
103
|
+
}>>;
|
|
104
|
+
declare function buildNodeEditor(minify?: boolean): Promise<string>;
|
|
105
|
+
declare function cleanDist(): void;
|
|
106
|
+
declare function writeCacheConfigFile(): void;
|
|
107
|
+
declare function buildAllPackage(minify?: boolean): Promise<void>;
|
|
108
|
+
|
|
109
|
+
export { buildAllPackage, buildFinalDistIndexContent, buildNodeController, buildNodeEditor, cleanDist, currentInstance, getAllCompiledStyles, getControllerIndex, getEditorIndex, getNodeHtml, getNodesHtml, getNodesStyles, getSrcStyles, handleAllDoc, writeCacheConfigFile, writeControllerIndex, writeEditorIndex, writeFinalDistIndexContent };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import*as x from'node:fs';import x__default,{readFileSync}from'node:fs';import ne from'node:path';import ue from'del';import V from'esbuild';import {cosmiconfigSync}from'cosmiconfig';import {globSync}from'glob';import {dash,pascal}from'radash';import {minify}from'html-minifier-terser';import*as A from'sass';var m=(e,t,r)=>new Promise((o,s)=>{var d=i=>{try{l(r.next(i));}catch(c){s(c);}},h=i=>{try{l(r.throw(i));}catch(c){s(c);}},l=i=>i.done?o(i.value):Promise.resolve(i.value).then(d,h);l((r=r.apply(e,t)).next());});function y(e){return Object.prototype.toString.call(e).slice(8,-1)}function u(e){if(y(e)!=="Object")return !1;let t=Object.getPrototypeOf(e);return !!t&&t.constructor===Object&&t===Object.prototype}function b(e){return y(e)==="Symbol"}function I(e,t,r,o){let s={}.propertyIsEnumerable.call(o,t)?"enumerable":"nonenumerable";s==="enumerable"&&(e[t]=r),s==="nonenumerable"&&Object.defineProperty(e,t,{value:r,enumerable:!1,writable:!0,configurable:!0});}function O(e,t,r){if(!u(t))return t;let o={};if(u(e)){let l=Object.getOwnPropertyNames(e),i=Object.getOwnPropertySymbols(e);o=[...l,...i].reduce((c,a)=>{let S=e[a];return (!b(a)&&!Object.getOwnPropertyNames(t).includes(a)||b(a)&&!Object.getOwnPropertySymbols(t).includes(a))&&I(c,a,S,e),c},{});}let s=Object.getOwnPropertyNames(t),d=Object.getOwnPropertySymbols(t);return [...s,...d].reduce((l,i)=>{let c=t[i],a=u(e)?e[i]:void 0;a!==void 0&&u(c)&&(c=O(a,c));let S=c;return I(l,i,S,t),l},o)}function w(e,...t){return t.reduce((r,o)=>O(r,o),e)}var C={libCacheDir:".node-red-dx",srcDir:"src",nodesDirName:"nodes",nodes:{controllerName:"index",editor:{dirName:"editor",htmlName:"index",tsName:"index"}},builder:{outputDir:"dist"},watcher:{nodeRed:{enabled:!0,path:"~/.node-red",url:"http://localhost:1880"}}};var z="node-red-dx",K=e=>e.replace("@","").replace("/","-");function Q(){let e=cosmiconfigSync(z);try{let t=e.search();return w(C,t?t.config:{})}catch(t){throw console.error("Error while loading configuration",t),t}}var p=Q(),f=process.cwd(),v=JSON.parse(readFileSync(`${f}/package.json`,"utf-8")),F=`${f}/${p.srcDir}`,X=`${f}/resources`,$=`${F}/${p.nodesDirName}`,D=`${f}/${p.libCacheDir}`;function Y(){return globSync(`${$}/*`,{withFileTypes:!0}).map(t=>{let r=t.fullpath(),o=`${r}/${p.nodes.editor.dirName}`,s=r.replace(f,"").slice(1),d=`${s}/${p.nodes.editor.dirName}`,h=globSync(`${o}/**/*.scss`),l=globSync(`${r}/doc.mdx`),i=globSync(`${r}/doc.md`),c=dash(t.name);return {fullEditorPath:o,fullPath:r,name:t.name,pascalName:pascal(t.name),dashName:c,relativeEditorPath:d,relativePath:s,nodeIdentifier:`${n.packageNameSlug}-${c}`,fullControllerPath:`${r}/${p.nodes.controllerName}.ts`,editor:{tsPath:`${o}/${p.nodes.editor.tsName}.ts`,htmlPath:`${o}/${p.nodes.editor.htmlName}.html`,scssFiles:h},doc:{mdxFiles:l,mdFiles:i}}})}function Z(){return {currentDir:f,pathSrcDir:F,pathSrcNodesDir:$,additionalResourcesDir:X,pathDist:`${f}/${p.builder.outputDir}`,cacheDirFiles:{controllerIndex:`${D}/controller-index.ts`,editorIndex:`${D}/editor-index.ts`},pathLibCacheDir:D,packageName:v.name,packageNameSlug:K(v.name),config:p,getResolvedSrcPathsScss:()=>globSync(`${F}/**/*.scss`,{ignore:`${$}/**/*.scss`}),getResolvedNodesPaths:()=>globSync(`${$}/*`),getListNodesFull:()=>Y()}}var n=Z();function re(e){return m(this,null,function*(){let t=readFileSync(e,"utf8");return minify(t,{collapseWhitespace:!0,removeComments:!0,removeRedundantAttributes:!1,useShortDoctype:!0,removeEmptyAttributes:!1,minifyCSS:!1,minifyJS:!1})})}function oe(e,t,r,o){return `
|
|
2
|
+
<script type="text/html" data-template-name="${e}">
|
|
3
|
+
<div class="${r}">
|
|
4
|
+
<div class="${t}">${o}</div>
|
|
5
|
+
</div>
|
|
6
|
+
</script>
|
|
7
|
+
`}function E(){return m(this,null,function*(){let e=n.getListNodesFull(),t=[];for(let r of e){let o=yield re(r.editor.htmlPath);t.push(oe(r.name,r.nodeIdentifier,n.packageNameSlug,o));}return t.join("").trim()})}function ie(e){return A.compile(e,{style:"compressed"}).css}function P(e){let t={};for(let r=0;r<e.length;r++){let o=e[r];t[o]=ie(o);}return t}function ce(){let e=n.getListNodesFull();return e.some(r=>r.editor.scssFiles.length)?e.map(r=>{let o=P(r.editor.scssFiles),s=Object.values(o).join("");return {name:r.name,styles:P(r.editor.scssFiles),mergedCompiledStyles:s,scssFinal:`#${r.nodeIdentifier}{${s}}`,hasStyles:!!r.editor.scssFiles.length}}).filter(r=>r.hasStyles):[]}function le(){let e=n.getResolvedSrcPathsScss(),t=globSync(`${ne.resolve(__dirname,"..")}/editor/**/*.scss`),r=P([...e,...t]);return Object.values(r).join("")}function R(){let e=le(),t=ce();return !e&&!t.length?"":`.${n.packageNameSlug}{${e}${t.map(r=>r.scssFinal).join("")}}`}function L(e){return e.trim().replace(/\n\s+/g,"")}function ae(e=!0){return m(this,null,function*(){let t=yield E(),r=yield H(e),o=R(),s=M();return `${e?L(t):t}
|
|
8
|
+
<style>${o}</style>
|
|
9
|
+
<script type="application/javascript">
|
|
10
|
+
${r.trim()}
|
|
11
|
+
</script>
|
|
12
|
+
${s}`})}function k(e=!1){return m(this,null,function*(){let t=yield ae(e);x.writeFileSync(`${n.pathDist}/index.html`,t);})}var N=n.getListNodesFull(),W=`
|
|
13
|
+
// generated by @keload/node-red-dev-xp
|
|
14
|
+
// do not modify this file
|
|
15
|
+
// do not commit this file
|
|
16
|
+
`;function me(){return `
|
|
17
|
+
${W}
|
|
18
|
+
import type { NodeAPI } from 'node-red';
|
|
19
|
+
${N.map(e=>`import ${e.pascalName} from '${e.fullControllerPath}';`).join(`
|
|
20
|
+
`)}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
export default async (RED: NodeAPI): Promise<void> => {
|
|
24
|
+
global.RED = RED;
|
|
25
|
+
|
|
26
|
+
${N.map(e=>`// @ts-ignore
|
|
27
|
+
global.RED.nodes.registerType('${e.name}', ${e.pascalName});`).join(`
|
|
28
|
+
`)}
|
|
29
|
+
};
|
|
30
|
+
`.trim()}function pe(){return `
|
|
31
|
+
${W}
|
|
32
|
+
import type { NodeAPI } from 'node-red';
|
|
33
|
+
${N.map(e=>`import ${e.pascalName} from '${e.editor.tsPath}';`).join(`
|
|
34
|
+
`)}
|
|
35
|
+
|
|
36
|
+
declare const RED: NodeAPI;
|
|
37
|
+
|
|
38
|
+
${N.map(e=>`// @ts-ignore
|
|
39
|
+
window.RED.nodes.registerType('${e.name}', ${e.pascalName});`).join(`
|
|
40
|
+
`)}
|
|
41
|
+
`.trim()}function _(){x.writeFileSync(`${n.cacheDirFiles.controllerIndex}`,me());}function J(){x.writeFileSync(`${n.cacheDirFiles.editorIndex}`,pe());}function M(){let e=n.getListNodesFull(),t=[];for(let r of e)if(r.doc.mdFiles[0]){let s=x__default.readFileSync(r.doc.mdFiles[0],"utf-8"),d=`
|
|
42
|
+
<script type="text/markdown" data-help-name="${r.name}">
|
|
43
|
+
${s}
|
|
44
|
+
</script>
|
|
45
|
+
`;t.push(d);}return t.length?t.join(`
|
|
46
|
+
`):""}function ge(e=!1){return m(this,null,function*(){return V.build({entryPoints:[n.cacheDirFiles.controllerIndex],outfile:`${n.pathDist}/index.js`,bundle:!0,minify:e,minifyWhitespace:e,minifyIdentifiers:e,minifySyntax:e,platform:"node",format:"cjs",target:"es2018",loader:{".ts":"ts"},packages:"external"})})}function H(e=!1){return m(this,null,function*(){let t=yield V.build({entryPoints:[n.cacheDirFiles.editorIndex],bundle:!0,platform:"browser",format:"iife",target:"es6",sourcemap:!1,minify:e,minifyWhitespace:e,minifySyntax:e,minifyIdentifiers:e,legalComments:"none",write:!1,loader:{".ts":"ts"}});return t.outputFiles&&t.outputFiles.length>0?t.outputFiles[0].text:""})}function xe(){ue.sync([n.pathDist]);}function he(){x.writeFileSync(`${n.pathLibCacheDir}/config.json`,JSON.stringify(n.config,null,2),"utf-8");}function ye(e){let t=ne.resolve(e);x.existsSync(t)||x.mkdirSync(t,{recursive:!0});}function pt(e=!1){return m(this,null,function*(){ye(n.pathLibCacheDir),xe(),he(),_(),J(),yield ge(e),yield k(e);})}export{pt as buildAllPackage,ae as buildFinalDistIndexContent,ge as buildNodeController,H as buildNodeEditor,xe as cleanDist,n as currentInstance,R as getAllCompiledStyles,me as getControllerIndex,pe as getEditorIndex,re as getNodeHtml,E as getNodesHtml,ce as getNodesStyles,le as getSrcStyles,M as handleAllDoc,he as writeCacheConfigFile,_ as writeControllerIndex,J as writeEditorIndex,k as writeFinalDistIndexContent};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';var oe=require('process'),commander=require('commander'),consola=require('consola'),g=require('fs'),be=require('path'),Fe=require('del'),K=require('esbuild'),cosmiconfig=require('cosmiconfig'),glob=require('glob'),radash=require('radash'),htmlMinifierTerser=require('html-minifier-terser'),W=require('sass'),Te=require('prettyjson'),Me=require('browser-sync'),qe=require('chokidar'),Y=require('nodemon');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var oe__namespace=/*#__PURE__*/_interopNamespace(oe);var g__namespace=/*#__PURE__*/_interopNamespace(g);var be__default=/*#__PURE__*/_interopDefault(be);var Fe__default=/*#__PURE__*/_interopDefault(Fe);var K__default=/*#__PURE__*/_interopDefault(K);var W__namespace=/*#__PURE__*/_interopNamespace(W);var Te__default=/*#__PURE__*/_interopDefault(Te);var Me__default=/*#__PURE__*/_interopDefault(Me);var qe__default=/*#__PURE__*/_interopDefault(qe);var Y__default=/*#__PURE__*/_interopDefault(Y);var v={version:"1.1.0"};function b(e){return Object.prototype.toString.call(e).slice(8,-1)}function f(e){if(b(e)!=="Object")return !1;let t=Object.getPrototypeOf(e);return !!t&&t.constructor===Object&&t===Object.prototype}function N(e){return b(e)==="Symbol"}function k(e,t,r,n){let s={}.propertyIsEnumerable.call(n,t)?"enumerable":"nonenumerable";s==="enumerable"&&(e[t]=r),s==="nonenumerable"&&Object.defineProperty(e,t,{value:r,enumerable:!1,writable:!0,configurable:!0});}function A(e,t,r){if(!f(t))return t;let n={};if(f(e)){let p=Object.getOwnPropertyNames(e),m=Object.getOwnPropertySymbols(e);n=[...p,...m].reduce((i,c)=>{let w=e[c];return (!N(c)&&!Object.getOwnPropertyNames(t).includes(c)||N(c)&&!Object.getOwnPropertySymbols(t).includes(c))&&k(i,c,w,e),i},{});}let s=Object.getOwnPropertyNames(t),x=Object.getOwnPropertySymbols(t);return [...s,...x].reduce((p,m)=>{let i=t[m],c=f(e)?e[m]:void 0;c!==void 0&&f(i)&&(i=A(c,i));let w=i;return k(p,m,w,t),p},n)}function E(e,...t){return t.reduce((r,n)=>A(r,n),e)}var R={libCacheDir:".node-red-dx",srcDir:"src",nodesDirName:"nodes",nodes:{controllerName:"index",editor:{dirName:"editor",htmlName:"index",tsName:"index"}},builder:{outputDir:"dist"},watcher:{nodeRed:{enabled:!0,path:"~/.node-red",url:"http://localhost:1880"}}};var me="node-red-dx",le=e=>e.replace("@","").replace("/","-");function de(){let e=cosmiconfig.cosmiconfigSync(me);try{let t=e.search();return E(R,t?t.config:{})}catch(t){throw console.error("Error while loading configuration",t),t}}var a=de(),l=process.cwd(),B=JSON.parse(g.readFileSync(`${l}/package.json`,"utf-8")),C=`${l}/${a.srcDir}`,pe=`${l}/resources`,S=`${C}/${a.nodesDirName}`,j=`${l}/${a.libCacheDir}`;function fe(){return glob.globSync(`${S}/*`,{withFileTypes:!0}).map(t=>{let r=t.fullpath(),n=`${r}/${a.nodes.editor.dirName}`,s=r.replace(l,"").slice(1),x=`${s}/${a.nodes.editor.dirName}`,O=glob.globSync(`${n}/**/*.scss`),p=glob.globSync(`${r}/doc.mdx`),m=glob.globSync(`${r}/doc.md`),i=radash.dash(t.name);return {fullEditorPath:n,fullPath:r,name:t.name,pascalName:radash.pascal(t.name),dashName:i,relativeEditorPath:x,relativePath:s,nodeIdentifier:`${o.packageNameSlug}-${i}`,fullControllerPath:`${r}/${a.nodes.controllerName}.ts`,editor:{tsPath:`${n}/${a.nodes.editor.tsName}.ts`,htmlPath:`${n}/${a.nodes.editor.htmlName}.html`,scssFiles:O},doc:{mdxFiles:p,mdFiles:m}}})}function ue(){return {currentDir:l,pathSrcDir:C,pathSrcNodesDir:S,additionalResourcesDir:pe,pathDist:`${l}/${a.builder.outputDir}`,cacheDirFiles:{controllerIndex:`${j}/controller-index.ts`,editorIndex:`${j}/editor-index.ts`},pathLibCacheDir:j,packageName:B.name,packageNameSlug:le(B.name),config:a,getResolvedSrcPathsScss:()=>glob.globSync(`${C}/**/*.scss`,{ignore:`${S}/**/*.scss`}),getResolvedNodesPaths:()=>glob.globSync(`${S}/*`),getListNodesFull:()=>fe()}}var o=ue();async function xe(e){let t=g.readFileSync(e,"utf8");return htmlMinifierTerser.minify(t,{collapseWhitespace:!0,removeComments:!0,removeRedundantAttributes:!1,useShortDoctype:!0,removeEmptyAttributes:!1,minifyCSS:!1,minifyJS:!1})}function ye(e,t,r,n){return `
|
|
3
|
+
<script type="text/html" data-template-name="${e}">
|
|
4
|
+
<div class="${r}">
|
|
5
|
+
<div class="${t}">${n}</div>
|
|
6
|
+
</div>
|
|
7
|
+
</script>
|
|
8
|
+
`}async function T(){let e=o.getListNodesFull(),t=[];for(let r of e){let n=await xe(r.editor.htmlPath);t.push(ye(r.name,r.nodeIdentifier,o.packageNameSlug,n));}return t.join("").trim()}function Se(e){return W__namespace.compile(e,{style:"compressed"}).css}function I(e){let t={};for(let r=0;r<e.length;r++){let n=e[r];t[n]=Se(n);}return t}function $e(){let e=o.getListNodesFull();return e.some(r=>r.editor.scssFiles.length)?e.map(r=>{let n=I(r.editor.scssFiles),s=Object.values(n).join("");return {name:r.name,styles:I(r.editor.scssFiles),mergedCompiledStyles:s,scssFinal:`#${r.nodeIdentifier}{${s}}`,hasStyles:!!r.editor.scssFiles.length}}).filter(r=>r.hasStyles):[]}function we(){let e=o.getResolvedSrcPathsScss(),t=glob.globSync(`${be__default.default.resolve(__dirname,"..")}/editor/**/*.scss`),r=I([...e,...t]);return Object.values(r).join("")}function L(){let e=we(),t=$e();return !e&&!t.length?"":`.${o.packageNameSlug}{${e}${t.map(r=>r.scssFinal).join("")}}`}function M(e){return e.trim().replace(/\n\s+/g,"")}async function je(e=!0){let t=await T(),r=await V(e),n=L(),s=J();return `${e?M(t):t}
|
|
9
|
+
<style>${n}</style>
|
|
10
|
+
<script type="application/javascript">
|
|
11
|
+
${r.trim()}
|
|
12
|
+
</script>
|
|
13
|
+
${s}`}async function H(e=!1){let t=await je(e);g__namespace.writeFileSync(`${o.pathDist}/index.html`,t);}var $=o.getListNodesFull(),_=`
|
|
14
|
+
// generated by @keload/node-red-dev-xp
|
|
15
|
+
// do not modify this file
|
|
16
|
+
// do not commit this file
|
|
17
|
+
`;function Ce(){return `
|
|
18
|
+
${_}
|
|
19
|
+
import type { NodeAPI } from 'node-red';
|
|
20
|
+
${$.map(e=>`import ${e.pascalName} from '${e.fullControllerPath}';`).join(`
|
|
21
|
+
`)}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
export default async (RED: NodeAPI): Promise<void> => {
|
|
25
|
+
global.RED = RED;
|
|
26
|
+
|
|
27
|
+
${$.map(e=>`// @ts-ignore
|
|
28
|
+
global.RED.nodes.registerType('${e.name}', ${e.pascalName});`).join(`
|
|
29
|
+
`)}
|
|
30
|
+
};
|
|
31
|
+
`.trim()}function Ie(){return `
|
|
32
|
+
${_}
|
|
33
|
+
import type { NodeAPI } from 'node-red';
|
|
34
|
+
${$.map(e=>`import ${e.pascalName} from '${e.editor.tsPath}';`).join(`
|
|
35
|
+
`)}
|
|
36
|
+
|
|
37
|
+
declare const RED: NodeAPI;
|
|
38
|
+
|
|
39
|
+
${$.map(e=>`// @ts-ignore
|
|
40
|
+
window.RED.nodes.registerType('${e.name}', ${e.pascalName});`).join(`
|
|
41
|
+
`)}
|
|
42
|
+
`.trim()}function G(){g__namespace.writeFileSync(`${o.cacheDirFiles.controllerIndex}`,Ce());}function U(){g__namespace.writeFileSync(`${o.cacheDirFiles.editorIndex}`,Ie());}function J(){let e=o.getListNodesFull(),t=[];for(let r of e)if(r.doc.mdFiles[0]){let s=g__namespace.default.readFileSync(r.doc.mdFiles[0],"utf-8"),x=`
|
|
43
|
+
<script type="text/markdown" data-help-name="${r.name}">
|
|
44
|
+
${s}
|
|
45
|
+
</script>
|
|
46
|
+
`;t.push(x);}return t.length?t.join(`
|
|
47
|
+
`):""}async function Oe(e=!1){return K__default.default.build({entryPoints:[o.cacheDirFiles.controllerIndex],outfile:`${o.pathDist}/index.js`,bundle:!0,minify:e,minifyWhitespace:e,minifyIdentifiers:e,minifySyntax:e,platform:"node",format:"cjs",target:"es2018",loader:{".ts":"ts"},packages:"external"})}async function V(e=!1){let t=await K__default.default.build({entryPoints:[o.cacheDirFiles.editorIndex],bundle:!0,platform:"browser",format:"iife",target:"es6",sourcemap:!1,minify:e,minifyWhitespace:e,minifySyntax:e,minifyIdentifiers:e,legalComments:"none",write:!1,loader:{".ts":"ts"}});return t.outputFiles&&t.outputFiles.length>0?t.outputFiles[0].text:""}function ve(){Fe__default.default.sync([o.pathDist]);}function ke(){g__namespace.writeFileSync(`${o.pathLibCacheDir}/config.json`,JSON.stringify(o.config,null,2),"utf-8");}function Ae(e){let t=be__default.default.resolve(e);g__namespace.existsSync(t)||g__namespace.mkdirSync(t,{recursive:!0});}async function y(e=!1){Ae(o.pathLibCacheDir),ve(),ke(),G(),U(),await Oe(e),await H(e);}function z(e){let t=new commander.Command("checks").description("[WIP] Commands to check the some stuff");t.command("nodes-structure").description("[WIP] Verify the structure of the nodes").action(()=>{console.log("In construction");}),e.addCommand(t);}function Q(e){let t=new commander.Command("info").description("Command to get information").description("Get information about the package").action(()=>{consola.consola.log(Te__default.default.render(o));});e.addCommand(t);}function X(e){let t=new commander.Command("create-node").description("[WIP] Create a new node").action(async()=>{consola.consola.warn("Command in construction - not working yet");let r=await consola.consola.prompt("Enter node name:",{type:"text"}),n=radash.dash(r),s=await consola.consola.prompt(`This name is OK for you '${n}'?`,{type:"confirm"});console.log("userIsOk",s);});e.addCommand(t);}var ee,F;function He(){ee=Y__default.default({exec:`node-red -u ${o.config.watcher.nodeRed.path}`,ignore:["**/*"],ext:"js,html",verbose:!0}),Y__default.default.once("start",()=>{F=Me__default.default.create(),F.init({ui:!1,proxy:{target:o.config.watcher.nodeRed.url,ws:!0},ghostMode:!1,open:!1,reloadDelay:4e3});}).on("quit",()=>{consola.consola.info("Nodemon has quit"),process.exit(0);});}function Je(){ee.restart(),F.reload();}var Z=o.config.watcher.nodeRed.enabled&&o.config.watcher.nodeRed.path;function te(){qe__default.default.watch(o.pathSrcDir,{}).on("ready",async()=>{consola.consola.info("Initial scan complete. Ready for changes"),await y(!1),consola.consola.success("Initial Build completed"),Z?He():consola.consola.warn("Node-Red watcher is disabled. Please enable it in the config file");}).on("change",async t=>{consola.consola.info(`File ${t.replace(o.currentDir,"")} has been changed`),await y(!1),consola.consola.success("Build completed"),Z&&Je();});}var d=new commander.Command;d.name("node-red-dxp").description("node-red-dxp CLI").version(v.version);d.command("build").description("Build project").action(async e=>{consola.consola.start("Building..."),await y(!0),consola.consola.ready("Build completed");});d.command("watch").description("watch project").option("--minify <minify>","[WIP] Minify the output",!1).action(e=>{te();});z(d);Q(d);X(d);d.parse(oe__namespace.argv);
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
@use "sass:color";
|
|
2
|
+
@use "sass:list";
|
|
3
|
+
|
|
4
|
+
$spacing-scale: (
|
|
5
|
+
0: 0,
|
|
6
|
+
1: 0.25rem,
|
|
7
|
+
2: 0.5rem,
|
|
8
|
+
3: 1rem,
|
|
9
|
+
4: 1.5rem,
|
|
10
|
+
5: 2rem
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
@mixin generate-spacing-classes($property, $prefix) {
|
|
14
|
+
@each $key, $value in $spacing-scale {
|
|
15
|
+
.#{$prefix}#{$key} {
|
|
16
|
+
#{$property}: #{$value};
|
|
17
|
+
}
|
|
18
|
+
.#{$prefix}t-#{$key} {
|
|
19
|
+
#{$property}-top: #{$value};
|
|
20
|
+
}
|
|
21
|
+
.#{$prefix}r-#{$key} {
|
|
22
|
+
#{$property}-right: #{$value};
|
|
23
|
+
}
|
|
24
|
+
.#{$prefix}b-#{$key} {
|
|
25
|
+
#{$property}-bottom: #{$value};
|
|
26
|
+
}
|
|
27
|
+
.#{$prefix}l-#{$key} {
|
|
28
|
+
#{$property}-left: #{$value};
|
|
29
|
+
}
|
|
30
|
+
.#{$prefix}x-#{$key} {
|
|
31
|
+
#{$property}-left: #{$value};
|
|
32
|
+
#{$property}-right: #{$value};
|
|
33
|
+
}
|
|
34
|
+
.#{$prefix}y-#{$key} {
|
|
35
|
+
#{$property}-top: #{$value};
|
|
36
|
+
#{$property}-bottom: #{$value};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@include generate-spacing-classes(margin, m);
|
|
42
|
+
@include generate-spacing-classes(padding, p);
|
|
43
|
+
|
|
44
|
+
$text-size-scale: (
|
|
45
|
+
"xs": 0.75rem,
|
|
46
|
+
"sm": 0.875rem,
|
|
47
|
+
"base": 1rem,
|
|
48
|
+
"lg": 1.25rem,
|
|
49
|
+
"xl": 1.5rem,
|
|
50
|
+
"2xl": 2rem
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
$text-weight-scale: (
|
|
54
|
+
"thin": 100,
|
|
55
|
+
"light": 300,
|
|
56
|
+
"normal": 400,
|
|
57
|
+
"medium": 500,
|
|
58
|
+
"bold": 700,
|
|
59
|
+
"black": 900
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
$text-color-scale: (
|
|
63
|
+
"primary": #1a202c,
|
|
64
|
+
"secondary": #4a5568,
|
|
65
|
+
"accent": #f56565,
|
|
66
|
+
"success": #48bb78,
|
|
67
|
+
"warning": #ecc94b,
|
|
68
|
+
"danger": #e53e3e,
|
|
69
|
+
"info": #4299e1
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
@mixin generate-text-classes() {
|
|
73
|
+
@each $key, $value in $text-size-scale {
|
|
74
|
+
.text-#{$key} {
|
|
75
|
+
font-size: #{$value};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@each $key, $value in $text-weight-scale {
|
|
80
|
+
.font-#{$key} {
|
|
81
|
+
font-weight: #{$value};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.text-left {
|
|
86
|
+
text-align: left;
|
|
87
|
+
}
|
|
88
|
+
.text-center {
|
|
89
|
+
text-align: center;
|
|
90
|
+
}
|
|
91
|
+
.text-right {
|
|
92
|
+
text-align: right;
|
|
93
|
+
}
|
|
94
|
+
.text-justify {
|
|
95
|
+
text-align: justify;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.text-uppercase {
|
|
99
|
+
text-transform: uppercase;
|
|
100
|
+
}
|
|
101
|
+
.text-lowercase {
|
|
102
|
+
text-transform: lowercase;
|
|
103
|
+
}
|
|
104
|
+
.text-capitalize {
|
|
105
|
+
text-transform: capitalize;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@each $key, $value in $text-color-scale {
|
|
109
|
+
.text-#{$key} {
|
|
110
|
+
color: #{$value};
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
@include generate-text-classes();
|
|
116
|
+
|
|
117
|
+
// Couleurs des alertes
|
|
118
|
+
$alert-color-scale: (
|
|
119
|
+
"success": (#48bb78, "✔️"),
|
|
120
|
+
"warning": (#ecc94b, "⚠️"),
|
|
121
|
+
"danger": (#e53e3e, "❌"),
|
|
122
|
+
"info": (#4299e1, "ℹ️")
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
// Styles généraux pour les alertes
|
|
126
|
+
.alert {
|
|
127
|
+
display: flex;
|
|
128
|
+
align-items: center;
|
|
129
|
+
padding: 1rem;
|
|
130
|
+
margin: 1rem 0;
|
|
131
|
+
border-radius: 0.1rem;
|
|
132
|
+
|
|
133
|
+
&::before {
|
|
134
|
+
content: '';
|
|
135
|
+
display: inline-block;
|
|
136
|
+
margin-right: 0.75rem;
|
|
137
|
+
font-size: 1.25rem;
|
|
138
|
+
line-height: 1;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Génération des classes pour les alertes
|
|
143
|
+
@each $key, $value in $alert-color-scale {
|
|
144
|
+
$color: list.nth($value, 1);
|
|
145
|
+
$emoji: list.nth($value, 2);
|
|
146
|
+
|
|
147
|
+
.alert-#{$key} {
|
|
148
|
+
background-color: color.adjust($color, $lightness: 40%);
|
|
149
|
+
color: $color;
|
|
150
|
+
border: 1px solid color.adjust($color, $lightness: 20%);
|
|
151
|
+
|
|
152
|
+
&::before {
|
|
153
|
+
content: "#{$emoji}";
|
|
154
|
+
color: $color;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
$percentage-scale: (
|
|
160
|
+
10: 10%,
|
|
161
|
+
20: 20%,
|
|
162
|
+
30: 30%,
|
|
163
|
+
40: 40%,
|
|
164
|
+
50: 50%,
|
|
165
|
+
60: 60%,
|
|
166
|
+
70: 70%,
|
|
167
|
+
80: 80%,
|
|
168
|
+
90: 90%,
|
|
169
|
+
100: 100%
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
@mixin generate-dimension-classes($property, $prefix) {
|
|
173
|
+
@each $key, $value in $percentage-scale {
|
|
174
|
+
.#{$prefix}-#{$key}p {
|
|
175
|
+
#{$property}: #{$value};
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
@include generate-dimension-classes(width, w);
|
|
181
|
+
@include generate-dimension-classes(height, h);
|
|
182
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';function m(t){return Object.prototype.toString.call(t).slice(8,-1)}function f(t){if(m(t)!=="Object")return !1;let o=Object.getPrototypeOf(t);return !!o&&o.constructor===Object&&o===Object.prototype}function a(t){return m(t)==="Symbol"}function O(t,o,s,i){let u={}.propertyIsEnumerable.call(i,o)?"enumerable":"nonenumerable";u==="enumerable"&&(t[o]=s),u==="nonenumerable"&&Object.defineProperty(t,o,{value:s,enumerable:!1,writable:!0,configurable:!0});}function P(t,o,s){if(!f(o))return o;let i={};if(f(t)){let c=Object.getOwnPropertyNames(t),e=Object.getOwnPropertySymbols(t);i=[...c,...e].reduce((n,r)=>{let p=t[r];return (!a(r)&&!Object.getOwnPropertyNames(o).includes(r)||a(r)&&!Object.getOwnPropertySymbols(o).includes(r))&&O(n,r,p,t),n},{});}let u=Object.getOwnPropertyNames(o),d=Object.getOwnPropertySymbols(o);return [...u,...d].reduce((c,e)=>{let n=o[e],r=f(t)?t[e]:void 0;r!==void 0&&f(n)&&(n=P(r,n));let p=n;return O(c,e,p,o),c},i)}function T(t,...o){return o.reduce((s,i)=>P(s,i),t)}var j={};function R(t){return T(j,t)}function l(t){return t.startsWith("$$")?`#node-config-input-${t.replace("$$","")}`:t.startsWith("$")?`#node-input-${t.replace("$","")}`:t}function N(t){return l(t).split("-input-")[1]}function w(t){function o(e){return t[e]}let s=(e,n,r)=>{let p=(r==null?void 0:r.selected)||o(N(e)),x=l(e),y=n;r!=null&&r.emptyValue&&(y=[{value:"",text:r.emptyValue},...n]),$(x).empty().append(y.map(b=>$("<option>",{value:b.value,text:b.text,selected:b.value===p})));},i=e=>{let n=e;return $(`#node-input-${n}`).val()};function u(e,n){let r=l(e);$(r).text(n);}function d(e){let n=l(e);return $(n)}function g(e,n){let r=l(e);$(r).val(n);}function c(e,n){let p=(Array.isArray(e)?e:[e]).map(l).join(", ");$(p).on("input",()=>{let x=$(p).map(function(){return $(this).val()}).get();n(x);});}return {getInputValue:i,watchInput:c,setText:u,setInputValue:g,jqSelector:d,initSelect:s}}exports.createEditorNode=R;exports.domHelper=w;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { NodeDef, Node, EditorNodeProperties, EditorNodeDef, EditorNodeInstance } from 'node-red';
|
|
2
|
+
|
|
3
|
+
type NodeControllerConfig<T> = NodeDef & T;
|
|
4
|
+
type NodeControllerInst<T> = Node & T;
|
|
5
|
+
type NodeEditorProps<T> = EditorNodeProperties & T;
|
|
6
|
+
declare namespace EditorDomHelper {
|
|
7
|
+
type InitSelectParams = {
|
|
8
|
+
selected?: string;
|
|
9
|
+
emptyValue?: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare function createEditorNode<TProps extends EditorNodeProperties, TCreds = undefined, TInstProps extends TProps = TProps>(props: Partial<EditorNodeDef<TProps, TCreds, TInstProps>>): EditorNodeDef<TProps, TCreds, TInstProps>;
|
|
14
|
+
declare function domHelper<TProps>(vm: EditorNodeInstance): {
|
|
15
|
+
getInputValue: (key: Exclude<keyof TProps, "inputs">) => string | number | string[];
|
|
16
|
+
watchInput: <T = any>(selectors: string | string[], callback: (values: T[]) => void) => void;
|
|
17
|
+
setText: (selector: string, text: string) => void;
|
|
18
|
+
setInputValue: (selector: string, val: string) => void;
|
|
19
|
+
jqSelector: (selector: string) => JQuery<HTMLElement>;
|
|
20
|
+
initSelect: (selector: string, options: Record<string, string>[], params?: EditorDomHelper.InitSelectParams) => void;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { EditorDomHelper, type NodeControllerConfig, type NodeControllerInst, type NodeEditorProps, createEditorNode, domHelper };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { NodeDef, Node, EditorNodeProperties, EditorNodeDef, EditorNodeInstance } from 'node-red';
|
|
2
|
+
|
|
3
|
+
type NodeControllerConfig<T> = NodeDef & T;
|
|
4
|
+
type NodeControllerInst<T> = Node & T;
|
|
5
|
+
type NodeEditorProps<T> = EditorNodeProperties & T;
|
|
6
|
+
declare namespace EditorDomHelper {
|
|
7
|
+
type InitSelectParams = {
|
|
8
|
+
selected?: string;
|
|
9
|
+
emptyValue?: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare function createEditorNode<TProps extends EditorNodeProperties, TCreds = undefined, TInstProps extends TProps = TProps>(props: Partial<EditorNodeDef<TProps, TCreds, TInstProps>>): EditorNodeDef<TProps, TCreds, TInstProps>;
|
|
14
|
+
declare function domHelper<TProps>(vm: EditorNodeInstance): {
|
|
15
|
+
getInputValue: (key: Exclude<keyof TProps, "inputs">) => string | number | string[];
|
|
16
|
+
watchInput: <T = any>(selectors: string | string[], callback: (values: T[]) => void) => void;
|
|
17
|
+
setText: (selector: string, text: string) => void;
|
|
18
|
+
setInputValue: (selector: string, val: string) => void;
|
|
19
|
+
jqSelector: (selector: string) => JQuery<HTMLElement>;
|
|
20
|
+
initSelect: (selector: string, options: Record<string, string>[], params?: EditorDomHelper.InitSelectParams) => void;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { EditorDomHelper, type NodeControllerConfig, type NodeControllerInst, type NodeEditorProps, createEditorNode, domHelper };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function m(t){return Object.prototype.toString.call(t).slice(8,-1)}function f(t){if(m(t)!=="Object")return !1;let o=Object.getPrototypeOf(t);return !!o&&o.constructor===Object&&o===Object.prototype}function a(t){return m(t)==="Symbol"}function O(t,o,s,i){let u={}.propertyIsEnumerable.call(i,o)?"enumerable":"nonenumerable";u==="enumerable"&&(t[o]=s),u==="nonenumerable"&&Object.defineProperty(t,o,{value:s,enumerable:!1,writable:!0,configurable:!0});}function P(t,o,s){if(!f(o))return o;let i={};if(f(t)){let c=Object.getOwnPropertyNames(t),e=Object.getOwnPropertySymbols(t);i=[...c,...e].reduce((n,r)=>{let p=t[r];return (!a(r)&&!Object.getOwnPropertyNames(o).includes(r)||a(r)&&!Object.getOwnPropertySymbols(o).includes(r))&&O(n,r,p,t),n},{});}let u=Object.getOwnPropertyNames(o),d=Object.getOwnPropertySymbols(o);return [...u,...d].reduce((c,e)=>{let n=o[e],r=f(t)?t[e]:void 0;r!==void 0&&f(n)&&(n=P(r,n));let p=n;return O(c,e,p,o),c},i)}function T(t,...o){return o.reduce((s,i)=>P(s,i),t)}var j={};function R(t){return T(j,t)}function l(t){return t.startsWith("$$")?`#node-config-input-${t.replace("$$","")}`:t.startsWith("$")?`#node-input-${t.replace("$","")}`:t}function N(t){return l(t).split("-input-")[1]}function w(t){function o(e){return t[e]}let s=(e,n,r)=>{let p=(r==null?void 0:r.selected)||o(N(e)),x=l(e),y=n;r!=null&&r.emptyValue&&(y=[{value:"",text:r.emptyValue},...n]),$(x).empty().append(y.map(b=>$("<option>",{value:b.value,text:b.text,selected:b.value===p})));},i=e=>{let n=e;return $(`#node-input-${n}`).val()};function u(e,n){let r=l(e);$(r).text(n);}function d(e){let n=l(e);return $(n)}function g(e,n){let r=l(e);$(r).val(n);}function c(e,n){let p=(Array.isArray(e)?e:[e]).map(l).join(", ");$(p).on("input",()=>{let x=$(p).map(function(){return $(this).val()}).get();n(x);});}return {getInputValue:i,watchInput:c,setText:u,setInputValue:g,jqSelector:d,initSelect:s}}export{R as createEditorNode,w as domHelper};
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var o=typeof global!="undefined"?global.RED:window.RED;exports._RED=o;
|
package/dist/index.d.cts
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var o=typeof global!="undefined"?global.RED:window.RED;export{o as _RED};
|
package/package.json
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@keload/node-red-dxp",
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "tsup",
|
|
8
|
+
"watch": "tsup --watch",
|
|
9
|
+
"format": "pnpm biome format",
|
|
10
|
+
"lint": "pnpm biome lint",
|
|
11
|
+
"lint:check": "pnpm biome check",
|
|
12
|
+
"release": "pnpm release-it",
|
|
13
|
+
"release:test": "pnpm release-it --dry-run"
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"bin": {
|
|
19
|
+
"node-red-dxp": "./dist/cli/index.cjs"
|
|
20
|
+
},
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"import": "./dist/index.js",
|
|
24
|
+
"require": "./dist/index.cjs"
|
|
25
|
+
},
|
|
26
|
+
"./builder": {
|
|
27
|
+
"import": "./dist/builder/index.js",
|
|
28
|
+
"require": "./dist/builder/index.cjs"
|
|
29
|
+
},
|
|
30
|
+
"./editor": {
|
|
31
|
+
"import": "./dist/editor/index.js",
|
|
32
|
+
"require": "./dist/editor/index.cjs"
|
|
33
|
+
},
|
|
34
|
+
"./package.json": "./package.json"
|
|
35
|
+
},
|
|
36
|
+
"keywords": [],
|
|
37
|
+
"author": "Clément BERARD <contact@berard.dev>",
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/clement-berard/node-red-dxp.git"
|
|
42
|
+
},
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/clement-berard/node-red-dxp/issues"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://github.com/clement-berard/node-red-dxp",
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@biomejs/biome": "1.9.4",
|
|
49
|
+
"@release-it/conventional-changelog": "9.0.3",
|
|
50
|
+
"@types/html-minifier-terser": "7.0.2",
|
|
51
|
+
"@types/jquery": "3.5.32",
|
|
52
|
+
"@types/jqueryui": "1.12.23",
|
|
53
|
+
"@types/node-red": "1.3.5",
|
|
54
|
+
"@types/prettyjson": "0.0.33",
|
|
55
|
+
"browser-sync": "3.0.3",
|
|
56
|
+
"chokidar": "4.0.1",
|
|
57
|
+
"consola": "3.2.3",
|
|
58
|
+
"cssnano": "7.0.6",
|
|
59
|
+
"del": "^6.1.1",
|
|
60
|
+
"esbuild": "0.24.0",
|
|
61
|
+
"glob": "11.0.0",
|
|
62
|
+
"handlebars": "4.7.8",
|
|
63
|
+
"html-minifier-terser": "7.2.0",
|
|
64
|
+
"merge-anything": "6.0.2",
|
|
65
|
+
"nodemon": "3.1.7",
|
|
66
|
+
"prettyjson": "1.2.5",
|
|
67
|
+
"release-it": "17.10.0",
|
|
68
|
+
"sass": "1.81.0",
|
|
69
|
+
"tsup": "8.3.5",
|
|
70
|
+
"tsx": "4.19.2",
|
|
71
|
+
"typescript": "5.6.3"
|
|
72
|
+
},
|
|
73
|
+
"dependencies": {
|
|
74
|
+
"commander": "12.1.0",
|
|
75
|
+
"cosmiconfig": "9.0.0",
|
|
76
|
+
"radash": "12.1.0"
|
|
77
|
+
},
|
|
78
|
+
"files": [
|
|
79
|
+
"dist"
|
|
80
|
+
]
|
|
81
|
+
}
|