@keload/node-red-dxp 1.3.1 → 1.4.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 +2 -2
- package/dist/builder/index.cjs +30 -31
- package/dist/builder/index.d.cts +12 -108
- package/dist/builder/index.d.ts +12 -108
- package/dist/builder/index.js +30 -31
- package/dist/cli/index.cjs +28 -29
- package/dist/editor/assets/tailwind.scss +22 -0
- package/dist/editor/global-solid.ts +15 -0
- package/dist/editor/index.cjs +1 -1
- package/dist/editor/index.d.cts +5 -1
- package/dist/editor/index.d.ts +5 -1
- package/dist/editor/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +9 -4
- package/dist/index.d.ts +9 -4
- package/dist/index.js +0 -1
- package/dist/scaffolding/create-node/hbs/controller.ts.hbs +12 -0
- package/dist/scaffolding/create-node/hbs/doc.md.hbs +32 -0
- package/dist/scaffolding/create-node/hbs/editor/index.html.hbs +8 -0
- package/dist/scaffolding/create-node/hbs/editor/index.ts.hbs +26 -0
- package/dist/scaffolding/create-node/hbs/editor/styles.scss.hbs +2 -0
- package/dist/scaffolding/create-node/hbs/types.ts.hbs +3 -0
- package/package.json +15 -5
- package/dist/editor/assets/styles.scss +0 -182
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<br/>
|
|
2
2
|
<div align="center">
|
|
3
|
-
<a href="https://
|
|
3
|
+
<a href="https://clement-berard.github.io/node-red-dxp/">
|
|
4
4
|
<img src="https://nodered.org/about/resources/media/node-red-icon-2.svg" alt="Logo" width="80" height="80">
|
|
5
5
|
</a>
|
|
6
6
|
<h3 align="center">Node-Red</h3>
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
Developer eXPerience
|
|
9
9
|
<br/>
|
|
10
10
|
<br/>
|
|
11
|
-
<a href="https://
|
|
11
|
+
<a href="https://clement-berard.github.io/node-red-dxp/"><strong>Explore the docs »</strong></a>
|
|
12
12
|
<br/>
|
|
13
13
|
<br/>
|
|
14
14
|
</div>
|
package/dist/builder/index.cjs
CHANGED
|
@@ -1,46 +1,45 @@
|
|
|
1
|
-
'use strict';var
|
|
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}
|
|
1
|
+
'use strict';var k=require('fs'),B=require('path'),cosmiconfig=require('cosmiconfig'),glob=require('glob'),radash=require('radash'),E=require('fs/promises'),dt=require('esbuild'),htmlMinifierTerser=require('html-minifier-terser'),Nt=require('@fullhuman/postcss-purgecss'),$t=require('autoprefixer'),St=require('cssnano'),V=require('postcss'),U=require('sass'),Ct=require('tailwindcss');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 k__default=/*#__PURE__*/_interopDefault(k);var B__default=/*#__PURE__*/_interopDefault(B);var E__default=/*#__PURE__*/_interopDefault(E);var dt__default=/*#__PURE__*/_interopDefault(dt);var Nt__default=/*#__PURE__*/_interopDefault(Nt);var $t__default=/*#__PURE__*/_interopDefault($t);var St__default=/*#__PURE__*/_interopDefault(St);var V__default=/*#__PURE__*/_interopDefault(V);var U__namespace=/*#__PURE__*/_interopNamespace(U);var Ct__default=/*#__PURE__*/_interopDefault(Ct);var Q=Object.defineProperty;var v=Object.getOwnPropertySymbols;var X=Object.prototype.hasOwnProperty,Y=Object.prototype.propertyIsEnumerable;var D=(e,t,r)=>t in e?Q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,u=(e,t)=>{for(var r in t||(t={}))X.call(t,r)&&D(e,r,t[r]);if(v)for(var r of v(t))Y.call(t,r)&&D(e,r,t[r]);return e};var Z=(e=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(e,{get:(t,r)=>(typeof require!="undefined"?require:t)[r]}):e)(function(e){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var g=(e,t,r)=>D(e,typeof t!="symbol"?t+"":t,r);var a=(e,t,r)=>new Promise((o,i)=>{var n=l=>{try{c(r.next(l));}catch(m){i(m);}},d=l=>{try{c(r.throw(l));}catch(m){i(m);}},c=l=>l.done?o(l.value):Promise.resolve(l.value).then(n,d);c((r=r.apply(e,t)).next());});function N(e){return Object.prototype.toString.call(e).slice(8,-1)}function x(e){if(N(e)!=="Object")return !1;let t=Object.getPrototypeOf(e);return !!t&&t.constructor===Object&&t===Object.prototype}function $(e){return N(e)==="Symbol"}function I(e,t,r,o){let i={}.propertyIsEnumerable.call(o,t)?"enumerable":"nonenumerable";i==="enumerable"&&(e[t]=r),i==="nonenumerable"&&Object.defineProperty(e,t,{value:r,enumerable:!1,writable:!0,configurable:!0});}function A(e,t,r){if(!x(t))return t;let o={};if(x(e)){let c=Object.getOwnPropertyNames(e),l=Object.getOwnPropertySymbols(e);o=[...c,...l].reduce((m,p)=>{let w=e[p];return (!$(p)&&!Object.getOwnPropertyNames(t).includes(p)||$(p)&&!Object.getOwnPropertySymbols(t).includes(p))&&I(m,p,w,e),m},{});}let i=Object.getOwnPropertyNames(t),n=Object.getOwnPropertySymbols(t);return [...i,...n].reduce((c,l)=>{let m=t[l],p=x(e)?e[l]:void 0;p!==void 0&&x(m)&&(m=A(p,m));let w=m;return I(c,l,w,t),c},o)}function H(e,...t){return t.reduce((r,o)=>A(r,o),e)}var T={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 it="node-red-dx",nt=e=>e.replace("@","").replace("/","-");function at(){let e=cosmiconfig.cosmiconfigSync(it);try{let t=e.search();return H(T,t?t.config:{})}catch(t){throw console.error("Error while loading configuration",t),t}}var f=at(),y=process.cwd(),L=JSON.parse(k.readFileSync(`${y}/package.json`,"utf-8")),O=`${y}/${f.srcDir}`,lt=`${y}/resources`,S=`${O}/${f.nodesDirName}`,j=`${y}/${f.libCacheDir}`,mt=`${B__default.default.resolve(__dirname,"..")}`,R=nt(L.name);function ct(){return glob.globSync(`${S}/*`,{withFileTypes:!0}).map(t=>{let r=t.fullpath(),o=`${r}/${f.nodes.editor.dirName}`,i=r.replace(y,"").slice(1),n=`${i}/${f.nodes.editor.dirName}`,d=glob.globSync(`${o}/**/*.scss`),c=glob.globSync(`${r}/doc.mdx`),l=glob.globSync(`${r}/doc.md`),m=radash.dash(t.name);return {fullEditorPath:o,fullPath:r,name:t.name,pascalName:radash.pascal(t.name),dashName:m,relativeEditorPath:n,relativePath:i,nodeIdentifier:`${R}-${m}`,fullControllerPath:`${r}/${f.nodes.controllerName}.ts`,editor:{tsPath:`${o}/${f.nodes.editor.tsName}.ts`,htmlPath:`${o}/${f.nodes.editor.htmlName}.html`,scssFiles:d},doc:{mdxFiles:c,mdFiles:l}}})}function pt(){return {currentDir:y,pathSrcDir:O,pathSrcNodesDir:S,additionalResourcesDir:lt,pathDist:`${y}/${f.builder.outputDir}`,currentPackagedDistPath:mt,cacheDirFiles:{controllerIndex:`${j}/controller-index.ts`,editorIndex:`${j}/editor-index.ts`},pathLibCacheDir:j,packageName:L.name,packageNameSlug:R,config:f,resolvedSrcPathsScss:glob.globSync(`${O}/**/*.scss`,{ignore:`${S}/**/*.scss`}),resolvedNodesPaths:glob.globSync(`${S}/*`),listNodesFull:ct()}}var s=pt();var W=`${B__default.default.resolve(__dirname,"..")}`;function M(e){k__default.default.existsSync(e)||k__default.default.mkdirSync(e,{recursive:!0});}function h(e,t){return a(this,null,function*(){try{yield E__default.default.writeFile(e,t);}catch(r){console.error("Error writing controller index:",r);}})}function _(e){return a(this,null,function*(){for(let t of e)try{let r=B__default.default.resolve(t),o=yield E__default.default.stat(r).catch(()=>null);o!=null&&o.isDirectory()&&(yield E__default.default.rm(r,{recursive:!0,force:!0}));}catch(r){console.error(`Error cleaning path (${t}): ${r}`);}})}var P=class{constructor(t){g(this,"params");this.params=u({minify:!1},t);}getControllerIndexContent(){return a(this,null,function*(){return `
|
|
18
2
|
import type { NodeAPI } from 'node-red';
|
|
19
|
-
${
|
|
3
|
+
${s.listNodesFull.map(t=>`import ${t.pascalName} from '${t.fullControllerPath}';`).join(`
|
|
20
4
|
`)}
|
|
21
5
|
|
|
22
6
|
|
|
23
7
|
export default async (RED: NodeAPI): Promise<void> => {
|
|
24
8
|
global.RED = RED;
|
|
25
9
|
|
|
26
|
-
${
|
|
27
|
-
global.RED.nodes.registerType('${
|
|
10
|
+
${s.listNodesFull.map(t=>`// @ts-ignore
|
|
11
|
+
global.RED.nodes.registerType('${t.name}', ${t.pascalName});`).join(`
|
|
28
12
|
`)}
|
|
29
13
|
};
|
|
30
|
-
`.trim()}
|
|
31
|
-
${
|
|
14
|
+
`.trim()})}buildScript(){return dt__default.default.build({entryPoints:[s.cacheDirFiles.controllerIndex],outfile:`${s.pathDist}/index.js`,bundle:!0,minify:this.params.minify,minifyWhitespace:this.params.minify,minifyIdentifiers:this.params.minify,minifySyntax:this.params.minify,platform:"node",format:"cjs",target:"es2018",loader:{".ts":"ts"},packages:"external"})}getControllerTask(){return a(this,null,function*(){return this.getControllerIndexContent().then(t=>{h(`${s.cacheDirFiles.controllerIndex}`,t).then(()=>{this.buildScript();});})})}};var C=class{getAllDocContent(){let t=[];for(let r of s.listNodesFull)if(r.doc.mdFiles[0]){let i=k__default.default.readFileSync(r.doc.mdFiles[0],"utf-8"),n=`
|
|
15
|
+
<script type="text/markdown" data-help-name="${r.name}">
|
|
16
|
+
${i}
|
|
17
|
+
</script>
|
|
18
|
+
`;t.push(n);}return t.length?t.join(`
|
|
19
|
+
`):""}};function G(e){return e.trim().replace(/\n\s+/g,"")}function yt(e){return a(this,null,function*(){return htmlMinifierTerser.minify(e,{collapseWhitespace:!0,removeComments:!0,removeRedundantAttributes:!1,useShortDoctype:!0,removeEmptyAttributes:!1,minifyCSS:!1,minifyJS:!1})})}function ht(e,t){return `
|
|
20
|
+
<script type="text/html" data-template-name="${e}">
|
|
21
|
+
${t}
|
|
22
|
+
</script>
|
|
23
|
+
`}function xt(e,t,r=!1){return a(this,null,function*(){let o=k.readFileSync(e.editor.htmlPath,"utf8"),i=`
|
|
24
|
+
<div class="${t}">
|
|
25
|
+
<div class="${e.nodeIdentifier}">${o}</div>
|
|
26
|
+
</div>
|
|
27
|
+
`,n=r?yield yt(i):i,d=ht(e.name,n);return {nodeName:e.name,nodeIdentifier:e.nodeIdentifier,html:n,wrappedHtml:d}})}function J(e){return a(this,null,function*(){let{nodes:t,minify:r=!1}=e,o=yield Promise.all(t.map(n=>xt(n,e.packageNameSlug,r)));return {html:o.map(n=>n.html).join("").trim(),allWrappedHtml:o.map(n=>r?G(n.wrappedHtml):n.wrappedHtml).join("").trim()}})}function Ft(e,t){return a(this,null,function*(){return (yield V__default.default([Nt__default.default({content:[{raw:t,extension:"html"}]}),$t__default.default,St__default.default({preset:"default"})]).process(e,{from:void 0})).css})}function wt(e){return U__namespace.compile(e,{style:"expanded"}).css}function q(e){let t={};for(let r=0;r<e.length;r++){let o=e[r];t[o]=wt(o);}return t}function Dt(e){return e.some(r=>r.editor.scssFiles.length)?e.filter(r=>r.editor.scssFiles.length).map(r=>{let o=q(r.editor.scssFiles),i=Object.values(o).join("");return {name:r.name,mergedCompiledStyles:i,scssFinal:`
|
|
28
|
+
#${r.nodeIdentifier}{
|
|
29
|
+
${i}
|
|
30
|
+
}`}}):[]}function jt(r){return a(this,arguments,function*(e,t={}){let i=u(u({},{content:[{raw:e}],theme:{}}),t),n=glob.globSync(`${W}/${s.config.nodes.editor.dirName}/assets/tailwind.scss`)[0],d=n.length?k__default.default.readFileSync(n,"utf8"):"";return (yield V__default.default([Ct__default.default(i),Z("autoprefixer")]).process(d,{from:void 0})).css})}function Ot(){let e=s.resolvedSrcPathsScss,t=q([...e]);return Object.values(t).join("")}function z(e){return a(this,null,function*(){let{rawHtml:t,minify:r=!1,nodes:o}=e||{},i=Ot(),n=Dt(o),d=yield jt(t),c=p=>`.${s.packageNameSlug}{${p}}`,l=n.map(p=>p.scssFinal).join(`
|
|
31
|
+
`),m=c(`${d}${i}${l}`);return r?Ft(m,t):m})}var F=class{constructor(t){g(this,"params");this.params=u({minify:!1},t);}getEditorIndexContent(){return a(this,null,function*(){return `
|
|
32
32
|
import type { NodeAPI } from 'node-red';
|
|
33
|
-
${
|
|
33
|
+
${s.listNodesFull.map(t=>`import ${t.pascalName} from '${t.editor.tsPath}';`).join(`
|
|
34
34
|
`)}
|
|
35
35
|
|
|
36
36
|
declare const RED: NodeAPI;
|
|
37
37
|
|
|
38
|
-
${
|
|
39
|
-
window.RED.nodes.registerType('${
|
|
38
|
+
${s.listNodesFull.map(t=>`// @ts-ignore
|
|
39
|
+
window.RED.nodes.registerType('${t.name}', ${t.pascalName});`).join(`
|
|
40
40
|
`)}
|
|
41
|
-
`.trim()}
|
|
42
|
-
|
|
43
|
-
${
|
|
44
|
-
|
|
45
|
-
|
|
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;
|
|
41
|
+
`.trim()})}getBuiltScript(){return a(this,null,function*(){let t=yield dt__default.default.build({entryPoints:[s.cacheDirFiles.editorIndex],bundle:!0,platform:"browser",format:"iife",target:"es6",sourcemap:!1,minify:this.params.minify,minifyWhitespace:this.params.minify,minifySyntax:this.params.minify,minifyIdentifiers:this.params.minify,legalComments:"none",inject:[`${s.currentPackagedDistPath}/editor/global-solid.ts`],write:!1,loader:{".ts":"ts"}});return t.outputFiles&&t.outputFiles.length>0?t.outputFiles[0].text:""})}prepareEditorIndex(){return a(this,null,function*(){let t=yield this.getBuiltScript(),r=yield J({minify:this.params.minify,nodes:s.listNodesFull,packageNameSlug:s.packageNameSlug}),o=yield z({rawHtml:r.html,minify:this.params.minify,nodes:s.listNodesFull}),n=new C().getAllDocContent(),d=`<script type="application/javascript">${t.trim()}</script>`,c=`<style>${o}</style>`;return `
|
|
42
|
+
${r.allWrappedHtml}
|
|
43
|
+
${c}
|
|
44
|
+
${d}
|
|
45
|
+
${n}`.trim()})}getEditorTask(){return a(this,null,function*(){return this.getEditorIndexContent().then(t=>{h(`${s.cacheDirFiles.editorIndex}`,t).then(()=>{this.prepareEditorIndex().then(r=>a(this,null,function*(){yield h(`${s.pathDist}/${s.config.nodes.editor.htmlName}.html`,r);}));});})})}};var K=class{constructor(t){g(this,"params");g(this,"builderController");g(this,"builderEditor");this.params=u({minify:!1},t),this.builderController=new P({minify:this.params.minify}),this.builderEditor=new F({minify:this.params.minify});}prepare(){M(s.pathLibCacheDir);let t=[_([s.pathDist]),h(`${s.pathLibCacheDir}/config.json`,JSON.stringify(s.config,null,2))];return Promise.all(t)}buildAll(){return a(this,null,function*(){return yield this.prepare(),Promise.all([this.builderController.getControllerTask(),this.builderEditor.getEditorTask()])})}};exports.Builder=K;
|
package/dist/builder/index.d.cts
CHANGED
|
@@ -1,109 +1,13 @@
|
|
|
1
|
-
|
|
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
|
-
}[];
|
|
1
|
+
type BuilderClassParams = {
|
|
2
|
+
minify?: boolean;
|
|
63
3
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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 };
|
|
4
|
+
declare class Builder {
|
|
5
|
+
private params;
|
|
6
|
+
private builderController;
|
|
7
|
+
private builderEditor;
|
|
8
|
+
constructor(params?: BuilderClassParams);
|
|
9
|
+
prepare(): Promise<void[]>;
|
|
10
|
+
buildAll(): Promise<[void, void]>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { Builder };
|
package/dist/builder/index.d.ts
CHANGED
|
@@ -1,109 +1,13 @@
|
|
|
1
|
-
|
|
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
|
-
}[];
|
|
1
|
+
type BuilderClassParams = {
|
|
2
|
+
minify?: boolean;
|
|
63
3
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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 };
|
|
4
|
+
declare class Builder {
|
|
5
|
+
private params;
|
|
6
|
+
private builderController;
|
|
7
|
+
private builderEditor;
|
|
8
|
+
constructor(params?: BuilderClassParams);
|
|
9
|
+
prepare(): Promise<void[]>;
|
|
10
|
+
buildAll(): Promise<[void, void]>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { Builder };
|
package/dist/builder/index.js
CHANGED
|
@@ -1,46 +1,45 @@
|
|
|
1
|
-
import
|
|
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}
|
|
1
|
+
import k,{readFileSync}from'node:fs';import B from'node:path';import {cosmiconfigSync}from'cosmiconfig';import {globSync}from'glob';import {dash,pascal}from'radash';import E from'node:fs/promises';import dt from'esbuild';import {minify}from'html-minifier-terser';import Nt from'@fullhuman/postcss-purgecss';import $t from'autoprefixer';import St from'cssnano';import V from'postcss';import*as U from'sass';import Ct from'tailwindcss';var Q=Object.defineProperty;var v=Object.getOwnPropertySymbols;var X=Object.prototype.hasOwnProperty,Y=Object.prototype.propertyIsEnumerable;var D=(e,t,r)=>t in e?Q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,u=(e,t)=>{for(var r in t||(t={}))X.call(t,r)&&D(e,r,t[r]);if(v)for(var r of v(t))Y.call(t,r)&&D(e,r,t[r]);return e};var Z=(e=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(e,{get:(t,r)=>(typeof require!="undefined"?require:t)[r]}):e)(function(e){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var g=(e,t,r)=>D(e,typeof t!="symbol"?t+"":t,r);var a=(e,t,r)=>new Promise((o,i)=>{var n=l=>{try{c(r.next(l));}catch(m){i(m);}},d=l=>{try{c(r.throw(l));}catch(m){i(m);}},c=l=>l.done?o(l.value):Promise.resolve(l.value).then(n,d);c((r=r.apply(e,t)).next());});function N(e){return Object.prototype.toString.call(e).slice(8,-1)}function x(e){if(N(e)!=="Object")return !1;let t=Object.getPrototypeOf(e);return !!t&&t.constructor===Object&&t===Object.prototype}function $(e){return N(e)==="Symbol"}function I(e,t,r,o){let i={}.propertyIsEnumerable.call(o,t)?"enumerable":"nonenumerable";i==="enumerable"&&(e[t]=r),i==="nonenumerable"&&Object.defineProperty(e,t,{value:r,enumerable:!1,writable:!0,configurable:!0});}function A(e,t,r){if(!x(t))return t;let o={};if(x(e)){let c=Object.getOwnPropertyNames(e),l=Object.getOwnPropertySymbols(e);o=[...c,...l].reduce((m,p)=>{let w=e[p];return (!$(p)&&!Object.getOwnPropertyNames(t).includes(p)||$(p)&&!Object.getOwnPropertySymbols(t).includes(p))&&I(m,p,w,e),m},{});}let i=Object.getOwnPropertyNames(t),n=Object.getOwnPropertySymbols(t);return [...i,...n].reduce((c,l)=>{let m=t[l],p=x(e)?e[l]:void 0;p!==void 0&&x(m)&&(m=A(p,m));let w=m;return I(c,l,w,t),c},o)}function H(e,...t){return t.reduce((r,o)=>A(r,o),e)}var T={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 it="node-red-dx",nt=e=>e.replace("@","").replace("/","-");function at(){let e=cosmiconfigSync(it);try{let t=e.search();return H(T,t?t.config:{})}catch(t){throw console.error("Error while loading configuration",t),t}}var f=at(),y=process.cwd(),L=JSON.parse(readFileSync(`${y}/package.json`,"utf-8")),O=`${y}/${f.srcDir}`,lt=`${y}/resources`,S=`${O}/${f.nodesDirName}`,j=`${y}/${f.libCacheDir}`,mt=`${B.resolve(__dirname,"..")}`,R=nt(L.name);function ct(){return globSync(`${S}/*`,{withFileTypes:!0}).map(t=>{let r=t.fullpath(),o=`${r}/${f.nodes.editor.dirName}`,i=r.replace(y,"").slice(1),n=`${i}/${f.nodes.editor.dirName}`,d=globSync(`${o}/**/*.scss`),c=globSync(`${r}/doc.mdx`),l=globSync(`${r}/doc.md`),m=dash(t.name);return {fullEditorPath:o,fullPath:r,name:t.name,pascalName:pascal(t.name),dashName:m,relativeEditorPath:n,relativePath:i,nodeIdentifier:`${R}-${m}`,fullControllerPath:`${r}/${f.nodes.controllerName}.ts`,editor:{tsPath:`${o}/${f.nodes.editor.tsName}.ts`,htmlPath:`${o}/${f.nodes.editor.htmlName}.html`,scssFiles:d},doc:{mdxFiles:c,mdFiles:l}}})}function pt(){return {currentDir:y,pathSrcDir:O,pathSrcNodesDir:S,additionalResourcesDir:lt,pathDist:`${y}/${f.builder.outputDir}`,currentPackagedDistPath:mt,cacheDirFiles:{controllerIndex:`${j}/controller-index.ts`,editorIndex:`${j}/editor-index.ts`},pathLibCacheDir:j,packageName:L.name,packageNameSlug:R,config:f,resolvedSrcPathsScss:globSync(`${O}/**/*.scss`,{ignore:`${S}/**/*.scss`}),resolvedNodesPaths:globSync(`${S}/*`),listNodesFull:ct()}}var s=pt();var W=`${B.resolve(__dirname,"..")}`;function M(e){k.existsSync(e)||k.mkdirSync(e,{recursive:!0});}function h(e,t){return a(this,null,function*(){try{yield E.writeFile(e,t);}catch(r){console.error("Error writing controller index:",r);}})}function _(e){return a(this,null,function*(){for(let t of e)try{let r=B.resolve(t),o=yield E.stat(r).catch(()=>null);o!=null&&o.isDirectory()&&(yield E.rm(r,{recursive:!0,force:!0}));}catch(r){console.error(`Error cleaning path (${t}): ${r}`);}})}var P=class{constructor(t){g(this,"params");this.params=u({minify:!1},t);}getControllerIndexContent(){return a(this,null,function*(){return `
|
|
18
2
|
import type { NodeAPI } from 'node-red';
|
|
19
|
-
${
|
|
3
|
+
${s.listNodesFull.map(t=>`import ${t.pascalName} from '${t.fullControllerPath}';`).join(`
|
|
20
4
|
`)}
|
|
21
5
|
|
|
22
6
|
|
|
23
7
|
export default async (RED: NodeAPI): Promise<void> => {
|
|
24
8
|
global.RED = RED;
|
|
25
9
|
|
|
26
|
-
${
|
|
27
|
-
global.RED.nodes.registerType('${
|
|
10
|
+
${s.listNodesFull.map(t=>`// @ts-ignore
|
|
11
|
+
global.RED.nodes.registerType('${t.name}', ${t.pascalName});`).join(`
|
|
28
12
|
`)}
|
|
29
13
|
};
|
|
30
|
-
`.trim()}
|
|
31
|
-
${
|
|
14
|
+
`.trim()})}buildScript(){return dt.build({entryPoints:[s.cacheDirFiles.controllerIndex],outfile:`${s.pathDist}/index.js`,bundle:!0,minify:this.params.minify,minifyWhitespace:this.params.minify,minifyIdentifiers:this.params.minify,minifySyntax:this.params.minify,platform:"node",format:"cjs",target:"es2018",loader:{".ts":"ts"},packages:"external"})}getControllerTask(){return a(this,null,function*(){return this.getControllerIndexContent().then(t=>{h(`${s.cacheDirFiles.controllerIndex}`,t).then(()=>{this.buildScript();});})})}};var C=class{getAllDocContent(){let t=[];for(let r of s.listNodesFull)if(r.doc.mdFiles[0]){let i=k.readFileSync(r.doc.mdFiles[0],"utf-8"),n=`
|
|
15
|
+
<script type="text/markdown" data-help-name="${r.name}">
|
|
16
|
+
${i}
|
|
17
|
+
</script>
|
|
18
|
+
`;t.push(n);}return t.length?t.join(`
|
|
19
|
+
`):""}};function G(e){return e.trim().replace(/\n\s+/g,"")}function yt(e){return a(this,null,function*(){return minify(e,{collapseWhitespace:!0,removeComments:!0,removeRedundantAttributes:!1,useShortDoctype:!0,removeEmptyAttributes:!1,minifyCSS:!1,minifyJS:!1})})}function ht(e,t){return `
|
|
20
|
+
<script type="text/html" data-template-name="${e}">
|
|
21
|
+
${t}
|
|
22
|
+
</script>
|
|
23
|
+
`}function xt(e,t,r=!1){return a(this,null,function*(){let o=readFileSync(e.editor.htmlPath,"utf8"),i=`
|
|
24
|
+
<div class="${t}">
|
|
25
|
+
<div class="${e.nodeIdentifier}">${o}</div>
|
|
26
|
+
</div>
|
|
27
|
+
`,n=r?yield yt(i):i,d=ht(e.name,n);return {nodeName:e.name,nodeIdentifier:e.nodeIdentifier,html:n,wrappedHtml:d}})}function J(e){return a(this,null,function*(){let{nodes:t,minify:r=!1}=e,o=yield Promise.all(t.map(n=>xt(n,e.packageNameSlug,r)));return {html:o.map(n=>n.html).join("").trim(),allWrappedHtml:o.map(n=>r?G(n.wrappedHtml):n.wrappedHtml).join("").trim()}})}function Ft(e,t){return a(this,null,function*(){return (yield V([Nt({content:[{raw:t,extension:"html"}]}),$t,St({preset:"default"})]).process(e,{from:void 0})).css})}function wt(e){return U.compile(e,{style:"expanded"}).css}function q(e){let t={};for(let r=0;r<e.length;r++){let o=e[r];t[o]=wt(o);}return t}function Dt(e){return e.some(r=>r.editor.scssFiles.length)?e.filter(r=>r.editor.scssFiles.length).map(r=>{let o=q(r.editor.scssFiles),i=Object.values(o).join("");return {name:r.name,mergedCompiledStyles:i,scssFinal:`
|
|
28
|
+
#${r.nodeIdentifier}{
|
|
29
|
+
${i}
|
|
30
|
+
}`}}):[]}function jt(r){return a(this,arguments,function*(e,t={}){let i=u(u({},{content:[{raw:e}],theme:{}}),t),n=globSync(`${W}/${s.config.nodes.editor.dirName}/assets/tailwind.scss`)[0],d=n.length?k.readFileSync(n,"utf8"):"";return (yield V([Ct(i),Z("autoprefixer")]).process(d,{from:void 0})).css})}function Ot(){let e=s.resolvedSrcPathsScss,t=q([...e]);return Object.values(t).join("")}function z(e){return a(this,null,function*(){let{rawHtml:t,minify:r=!1,nodes:o}=e||{},i=Ot(),n=Dt(o),d=yield jt(t),c=p=>`.${s.packageNameSlug}{${p}}`,l=n.map(p=>p.scssFinal).join(`
|
|
31
|
+
`),m=c(`${d}${i}${l}`);return r?Ft(m,t):m})}var F=class{constructor(t){g(this,"params");this.params=u({minify:!1},t);}getEditorIndexContent(){return a(this,null,function*(){return `
|
|
32
32
|
import type { NodeAPI } from 'node-red';
|
|
33
|
-
${
|
|
33
|
+
${s.listNodesFull.map(t=>`import ${t.pascalName} from '${t.editor.tsPath}';`).join(`
|
|
34
34
|
`)}
|
|
35
35
|
|
|
36
36
|
declare const RED: NodeAPI;
|
|
37
37
|
|
|
38
|
-
${
|
|
39
|
-
window.RED.nodes.registerType('${
|
|
38
|
+
${s.listNodesFull.map(t=>`// @ts-ignore
|
|
39
|
+
window.RED.nodes.registerType('${t.name}', ${t.pascalName});`).join(`
|
|
40
40
|
`)}
|
|
41
|
-
`.trim()}
|
|
42
|
-
|
|
43
|
-
${
|
|
44
|
-
|
|
45
|
-
|
|
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};
|
|
41
|
+
`.trim()})}getBuiltScript(){return a(this,null,function*(){let t=yield dt.build({entryPoints:[s.cacheDirFiles.editorIndex],bundle:!0,platform:"browser",format:"iife",target:"es6",sourcemap:!1,minify:this.params.minify,minifyWhitespace:this.params.minify,minifySyntax:this.params.minify,minifyIdentifiers:this.params.minify,legalComments:"none",inject:[`${s.currentPackagedDistPath}/editor/global-solid.ts`],write:!1,loader:{".ts":"ts"}});return t.outputFiles&&t.outputFiles.length>0?t.outputFiles[0].text:""})}prepareEditorIndex(){return a(this,null,function*(){let t=yield this.getBuiltScript(),r=yield J({minify:this.params.minify,nodes:s.listNodesFull,packageNameSlug:s.packageNameSlug}),o=yield z({rawHtml:r.html,minify:this.params.minify,nodes:s.listNodesFull}),n=new C().getAllDocContent(),d=`<script type="application/javascript">${t.trim()}</script>`,c=`<style>${o}</style>`;return `
|
|
42
|
+
${r.allWrappedHtml}
|
|
43
|
+
${c}
|
|
44
|
+
${d}
|
|
45
|
+
${n}`.trim()})}getEditorTask(){return a(this,null,function*(){return this.getEditorIndexContent().then(t=>{h(`${s.cacheDirFiles.editorIndex}`,t).then(()=>{this.prepareEditorIndex().then(r=>a(this,null,function*(){yield h(`${s.pathDist}/${s.config.nodes.editor.htmlName}.html`,r);}));});})})}};var K=class{constructor(t){g(this,"params");g(this,"builderController");g(this,"builderEditor");this.params=u({minify:!1},t),this.builderController=new P({minify:this.params.minify}),this.builderEditor=new F({minify:this.params.minify});}prepare(){M(s.pathLibCacheDir);let t=[_([s.pathDist]),h(`${s.pathLibCacheDir}/config.json`,JSON.stringify(s.config,null,2))];return Promise.all(t)}buildAll(){return a(this,null,function*(){return yield this.prepare(),Promise.all([this.builderController.getControllerTask(),this.builderEditor.getEditorTask()])})}};export{K as Builder};
|
package/dist/cli/index.cjs
CHANGED
|
@@ -1,47 +1,46 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
'use strict';var
|
|
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
|
-
${_}
|
|
2
|
+
'use strict';var perf_hooks=require('perf_hooks'),ne=require('process'),commander=require('commander'),consola=require('consola'),M=require('fs'),q=require('path'),cosmiconfig=require('cosmiconfig'),glob=require('glob'),radash=require('radash'),O=require('fs/promises'),we=require('esbuild'),htmlMinifierTerser=require('html-minifier-terser'),Ie=require('@fullhuman/postcss-purgecss'),Oe=require('autoprefixer'),ke=require('cssnano'),U=require('postcss'),z=require('sass'),He=require('tailwindcss'),_e=require('prettyjson'),ze=require('handlebars'),et=require('browser-sync'),tt=require('chokidar'),te=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 ne__namespace=/*#__PURE__*/_interopNamespace(ne);var M__default=/*#__PURE__*/_interopDefault(M);var q__default=/*#__PURE__*/_interopDefault(q);var O__default=/*#__PURE__*/_interopDefault(O);var we__default=/*#__PURE__*/_interopDefault(we);var Ie__default=/*#__PURE__*/_interopDefault(Ie);var Oe__default=/*#__PURE__*/_interopDefault(Oe);var ke__default=/*#__PURE__*/_interopDefault(ke);var U__default=/*#__PURE__*/_interopDefault(U);var z__namespace=/*#__PURE__*/_interopNamespace(z);var He__default=/*#__PURE__*/_interopDefault(He);var _e__default=/*#__PURE__*/_interopDefault(_e);var ze__default=/*#__PURE__*/_interopDefault(ze);var et__default=/*#__PURE__*/_interopDefault(et);var tt__default=/*#__PURE__*/_interopDefault(tt);var te__default=/*#__PURE__*/_interopDefault(te);var ae=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var A={name:"@keload/node-red-dxp",version:"1.3.2",description:"",type:"module",scripts:{build:"tsup",watch:"tsup --watch",format:"pnpm biome format",lint:"pnpm biome lint","lint:check":"pnpm biome check",release:"pnpm release-it","release:test":"pnpm release-it --dry-run","docs:dev":"vitepress dev docs","docs:build":"vitepress build docs","docs:preview":"vitepress preview docs"},publishConfig:{access:"public"},bin:{"node-red-dxp":"./dist/cli/index.cjs"},exports:{".":{import:"./dist/index.js",require:"./dist/index.cjs"},"./builder":{import:"./dist/builder/index.js",require:"./dist/builder/index.cjs"},"./editor":{import:"./dist/editor/index.js",require:"./dist/editor/index.cjs"},"./package.json":"./package.json"},keywords:[],author:"Cl\xE9ment BERARD <contact@berard.dev>",license:"MIT",repository:{type:"git",url:"https://github.com/clement-berard/node-red-dxp.git"},bugs:{url:"https://github.com/clement-berard/node-red-dxp/issues"},homepage:"https://github.com/clement-berard/node-red-dxp",devDependencies:{"@biomejs/biome":"1.9.4","@release-it/conventional-changelog":"9.0.3","@types/handlebars":"4.1.0","release-it":"17.10.0",tsup:"8.3.5",tsx:"4.19.2",typescript:"5.6.3",vitepress:"1.5.0"},dependencies:{"@fullhuman/postcss-purgecss":"^6.0.0","@types/html-minifier-terser":"7.0.2","@types/jquery":"3.5.32","@types/jqueryui":"1.12.23","@types/node-red":"1.3.5","@types/prettyjson":"0.0.33",autoprefixer:"^10.4.20","browser-sync":"3.0.3",chokidar:"4.0.1",commander:"12.1.0",consola:"3.2.3",cosmiconfig:"9.0.0",cssnano:"^7.0.6",esbuild:"0.24.0",glob:"11.0.0",handlebars:"4.7.8","html-minifier-terser":"7.2.0","merge-anything":"6.0.2",nodemon:"3.1.7",postcss:"^8.4.49",prettyjson:"1.2.5",radash:"12.1.0",sass:"1.81.0","solid-js":"1.9.3",tailwindcss:"^3.4.15"},files:["dist"]};function w(t){return Object.prototype.toString.call(t).slice(8,-1)}function g(t){if(w(t)!=="Object")return !1;let e=Object.getPrototypeOf(t);return !!e&&e.constructor===Object&&e===Object.prototype}function P(t){return w(t)==="Symbol"}function H(t,e,r,o){let n={}.propertyIsEnumerable.call(o,e)?"enumerable":"nonenumerable";n==="enumerable"&&(t[e]=r),n==="nonenumerable"&&Object.defineProperty(t,e,{value:r,enumerable:!1,writable:!0,configurable:!0});}function B(t,e,r){if(!g(e))return e;let o={};if(g(t)){let m=Object.getOwnPropertyNames(t),c=Object.getOwnPropertySymbols(t);o=[...m,...c].reduce((a,l)=>{let v=t[l];return (!P(l)&&!Object.getOwnPropertyNames(e).includes(l)||P(l)&&!Object.getOwnPropertySymbols(e).includes(l))&&H(a,l,v,t),a},{});}let n=Object.getOwnPropertyNames(e),i=Object.getOwnPropertySymbols(e);return [...n,...i].reduce((m,c)=>{let a=e[c],l=g(t)?t[c]:void 0;l!==void 0&&g(a)&&(a=B(l,a));let v=a;return H(m,c,v,e),m},o)}function R(t,...e){return e.reduce((r,o)=>B(r,o),t)}var T={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 ue="node-red-dx",he=t=>t.replace("@","").replace("/","-");function ge(){let t=cosmiconfig.cosmiconfigSync(ue);try{let e=t.search();return R(T,e?e.config:{})}catch(e){throw console.error("Error while loading configuration",e),e}}var d=ge(),u=process.cwd(),L=JSON.parse(M.readFileSync(`${u}/package.json`,"utf-8")),I=`${u}/${d.srcDir}`,ye=`${u}/resources`,$=`${I}/${d.nodesDirName}`,E=`${u}/${d.libCacheDir}`,xe=`${q__default.default.resolve(__dirname,"..")}`,W=he(L.name);function be(){return glob.globSync(`${$}/*`,{withFileTypes:!0}).map(e=>{let r=e.fullpath(),o=`${r}/${d.nodes.editor.dirName}`,n=r.replace(u,"").slice(1),i=`${n}/${d.nodes.editor.dirName}`,p=glob.globSync(`${o}/**/*.scss`),m=glob.globSync(`${r}/doc.mdx`),c=glob.globSync(`${r}/doc.md`),a=radash.dash(e.name);return {fullEditorPath:o,fullPath:r,name:e.name,pascalName:radash.pascal(e.name),dashName:a,relativeEditorPath:i,relativePath:n,nodeIdentifier:`${W}-${a}`,fullControllerPath:`${r}/${d.nodes.controllerName}.ts`,editor:{tsPath:`${o}/${d.nodes.editor.tsName}.ts`,htmlPath:`${o}/${d.nodes.editor.htmlName}.html`,scssFiles:p},doc:{mdxFiles:m,mdFiles:c}}})}function Ne(){return {currentDir:u,pathSrcDir:I,pathSrcNodesDir:$,additionalResourcesDir:ye,pathDist:`${u}/${d.builder.outputDir}`,currentPackagedDistPath:xe,cacheDirFiles:{controllerIndex:`${E}/controller-index.ts`,editorIndex:`${E}/editor-index.ts`},pathLibCacheDir:E,packageName:L.name,packageNameSlug:W,config:d,resolvedSrcPathsScss:glob.globSync(`${I}/**/*.scss`,{ignore:`${$}/**/*.scss`}),resolvedNodesPaths:glob.globSync(`${$}/*`),listNodesFull:be()}}var s=Ne();var G=`${q__default.default.resolve(__dirname,"..")}`;function C(t){M__default.default.existsSync(t)||M__default.default.mkdirSync(t,{recursive:!0});}async function f(t,e){try{await O__default.default.writeFile(t,e);}catch(r){console.error("Error writing controller index:",r);}}async function J(t){for(let e of t)try{let r=q__default.default.resolve(e),o=await O__default.default.stat(r).catch(()=>null);o!=null&&o.isDirectory()&&await O__default.default.rm(r,{recursive:!0,force:!0});}catch(r){console.error(`Error cleaning path (${e}): ${r}`);}}var S=class{params;constructor(e){this.params={minify:!1,...e};}async getControllerIndexContent(){return `
|
|
19
3
|
import type { NodeAPI } from 'node-red';
|
|
20
|
-
${
|
|
4
|
+
${s.listNodesFull.map(e=>`import ${e.pascalName} from '${e.fullControllerPath}';`).join(`
|
|
21
5
|
`)}
|
|
22
6
|
|
|
23
7
|
|
|
24
8
|
export default async (RED: NodeAPI): Promise<void> => {
|
|
25
9
|
global.RED = RED;
|
|
26
10
|
|
|
27
|
-
${
|
|
11
|
+
${s.listNodesFull.map(e=>`// @ts-ignore
|
|
28
12
|
global.RED.nodes.registerType('${e.name}', ${e.pascalName});`).join(`
|
|
29
13
|
`)}
|
|
30
14
|
};
|
|
31
|
-
`.trim()}
|
|
32
|
-
${
|
|
15
|
+
`.trim()}buildScript(){return we__default.default.build({entryPoints:[s.cacheDirFiles.controllerIndex],outfile:`${s.pathDist}/index.js`,bundle:!0,minify:this.params.minify,minifyWhitespace:this.params.minify,minifyIdentifiers:this.params.minify,minifySyntax:this.params.minify,platform:"node",format:"cjs",target:"es2018",loader:{".ts":"ts"},packages:"external"})}async getControllerTask(){return this.getControllerIndexContent().then(e=>{f(`${s.cacheDirFiles.controllerIndex}`,e).then(()=>{this.buildScript();});})}};var D=class{getAllDocContent(){let e=[];for(let r of s.listNodesFull)if(r.doc.mdFiles[0]){let n=M__default.default.readFileSync(r.doc.mdFiles[0],"utf-8"),i=`
|
|
16
|
+
<script type="text/markdown" data-help-name="${r.name}">
|
|
17
|
+
${n}
|
|
18
|
+
</script>
|
|
19
|
+
`;e.push(i);}return e.length?e.join(`
|
|
20
|
+
`):""}};function _(t){return t.trim().replace(/\n\s+/g,"")}function V(t=""){return {name:t,dashName:radash.dash(t),pascalName:radash.pascal(t)}}async function Fe(t){return htmlMinifierTerser.minify(t,{collapseWhitespace:!0,removeComments:!0,removeRedundantAttributes:!1,useShortDoctype:!0,removeEmptyAttributes:!1,minifyCSS:!1,minifyJS:!1})}function je(t,e){return `
|
|
21
|
+
<script type="text/html" data-template-name="${t}">
|
|
22
|
+
${e}
|
|
23
|
+
</script>
|
|
24
|
+
`}async function ve(t,e,r=!1){let o=M.readFileSync(t.editor.htmlPath,"utf8"),n=`
|
|
25
|
+
<div class="${e}">
|
|
26
|
+
<div class="${t.nodeIdentifier}">${o}</div>
|
|
27
|
+
</div>
|
|
28
|
+
`,i=r?await Fe(n):n,p=je(t.name,i);return {nodeName:t.name,nodeIdentifier:t.nodeIdentifier,html:i,wrappedHtml:p}}async function K(t){let{nodes:e,minify:r=!1}=t,o=await Promise.all(e.map(i=>ve(i,t.packageNameSlug,r)));return {html:o.map(i=>i.html).join("").trim(),allWrappedHtml:o.map(i=>r?_(i.wrappedHtml):i.wrappedHtml).join("").trim()}}async function Be(t,e){return (await U__default.default([Ie__default.default({content:[{raw:e,extension:"html"}]}),Oe__default.default,ke__default.default({preset:"default"})]).process(t,{from:void 0})).css}function Re(t){return z__namespace.compile(t,{style:"expanded"}).css}function Q(t){let e={};for(let r=0;r<t.length;r++){let o=t[r];e[o]=Re(o);}return e}function Te(t){return t.some(r=>r.editor.scssFiles.length)?t.filter(r=>r.editor.scssFiles.length).map(r=>{let o=Q(r.editor.scssFiles),n=Object.values(o).join("");return {name:r.name,mergedCompiledStyles:n,scssFinal:`
|
|
29
|
+
#${r.nodeIdentifier}{
|
|
30
|
+
${n}
|
|
31
|
+
}`}}):[]}async function Le(t,e={}){let o={...{content:[{raw:t}],theme:{}},...e},n=glob.globSync(`${G}/${s.config.nodes.editor.dirName}/assets/tailwind.scss`)[0],i=n.length?M__default.default.readFileSync(n,"utf8"):"";return (await U__default.default([He__default.default(o),ae("autoprefixer")]).process(i,{from:void 0})).css}function We(){let t=s.resolvedSrcPathsScss,e=Q([...t]);return Object.values(e).join("")}async function X(t){let{rawHtml:e,minify:r=!1,nodes:o}=t||{},n=We(),i=Te(o),p=await Le(e),m=l=>`.${s.packageNameSlug}{${l}}`,c=i.map(l=>l.scssFinal).join(`
|
|
32
|
+
`),a=m(`${p}${n}${c}`);return r?Be(a,e):a}var F=class{params;constructor(e){this.params={minify:!1,...e};}async getEditorIndexContent(){return `
|
|
33
33
|
import type { NodeAPI } from 'node-red';
|
|
34
|
-
${
|
|
34
|
+
${s.listNodesFull.map(e=>`import ${e.pascalName} from '${e.editor.tsPath}';`).join(`
|
|
35
35
|
`)}
|
|
36
36
|
|
|
37
37
|
declare const RED: NodeAPI;
|
|
38
38
|
|
|
39
|
-
${
|
|
39
|
+
${s.listNodesFull.map(e=>`// @ts-ignore
|
|
40
40
|
window.RED.nodes.registerType('${e.name}', ${e.pascalName});`).join(`
|
|
41
41
|
`)}
|
|
42
|
-
`.trim()}
|
|
43
|
-
|
|
44
|
-
${
|
|
45
|
-
|
|
46
|
-
|
|
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);
|
|
42
|
+
`.trim()}async getBuiltScript(){let e=await we__default.default.build({entryPoints:[s.cacheDirFiles.editorIndex],bundle:!0,platform:"browser",format:"iife",target:"es6",sourcemap:!1,minify:this.params.minify,minifyWhitespace:this.params.minify,minifySyntax:this.params.minify,minifyIdentifiers:this.params.minify,legalComments:"none",inject:[`${s.currentPackagedDistPath}/editor/global-solid.ts`],write:!1,loader:{".ts":"ts"}});return e.outputFiles&&e.outputFiles.length>0?e.outputFiles[0].text:""}async prepareEditorIndex(){let e=await this.getBuiltScript(),r=await K({minify:this.params.minify,nodes:s.listNodesFull,packageNameSlug:s.packageNameSlug}),o=await X({rawHtml:r.html,minify:this.params.minify,nodes:s.listNodesFull}),i=new D().getAllDocContent(),p=`<script type="application/javascript">${e.trim()}</script>`,m=`<style>${o}</style>`;return `
|
|
43
|
+
${r.allWrappedHtml}
|
|
44
|
+
${m}
|
|
45
|
+
${p}
|
|
46
|
+
${i}`.trim()}async getEditorTask(){return this.getEditorIndexContent().then(e=>{f(`${s.cacheDirFiles.editorIndex}`,e).then(()=>{this.prepareEditorIndex().then(async r=>{await f(`${s.pathDist}/${s.config.nodes.editor.htmlName}.html`,r);});});})}};var x=class{params;builderController;builderEditor;constructor(e){this.params={minify:!1,...e},this.builderController=new S({minify:this.params.minify}),this.builderEditor=new F({minify:this.params.minify});}prepare(){C(s.pathLibCacheDir);let e=[J([s.pathDist]),f(`${s.pathLibCacheDir}/config.json`,JSON.stringify(s.config,null,2))];return Promise.all(e)}async buildAll(){return await this.prepare(),Promise.all([this.builderController.getControllerTask(),this.builderEditor.getEditorTask()])}};function Y(t){let e=new commander.Command("checks").description("[WIP] Commands to check the some stuff");e.command("nodes-structure").description("[WIP] Verify the structure of the nodes").action(()=>{console.log("In construction");}),t.addCommand(e);}function Z(t){let e=new commander.Command("info").description("Command to get information").description("Get information about the package").action(()=>{consola.consola.log(_e__default.default.render(s));});t.addCommand(e);}async function Qe(t){try{let e=q__default.default.resolve(t);return await O__default.default.readFile(e,"utf-8")}catch(e){throw new Error(`Failed to load file: ${e.message}`)}}async function Xe(t,e){try{let r=await Qe(t);return ze__default.default.compile(r)(e)}catch(r){throw new Error(`Failed to render template: ${r.message}`)}}var j=class{nodePascalName;nodeDashName;newNodeDistPath;newNodeEditorDistPath;scaffoldedDistHbs;constructor(e){let{pascalName:r,dashName:o}=V(e);this.nodePascalName=r,this.nodeDashName=o,this.newNodeDistPath=`${s.pathSrcNodesDir}/${o}`,this.newNodeEditorDistPath=`${this.newNodeDistPath}/${s.config.nodes.editor.dirName}`,this.scaffoldedDistHbs=`${s.currentPackagedDistPath}/scaffolding/create-node/hbs`;}distFolderExist(){return M__default.default.existsSync(this.newNodeDistPath)}prepareStructure(){return [{finalPath:`${this.newNodeDistPath}/index.ts`,templatePath:`${this.scaffoldedDistHbs}/controller.ts.hbs`,templateData:{nodePascalName:this.nodePascalName,nodeName:this.nodeDashName}},{finalPath:`${this.newNodeDistPath}/types.ts`,templatePath:`${this.scaffoldedDistHbs}/types.ts.hbs`,templateData:{nodePascalName:this.nodePascalName,nodeName:this.nodeDashName}},{finalPath:`${this.newNodeDistPath}/doc.md`,templatePath:`${this.scaffoldedDistHbs}/doc.md.hbs`,templateData:{}},{finalPath:`${this.newNodeEditorDistPath}/index.ts`,templatePath:`${this.scaffoldedDistHbs}/editor/index.ts.hbs`,templateData:{nodePascalName:this.nodePascalName,nodeName:this.nodeDashName}},{finalPath:`${this.newNodeEditorDistPath}/styles.scss`,templatePath:`${this.scaffoldedDistHbs}/editor/styles.scss.hbs`,templateData:{nodeName:this.nodeDashName}},{finalPath:`${this.newNodeEditorDistPath}/index.html`,templatePath:`${this.scaffoldedDistHbs}/editor/index.html.hbs`,templateData:{}}]}async renderFilesTemplates(){let e=this.prepareStructure().map(async r=>Xe(r.templatePath,r.templateData).then(o=>({finalPath:r.finalPath,content:o})));return await Promise.all(e)}async writeNewNode(){let e=await this.renderFilesTemplates();await Promise.all(e.map(r=>f(r.finalPath,r.content)));}};function ee(t){let e=new commander.Command("create-node").description("Create new node").action(async()=>{let r=await consola.consola.prompt("Enter node name:",{type:"text"}),o=radash.dash(r);if(!await consola.consola.prompt(`This name is OK for you '${o}'?`,{type:"confirm"})){consola.consola.info("\u{1F44C} OK. Exiting...");return}let i=new j(o);if(i.distFolderExist()){consola.consola.error(`Node ${i.nodeDashName} already exists`),consola.consola.info(`In ${i.newNodeDistPath}`);return}C(i.newNodeEditorDistPath),await i.writeNewNode();});t.addCommand(e);}var re,k;function rt(){re=te__default.default({exec:`node-red -u ${s.config.watcher.nodeRed.path}`,ignore:["**/*"],ext:"js,html",verbose:!0}),te__default.default.once("start",()=>{k=et__default.default.create(),k.init({ui:!1,proxy:{target:s.config.watcher.nodeRed.url,ws:!0},ghostMode:!1,open:!1,reloadDelay:4e3});}).on("quit",()=>{consola.consola.info("Nodemon has quit"),process.exit(0);});}function ot(){re.restart(),k.reload();}function oe(){let t=s.config.watcher.nodeRed.enabled&&s.config.watcher.nodeRed.path,e=tt__default.default.watch(s.pathSrcDir,{}),r=new x({minify:!1});e.on("ready",async()=>{consola.consola.info("Initial scan complete. Ready for changes"),await r.buildAll(),consola.consola.success("Initial Build completed"),t?rt():consola.consola.warn("Node-Red watcher is disabled. Please enable it in the config file");}).on("change",async o=>{consola.consola.info(`File ${o.replace(s.currentDir,"")} has been changed`),await r.buildAll(),consola.consola.success("Build completed"),t&&ot();});}var h=new commander.Command;h.name("node-red-dxp").description("node-red-dxp CLI").version(A.version);h.command("build").description("Build project").action(async t=>{let e=perf_hooks.performance.now();consola.consola.start("Building..."),await new x({minify:!0}).buildAll();let n=perf_hooks.performance.now()-e,i=n>1e3?`${(n/1e3).toFixed(2)}s`:`${n.toFixed(2)}ms`;consola.consola.ready(`Build completed in ${i}`);});h.command("watch").description("watch project").option("--minify <minify>","[WIP] Minify the output",!1).action(t=>{oe();});Y(h);Z(h);ee(h);h.parse(ne__namespace.argv);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
@tailwind utilities; @tailwind components; @tailwind base;
|
|
2
|
+
|
|
3
|
+
@layer components {
|
|
4
|
+
.alert {
|
|
5
|
+
@apply p-4 mb-4 text-sm rounded-lg;
|
|
6
|
+
}
|
|
7
|
+
.alert-info {
|
|
8
|
+
@apply text-blue-800 bg-blue-50;
|
|
9
|
+
}
|
|
10
|
+
.alert-danger {
|
|
11
|
+
@apply text-red-800 bg-red-50;
|
|
12
|
+
}
|
|
13
|
+
.alert-success {
|
|
14
|
+
@apply text-green-800 bg-green-50;
|
|
15
|
+
}
|
|
16
|
+
.alert-warning {
|
|
17
|
+
@apply text-yellow-800 bg-yellow-50;
|
|
18
|
+
}
|
|
19
|
+
.alert-dark {
|
|
20
|
+
@apply text-gray-800 bg-gray-50;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as Solid from 'solid-js';
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
var SolidJS: typeof import('solid-js');
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
declare global {
|
|
8
|
+
interface Window {
|
|
9
|
+
SolidJS: typeof import('solid-js');
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (!window.SolidJS) {
|
|
14
|
+
window.SolidJS = Solid;
|
|
15
|
+
}
|
package/dist/editor/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';function
|
|
1
|
+
'use strict';var solidJs=require('solid-js');function d(e){return Object.prototype.toString.call(e).slice(8,-1)}function m(e){if(d(e)!=="Object")return !1;let r=Object.getPrototypeOf(e);return !!r&&r.constructor===Object&&r===Object.prototype}function x(e){return d(e)==="Symbol"}function O(e,r,s,i){let p={}.propertyIsEnumerable.call(i,r)?"enumerable":"nonenumerable";p==="enumerable"&&(e[r]=s),p==="nonenumerable"&&Object.defineProperty(e,r,{value:s,enumerable:!1,writable:!0,configurable:!0});}function T(e,r,s){if(!m(r))return r;let i={};if(m(e)){let l=Object.getOwnPropertyNames(e),t=Object.getOwnPropertySymbols(e);i=[...l,...t].reduce((n,o)=>{let c=e[o];return (!x(o)&&!Object.getOwnPropertyNames(r).includes(o)||x(o)&&!Object.getOwnPropertySymbols(r).includes(o))&&O(n,o,c,e),n},{});}let p=Object.getOwnPropertyNames(r),f=Object.getOwnPropertySymbols(r);return [...p,...f].reduce((l,t)=>{let n=r[t],o=m(e)?e[t]:void 0;o!==void 0&&m(n)&&(n=T(o,n));let c=n;return O(l,t,c,r),l},i)}function P(e,...r){return r.reduce((s,i)=>T(s,i),e)}function u(e){return e.startsWith("$$")?`#node-config-input-${e.replace("$$","")}`:e.startsWith("$")?`#node-input-${e.replace("$","")}`:e}function B(e,r){let s=u(e),i=document.querySelector(s);if(!i)throw new Error(`Element with id '${e}' not found`);let[p,f]=solidJs.createSignal(r||""),a=()=>{f(i.value);},l=t=>{i.value!==t&&(i.value=t);};return i.addEventListener("input",a),solidJs.onCleanup(()=>{console.log("JE CLEAN"),i.removeEventListener("input",a);}),solidJs.createEffect(()=>{l(p());}),f(i.value||r),[p,f]}var N={};function J(e){return P(N,e)}function j(e){return u(e).split("-input-")[1]}function z(e){function r(t){return e[t]}let s=(t,n,o)=>{let c=(o==null?void 0:o.selected)||r(j(t)),g=u(t),y=n;o!=null&&o.emptyValue&&(y=[{value:"",text:o.emptyValue},...n]),$(g).empty().append(y.map(b=>$("<option>",{value:b.value,text:b.text,selected:b.value===c})));},i=t=>{let n=t;return $(`#node-input-${n}`).val()};function p(t,n){let o=u(t);$(o).text(n);}function f(t){let n=u(t);return $(n)}function a(t,n){let o=u(t);$(o).val(n);}function l(t,n){let c=(Array.isArray(t)?t:[t]).map(u).join(", ");$(c).on("input",()=>{let g=$(c).map(function(){return $(this).val()}).get();n(g);});}return {getInputValue:i,watchInput:l,setText:p,setInputValue:a,jqSelector:f,initSelect:s}}exports.createEditorNode=J;exports.createReactiveField=B;exports.domHelper=z;exports.resolveSelector=u;
|
package/dist/editor/index.d.cts
CHANGED
|
@@ -10,6 +10,10 @@ declare namespace EditorDomHelper {
|
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
declare function resolveSelector(inSelector: string): string;
|
|
14
|
+
|
|
15
|
+
declare function createReactiveField<T extends HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>(selector: string, defaultValue?: string): [() => string, (value: string) => void];
|
|
16
|
+
|
|
13
17
|
declare function createEditorNode<TProps extends EditorNodeProperties, TCreds = undefined, TInstProps extends TProps = TProps>(props: Partial<EditorNodeDef<TProps, TCreds, TInstProps>>): EditorNodeDef<TProps, TCreds, TInstProps>;
|
|
14
18
|
declare function domHelper<TProps>(vm: EditorNodeInstance): {
|
|
15
19
|
getInputValue: (key: Exclude<keyof TProps, "inputs">) => string | number | string[];
|
|
@@ -20,4 +24,4 @@ declare function domHelper<TProps>(vm: EditorNodeInstance): {
|
|
|
20
24
|
initSelect: (selector: string, options: Record<string, string>[], params?: EditorDomHelper.InitSelectParams) => void;
|
|
21
25
|
};
|
|
22
26
|
|
|
23
|
-
export { EditorDomHelper, type NodeControllerConfig, type NodeControllerInst, type NodeEditorProps, createEditorNode, domHelper };
|
|
27
|
+
export { EditorDomHelper, type NodeControllerConfig, type NodeControllerInst, type NodeEditorProps, createEditorNode, createReactiveField, domHelper, resolveSelector };
|
package/dist/editor/index.d.ts
CHANGED
|
@@ -10,6 +10,10 @@ declare namespace EditorDomHelper {
|
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
declare function resolveSelector(inSelector: string): string;
|
|
14
|
+
|
|
15
|
+
declare function createReactiveField<T extends HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>(selector: string, defaultValue?: string): [() => string, (value: string) => void];
|
|
16
|
+
|
|
13
17
|
declare function createEditorNode<TProps extends EditorNodeProperties, TCreds = undefined, TInstProps extends TProps = TProps>(props: Partial<EditorNodeDef<TProps, TCreds, TInstProps>>): EditorNodeDef<TProps, TCreds, TInstProps>;
|
|
14
18
|
declare function domHelper<TProps>(vm: EditorNodeInstance): {
|
|
15
19
|
getInputValue: (key: Exclude<keyof TProps, "inputs">) => string | number | string[];
|
|
@@ -20,4 +24,4 @@ declare function domHelper<TProps>(vm: EditorNodeInstance): {
|
|
|
20
24
|
initSelect: (selector: string, options: Record<string, string>[], params?: EditorDomHelper.InitSelectParams) => void;
|
|
21
25
|
};
|
|
22
26
|
|
|
23
|
-
export { EditorDomHelper, type NodeControllerConfig, type NodeControllerInst, type NodeEditorProps, createEditorNode, domHelper };
|
|
27
|
+
export { EditorDomHelper, type NodeControllerConfig, type NodeControllerInst, type NodeEditorProps, createEditorNode, createReactiveField, domHelper, resolveSelector };
|
package/dist/editor/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import {createSignal,onCleanup,createEffect}from'solid-js';function d(e){return Object.prototype.toString.call(e).slice(8,-1)}function m(e){if(d(e)!=="Object")return !1;let r=Object.getPrototypeOf(e);return !!r&&r.constructor===Object&&r===Object.prototype}function x(e){return d(e)==="Symbol"}function O(e,r,s,i){let p={}.propertyIsEnumerable.call(i,r)?"enumerable":"nonenumerable";p==="enumerable"&&(e[r]=s),p==="nonenumerable"&&Object.defineProperty(e,r,{value:s,enumerable:!1,writable:!0,configurable:!0});}function T(e,r,s){if(!m(r))return r;let i={};if(m(e)){let l=Object.getOwnPropertyNames(e),t=Object.getOwnPropertySymbols(e);i=[...l,...t].reduce((n,o)=>{let c=e[o];return (!x(o)&&!Object.getOwnPropertyNames(r).includes(o)||x(o)&&!Object.getOwnPropertySymbols(r).includes(o))&&O(n,o,c,e),n},{});}let p=Object.getOwnPropertyNames(r),f=Object.getOwnPropertySymbols(r);return [...p,...f].reduce((l,t)=>{let n=r[t],o=m(e)?e[t]:void 0;o!==void 0&&m(n)&&(n=T(o,n));let c=n;return O(l,t,c,r),l},i)}function P(e,...r){return r.reduce((s,i)=>T(s,i),e)}function u(e){return e.startsWith("$$")?`#node-config-input-${e.replace("$$","")}`:e.startsWith("$")?`#node-input-${e.replace("$","")}`:e}function B(e,r){let s=u(e),i=document.querySelector(s);if(!i)throw new Error(`Element with id '${e}' not found`);let[p,f]=createSignal(r||""),a=()=>{f(i.value);},l=t=>{i.value!==t&&(i.value=t);};return i.addEventListener("input",a),onCleanup(()=>{console.log("JE CLEAN"),i.removeEventListener("input",a);}),createEffect(()=>{l(p());}),f(i.value||r),[p,f]}var N={};function J(e){return P(N,e)}function j(e){return u(e).split("-input-")[1]}function z(e){function r(t){return e[t]}let s=(t,n,o)=>{let c=(o==null?void 0:o.selected)||r(j(t)),g=u(t),y=n;o!=null&&o.emptyValue&&(y=[{value:"",text:o.emptyValue},...n]),$(g).empty().append(y.map(b=>$("<option>",{value:b.value,text:b.text,selected:b.value===c})));},i=t=>{let n=t;return $(`#node-input-${n}`).val()};function p(t,n){let o=u(t);$(o).text(n);}function f(t){let n=u(t);return $(n)}function a(t,n){let o=u(t);$(o).val(n);}function l(t,n){let c=(Array.isArray(t)?t:[t]).map(u).join(", ");$(c).on("input",()=>{let g=$(c).map(function(){return $(this).val()}).get();n(g);});}return {getInputValue:i,watchInput:l,setText:p,setInputValue:a,jqSelector:f,initSelect:s}}export{J as createEditorNode,B as createReactiveField,z as domHelper,u as resolveSelector};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';
|
|
1
|
+
'use strict';
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as solid_js from 'solid-js';
|
|
2
2
|
import { NodeAPI } from 'node-red';
|
|
3
3
|
|
|
4
4
|
declare global {
|
|
5
5
|
var RED: NodeAPI;
|
|
6
6
|
}
|
|
7
|
-
declare
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
declare global {
|
|
8
|
+
var SolidJS: typeof solid_js;
|
|
9
|
+
}
|
|
10
|
+
declare global {
|
|
11
|
+
interface Window {
|
|
12
|
+
SolidJS: typeof solid_js;
|
|
13
|
+
}
|
|
14
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as solid_js from 'solid-js';
|
|
2
2
|
import { NodeAPI } from 'node-red';
|
|
3
3
|
|
|
4
4
|
declare global {
|
|
5
5
|
var RED: NodeAPI;
|
|
6
6
|
}
|
|
7
|
-
declare
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
declare global {
|
|
8
|
+
var SolidJS: typeof solid_js;
|
|
9
|
+
}
|
|
10
|
+
declare global {
|
|
11
|
+
interface Window {
|
|
12
|
+
SolidJS: typeof solid_js;
|
|
13
|
+
}
|
|
14
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var o=typeof global!="undefined"?global.RED:window.RED;export{o as _RED};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { NodeControllerConfig, NodeControllerInst } from '@keload/node-red-dxp/editor';
|
|
2
|
+
import type { Node{{nodePascalName}}Props } from './types';
|
|
3
|
+
|
|
4
|
+
export default function (this: NodeControllerInst<Node{{nodePascalName}}Props>, config: NodeControllerConfig<Node{{nodePascalName}}Props>) {
|
|
5
|
+
RED.nodes.createNode(this, config);
|
|
6
|
+
|
|
7
|
+
this.on('input', async (msg) => {
|
|
8
|
+
this.send({
|
|
9
|
+
payload: 'foo',
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Connects to a MQTT broker and publishes messages.
|
|
2
|
+
|
|
3
|
+
### Inputs
|
|
4
|
+
|
|
5
|
+
: payload (string | buffer) : the payload of the message to publish.
|
|
6
|
+
: *topic* (string) : the MQTT topic to publish to.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Outputs
|
|
10
|
+
|
|
11
|
+
1. Standard output
|
|
12
|
+
: payload (string) : the standard output of the command.
|
|
13
|
+
|
|
14
|
+
2. Standard error
|
|
15
|
+
: payload (string) : the standard error of the command.
|
|
16
|
+
|
|
17
|
+
### Details
|
|
18
|
+
|
|
19
|
+
`msg.payload` is used as the payload of the published message.
|
|
20
|
+
If it contains an Object it will be converted to a JSON string before being sent.
|
|
21
|
+
If it contains a binary Buffer the message will be published as-is.
|
|
22
|
+
|
|
23
|
+
The topic used can be configured in the node or, if left blank, can be set
|
|
24
|
+
`msg.topic`.
|
|
25
|
+
|
|
26
|
+
Likewise the QoS and retain values can be configured in the node or, if left
|
|
27
|
+
blank, set by `msg.qos` and `msg.retain` respectively.
|
|
28
|
+
|
|
29
|
+
### References
|
|
30
|
+
|
|
31
|
+
- [Twitter API docs]() - full description of `msg.tweet` property
|
|
32
|
+
- [GitHub]() - the nodes github repository
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<div class="form-row">
|
|
2
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
3
|
+
<input type="text" id="node-input-name" placeholder="custom name"/>
|
|
4
|
+
</div>
|
|
5
|
+
<div class="form-row">
|
|
6
|
+
<label for="node-input-age" ><i class="fa fa-tag"></i> Age</label>
|
|
7
|
+
<input type="text" id="node-input-age" placeholder="enter age"/>
|
|
8
|
+
</div>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type NodeEditorProps, createEditorNode, domHelper } from '@keload/node-red-dxp/editor';
|
|
2
|
+
import type { Node{{nodePascalName}}Props } from '../types';
|
|
3
|
+
|
|
4
|
+
const {{nodePascalName}} = createEditorNode<NodeEditorProps<Node{{nodePascalName}}Props>>({
|
|
5
|
+
category: 'my_cat',
|
|
6
|
+
color: '#a6bbcf',
|
|
7
|
+
defaults: {
|
|
8
|
+
name: { value: '', required: true },
|
|
9
|
+
age: { value: '' },
|
|
10
|
+
},
|
|
11
|
+
inputs: 1,
|
|
12
|
+
outputs: 1,
|
|
13
|
+
icon: 'font-awesome/fa-tower-broadcast',
|
|
14
|
+
label: function () {
|
|
15
|
+
return this.name || '{{nodePascalName}}';
|
|
16
|
+
},
|
|
17
|
+
oneditprepare: function () {
|
|
18
|
+
const { watchInput } = domHelper<Node{{nodePascalName}}Props>(this);
|
|
19
|
+
// $age == #node-input-age in DOM
|
|
20
|
+
watchInput('$age', ([ageValue]) => {
|
|
21
|
+
console.log('ageValue', ageValue);
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export default {{nodePascalName}};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keload/node-red-dxp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -10,7 +10,10 @@
|
|
|
10
10
|
"lint": "pnpm biome lint",
|
|
11
11
|
"lint:check": "pnpm biome check",
|
|
12
12
|
"release": "pnpm release-it",
|
|
13
|
-
"release:test": "pnpm release-it --dry-run"
|
|
13
|
+
"release:test": "pnpm release-it --dry-run",
|
|
14
|
+
"docs:dev": "vitepress dev docs",
|
|
15
|
+
"docs:build": "vitepress build docs",
|
|
16
|
+
"docs:preview": "vitepress preview docs"
|
|
14
17
|
},
|
|
15
18
|
"publishConfig": {
|
|
16
19
|
"access": "public"
|
|
@@ -47,32 +50,39 @@
|
|
|
47
50
|
"devDependencies": {
|
|
48
51
|
"@biomejs/biome": "1.9.4",
|
|
49
52
|
"@release-it/conventional-changelog": "9.0.3",
|
|
53
|
+
"@types/handlebars": "4.1.0",
|
|
50
54
|
"release-it": "17.10.0",
|
|
51
55
|
"tsup": "8.3.5",
|
|
52
56
|
"tsx": "4.19.2",
|
|
53
|
-
"typescript": "5.6.3"
|
|
57
|
+
"typescript": "5.6.3",
|
|
58
|
+
"vitepress": "1.5.0"
|
|
54
59
|
},
|
|
55
60
|
"dependencies": {
|
|
61
|
+
"@fullhuman/postcss-purgecss": "^6.0.0",
|
|
56
62
|
"@types/html-minifier-terser": "7.0.2",
|
|
57
63
|
"@types/jquery": "3.5.32",
|
|
58
64
|
"@types/jqueryui": "1.12.23",
|
|
59
65
|
"@types/node-red": "1.3.5",
|
|
60
66
|
"@types/prettyjson": "0.0.33",
|
|
67
|
+
"autoprefixer": "^10.4.20",
|
|
61
68
|
"browser-sync": "3.0.3",
|
|
62
69
|
"chokidar": "4.0.1",
|
|
63
70
|
"commander": "12.1.0",
|
|
64
71
|
"consola": "3.2.3",
|
|
65
72
|
"cosmiconfig": "9.0.0",
|
|
66
|
-
"
|
|
73
|
+
"cssnano": "^7.0.6",
|
|
67
74
|
"esbuild": "0.24.0",
|
|
68
75
|
"glob": "11.0.0",
|
|
69
76
|
"handlebars": "4.7.8",
|
|
70
77
|
"html-minifier-terser": "7.2.0",
|
|
71
78
|
"merge-anything": "6.0.2",
|
|
72
79
|
"nodemon": "3.1.7",
|
|
80
|
+
"postcss": "^8.4.49",
|
|
73
81
|
"prettyjson": "1.2.5",
|
|
74
82
|
"radash": "12.1.0",
|
|
75
|
-
"sass": "1.81.0"
|
|
83
|
+
"sass": "1.81.0",
|
|
84
|
+
"solid-js": "1.9.3",
|
|
85
|
+
"tailwindcss": "^3.4.15"
|
|
76
86
|
},
|
|
77
87
|
"files": [
|
|
78
88
|
"dist"
|
|
@@ -1,182 +0,0 @@
|
|
|
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
|
-
|