@keload/node-red-dxp 1.3.0 → 1.3.2
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 +31 -26
- package/dist/builder/index.d.cts +69 -35
- package/dist/builder/index.d.ts +69 -35
- package/dist/builder/index.js +31 -26
- package/dist/cli/index.cjs +31 -26
- 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/package.json +15 -6
- 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,51 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var W=require('fs'),cosmiconfig=require('cosmiconfig'),glob=require('glob'),radash=require('radash'),M=require('path'),H=require('esbuild'),htmlMinifierTerser=require('html-minifier-terser'),C=require('fs/promises'),$e=require('@fullhuman/postcss-purgecss'),Se=require('autoprefixer'),Pe=require('cssnano'),V=require('postcss'),U=require('sass'),we=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 W__default=/*#__PURE__*/_interopDefault(W);var M__default=/*#__PURE__*/_interopDefault(M);var H__default=/*#__PURE__*/_interopDefault(H);var C__default=/*#__PURE__*/_interopDefault(C);var $e__default=/*#__PURE__*/_interopDefault($e);var Se__default=/*#__PURE__*/_interopDefault(Se);var Pe__default=/*#__PURE__*/_interopDefault(Pe);var V__default=/*#__PURE__*/_interopDefault(V);var U__namespace=/*#__PURE__*/_interopNamespace(U);var we__default=/*#__PURE__*/_interopDefault(we);var Z=Object.defineProperty;var j=Object.getOwnPropertySymbols;var ee=Object.prototype.hasOwnProperty,te=Object.prototype.propertyIsEnumerable;var I=(e,t,r)=>t in e?Z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))ee.call(t,r)&&I(e,r,t[r]);if(j)for(var r of j(t))te.call(t,r)&&I(e,r,t[r]);return e};var re=(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 i=(e,t,r)=>new Promise((o,s)=>{var n=l=>{try{c(r.next(l));}catch(a){s(a);}},m=l=>{try{c(r.throw(l));}catch(a){s(a);}},c=l=>l.done?o(l.value):Promise.resolve(l.value).then(n,m);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 b(e){return N(e)==="Symbol"}function O(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 v(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((a,p)=>{let S=e[p];return (!b(p)&&!Object.getOwnPropertyNames(t).includes(p)||b(p)&&!Object.getOwnPropertySymbols(t).includes(p))&&O(a,p,S,e),a},{});}let s=Object.getOwnPropertyNames(t),n=Object.getOwnPropertySymbols(t);return [...s,...n].reduce((c,l)=>{let a=t[l],p=x(e)?e[l]:void 0;p!==void 0&&x(a)&&(a=v(p,a));let S=a;return O(c,l,S,t),c},o)}function E(e,...t){return t.reduce((r,o)=>v(r,o),e)}var A={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 le="node-red-dx",ae=e=>e.replace("@","").replace("/","-");function ce(){let e=cosmiconfig.cosmiconfigSync(le);try{let t=e.search();return E(A,t?t.config:{})}catch(t){throw console.error("Error while loading configuration",t),t}}var f=ce(),g=process.cwd(),L=JSON.parse(W.readFileSync(`${g}/package.json`,"utf-8")),w=`${g}/${f.srcDir}`,me=`${g}/resources`,$=`${w}/${f.nodesDirName}`,F=`${g}/${f.libCacheDir}`;function pe(){return glob.globSync(`${$}/*`,{withFileTypes:!0}).map(t=>{let r=t.fullpath(),o=`${r}/${f.nodes.editor.dirName}`,s=r.replace(g,"").slice(1),n=`${s}/${f.nodes.editor.dirName}`,m=glob.globSync(`${o}/**/*.scss`),c=glob.globSync(`${r}/doc.mdx`),l=glob.globSync(`${r}/doc.md`),a=radash.dash(t.name);return {fullEditorPath:o,fullPath:r,name:t.name,pascalName:radash.pascal(t.name),dashName:a,relativeEditorPath:n,relativePath:s,nodeIdentifier:`${d.packageNameSlug}-${a}`,fullControllerPath:`${r}/${f.nodes.controllerName}.ts`,editor:{tsPath:`${o}/${f.nodes.editor.tsName}.ts`,htmlPath:`${o}/${f.nodes.editor.htmlName}.html`,scssFiles:m},doc:{mdxFiles:c,mdFiles:l}}})}function D(){return {currentDir:g,pathSrcDir:w,pathSrcNodesDir:$,additionalResourcesDir:me,pathDist:`${g}/${f.builder.outputDir}`,cacheDirFiles:{controllerIndex:`${F}/controller-index.ts`,editorIndex:`${F}/editor-index.ts`},pathLibCacheDir:F,packageName:L.name,packageNameSlug:ae(L.name),config:f,getResolvedSrcPathsScss:()=>glob.globSync(`${w}/**/*.scss`,{ignore:`${$}/**/*.scss`}),getResolvedNodesPaths:()=>glob.globSync(`${$}/*`),getListNodesFull:()=>pe()}}var d=D();function R(e=!1){return i(this,null,function*(){return H__default.default.build({entryPoints:[d.cacheDirFiles.controllerIndex],outfile:`${d.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 T(e=!1){return i(this,null,function*(){let t=yield H__default.default.build({entryPoints:[d.cacheDirFiles.editorIndex],bundle:!0,platform:"browser",format:"iife",target:"es6",sourcemap:!1,minify:e,minifyWhitespace:e,minifySyntax:e,minifyIdentifiers:e,legalComments:"none",inject:[M__default.default.resolve(__dirname,"..","./editor/global-solid.ts")],write:!1,loader:{".ts":"ts"}});return t.outputFiles&&t.outputFiles.length>0?t.outputFiles[0].text:""})}function k(){let e=d.getListNodesFull(),t=[];for(let r of e)if(r.doc.mdFiles[0]){let s=W__default.default.readFileSync(r.doc.mdFiles[0],"utf-8"),n=`
|
|
2
|
+
<script type="text/markdown" data-help-name="${r.name}">
|
|
3
|
+
${s}
|
|
4
|
+
</script>
|
|
5
|
+
`;t.push(n);}return t.length?t.join(`
|
|
6
|
+
`):""}function _(e){return e.trim().replace(/\n\s+/g,"")}function G(e){return i(this,null,function*(){for(let t of e)try{let r=M__default.default.resolve(t),o=yield C__default.default.stat(r).catch(()=>null);o!=null&&o.isDirectory()?(yield C__default.default.rm(r,{recursive:!0,force:!0}),console.log(`Successfully cleaned: ${r}`)):console.log(`Path does not exist or is not a directory: ${r}`);}catch(r){console.error(`Error cleaning path (${t}): ${r}`);}})}function B(e){let t=M__default.default.resolve(e);W__default.default.existsSync(t)||W__default.default.mkdirSync(t,{recursive:!0});}function h(e,t){return i(this,null,function*(){try{yield C__default.default.writeFile(e,t);}catch(r){console.error("Error writing controller index:",r);}})}function xe(e){return i(this,null,function*(){return htmlMinifierTerser.minify(e,{collapseWhitespace:!0,removeComments:!0,removeRedundantAttributes:!1,useShortDoctype:!0,removeEmptyAttributes:!1,minifyCSS:!1,minifyJS:!1})})}function ye(e,t){return `
|
|
2
7
|
<script type="text/html" data-template-name="${e}">
|
|
3
|
-
|
|
4
|
-
<div class="${t}">${o}</div>
|
|
5
|
-
</div>
|
|
8
|
+
${t}
|
|
6
9
|
</script>
|
|
7
|
-
`}function
|
|
8
|
-
<
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
`}function he(e,t,r=!1){return i(this,null,function*(){let o=W.readFileSync(e.editor.htmlPath,"utf8"),s=`
|
|
11
|
+
<div class="${t}">
|
|
12
|
+
<div class="${e.nodeIdentifier}">${o}</div>
|
|
13
|
+
</div>
|
|
14
|
+
`,n=r?yield xe(s):s,m=ye(e.name,n);return {nodeName:e.name,nodeIdentifier:e.nodeIdentifier,html:n,wrappedHtml:m}})}function J(e){return i(this,null,function*(){let{nodes:t,minify:r=!1}=e,o=yield Promise.all(t.map(n=>he(n,e.packageNameSlug,r)));return {html:o.map(n=>n.html).join("").trim(),allWrappedHtml:o.map(n=>r?_(n.wrappedHtml):n.wrappedHtml).join("").trim()}})}function De(e,t){return i(this,null,function*(){return (yield V__default.default([$e__default.default({content:[{raw:t,extension:"html"}]}),Se__default.default,Pe__default.default({preset:"default"})]).process(e,{from:void 0})).css})}function Ce(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]=Ce(o);}return t}function je(e){return e.some(r=>r.editor.scssFiles.length)?e.filter(r=>r.editor.scssFiles.length).map(r=>{let o=q(r.editor.scssFiles),s=Object.values(o).join("");return {name:r.name,mergedCompiledStyles:s,scssFinal:`
|
|
15
|
+
#${r.nodeIdentifier}{
|
|
16
|
+
${s}
|
|
17
|
+
}`}}):[]}function Ie(r){return i(this,arguments,function*(e,t={}){let s=P(P({},{content:[{raw:e}],theme:{}}),t),n=glob.globSync(`${M__default.default.resolve(__dirname,"..")}/${d.config.nodes.editor.dirName}/assets/tailwind.scss`)[0],m=n.length?W__default.default.readFileSync(n,"utf8"):"";return (yield V__default.default([we__default.default(s),re("autoprefixer")]).process(m,{from:void 0})).css})}function Oe(){let e=d.getResolvedSrcPathsScss(),t=q([...e]);return Object.values(t).join("")}function z(e){return i(this,null,function*(){let{rawHtml:t,minify:r=!1,nodes:o}=e||{},s=Oe(),n=je(o),m=yield Ie(t),c=p=>`.${d.packageNameSlug}{${p}}`,l=n.map(p=>p.scssFinal).join(`
|
|
18
|
+
`),a=c(`${m}${s}${l}`);return r?De(a,t):a})}function K(e){return i(this,null,function*(){let{minify:t=!1}=e||{},r=yield J({minify:t,nodes:e.nodes,packageNameSlug:d.packageNameSlug}),o=yield T(t),s=yield z({rawHtml:r.html,minify:t,nodes:e.nodes}),n=k(),m=`<script type="application/javascript">${o.trim()}</script>`,c=`<style>${s}</style>`;return `
|
|
19
|
+
${r.allWrappedHtml}
|
|
20
|
+
${c}
|
|
21
|
+
${m}
|
|
22
|
+
${n}`.trim()})}var Q=`
|
|
13
23
|
// generated by @keload/node-red-dev-xp
|
|
14
24
|
// do not modify this file
|
|
15
25
|
// do not commit this file
|
|
16
|
-
`;function
|
|
17
|
-
${
|
|
26
|
+
`;function X(e){return i(this,null,function*(){return `
|
|
27
|
+
${Q}
|
|
18
28
|
import type { NodeAPI } from 'node-red';
|
|
19
|
-
${
|
|
29
|
+
${e.map(t=>`import ${t.pascalName} from '${t.fullControllerPath}';`).join(`
|
|
20
30
|
`)}
|
|
21
31
|
|
|
22
32
|
|
|
23
33
|
export default async (RED: NodeAPI): Promise<void> => {
|
|
24
34
|
global.RED = RED;
|
|
25
35
|
|
|
26
|
-
${
|
|
27
|
-
global.RED.nodes.registerType('${
|
|
36
|
+
${e.map(t=>`// @ts-ignore
|
|
37
|
+
global.RED.nodes.registerType('${t.name}', ${t.pascalName});`).join(`
|
|
28
38
|
`)}
|
|
29
39
|
};
|
|
30
|
-
`.trim()}function
|
|
31
|
-
${
|
|
40
|
+
`.trim()})}function Y(e){return i(this,null,function*(){return `
|
|
41
|
+
${Q}
|
|
32
42
|
import type { NodeAPI } from 'node-red';
|
|
33
|
-
${
|
|
43
|
+
${e.map(t=>`import ${t.pascalName} from '${t.editor.tsPath}';`).join(`
|
|
34
44
|
`)}
|
|
35
45
|
|
|
36
46
|
declare const RED: NodeAPI;
|
|
37
47
|
|
|
38
|
-
${
|
|
39
|
-
window.RED.nodes.registerType('${
|
|
48
|
+
${e.map(t=>`// @ts-ignore
|
|
49
|
+
window.RED.nodes.registerType('${t.name}', ${t.pascalName});`).join(`
|
|
40
50
|
`)}
|
|
41
|
-
`.trim()}function
|
|
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;
|
|
51
|
+
`.trim()})}var u=D();function Wt(e){return i(this,null,function*(){let{minify:t=!1}=e||{},r=u.getListNodesFull();B(u.pathLibCacheDir),yield G([u.pathDist]);let o=X(r).then(n=>{h(`${u.cacheDirFiles.controllerIndex}`,n).then(()=>{R(t);});}),s=Y(r).then(n=>{h(`${u.cacheDirFiles.editorIndex}`,n).then(()=>{K({minify:t,nodes:r}).then(m=>i(this,null,function*(){yield h(`${u.pathDist}/index.html`,m);}));});});yield Promise.all([o,s,h(`${u.pathLibCacheDir}/config.json`,JSON.stringify(u.config,null,2))]);})}exports.buildAllPackage=Wt;exports.buildFinalDistIndexContent=K;exports.currentInstance=u;exports.generateCSSFromHTMLWithTailwind=Ie;exports.getAllCompiledStyles=z;exports.getControllerIndexContent=X;exports.getEditorIndexContent=Y;exports.getNodesHtml=J;exports.getNodesStyles=je;exports.getSrcStyles=Oe;exports.handleAllDoc=k;exports.minifyHtml=xe;
|
package/dist/builder/index.d.cts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import esbuild from 'esbuild';
|
|
2
|
-
|
|
3
1
|
type Config = {
|
|
4
2
|
libCacheDir: string;
|
|
5
3
|
srcDir: string;
|
|
@@ -24,7 +22,7 @@ type Config = {
|
|
|
24
22
|
};
|
|
25
23
|
};
|
|
26
24
|
|
|
27
|
-
declare const currentInstance: {
|
|
25
|
+
declare const currentInstance$1: {
|
|
28
26
|
currentDir: string;
|
|
29
27
|
pathSrcDir: string;
|
|
30
28
|
pathSrcNodesDir: string;
|
|
@@ -61,49 +59,85 @@ declare const currentInstance: {
|
|
|
61
59
|
};
|
|
62
60
|
}[];
|
|
63
61
|
};
|
|
62
|
+
type ListNodesFull = ReturnType<typeof currentInstance$1.getListNodesFull>;
|
|
64
63
|
|
|
65
|
-
declare function
|
|
66
|
-
declare function
|
|
67
|
-
declare function writeControllerIndex(): void;
|
|
68
|
-
declare function writeEditorIndex(): void;
|
|
64
|
+
declare function getControllerIndexContent(nodes: ListNodesFull): Promise<string>;
|
|
65
|
+
declare function getEditorIndexContent(nodes: ListNodesFull): Promise<string>;
|
|
69
66
|
|
|
70
|
-
declare function getNodesStyles(): {
|
|
67
|
+
declare function getNodesStyles(nodes: ListNodesFull): {
|
|
71
68
|
name: string;
|
|
72
|
-
styles: Record<string, string>;
|
|
73
69
|
mergedCompiledStyles: string;
|
|
74
70
|
scssFinal: string;
|
|
75
|
-
hasStyles: boolean;
|
|
76
71
|
}[];
|
|
72
|
+
declare function generateCSSFromHTMLWithTailwind(htmlString: string, tailwindConfig?: any): Promise<string>;
|
|
77
73
|
declare function getSrcStyles(): string;
|
|
78
|
-
|
|
74
|
+
type GetAllCompiledStylesParams = {
|
|
75
|
+
rawHtml: string;
|
|
76
|
+
minify?: boolean;
|
|
77
|
+
nodes: ListNodesFull;
|
|
78
|
+
};
|
|
79
|
+
declare function getAllCompiledStyles(params: GetAllCompiledStylesParams): Promise<string>;
|
|
79
80
|
|
|
80
|
-
declare function
|
|
81
|
-
|
|
81
|
+
declare function minifyHtml(content: string): Promise<string>;
|
|
82
|
+
type GetNodesHtmlParams = {
|
|
83
|
+
nodes: ListNodesFull;
|
|
84
|
+
minify?: boolean;
|
|
85
|
+
packageNameSlug: string;
|
|
86
|
+
};
|
|
87
|
+
declare function getNodesHtml(params: GetNodesHtmlParams): Promise<{
|
|
88
|
+
html: string;
|
|
89
|
+
allWrappedHtml: string;
|
|
90
|
+
}>;
|
|
82
91
|
|
|
83
|
-
declare function buildFinalDistIndexContent(
|
|
84
|
-
|
|
92
|
+
declare function buildFinalDistIndexContent(params?: WriteFinalDistIndexContentParams): Promise<string>;
|
|
93
|
+
type WriteFinalDistIndexContentParams = {
|
|
94
|
+
minify?: boolean;
|
|
95
|
+
nodes: ListNodesFull;
|
|
96
|
+
};
|
|
85
97
|
|
|
86
98
|
declare function handleAllDoc(): string;
|
|
87
99
|
|
|
88
|
-
declare
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
format: "cjs";
|
|
98
|
-
target: string;
|
|
99
|
-
loader: {
|
|
100
|
-
'.ts': "ts";
|
|
100
|
+
declare const currentInstance: {
|
|
101
|
+
currentDir: string;
|
|
102
|
+
pathSrcDir: string;
|
|
103
|
+
pathSrcNodesDir: string;
|
|
104
|
+
additionalResourcesDir: string;
|
|
105
|
+
pathDist: string;
|
|
106
|
+
cacheDirFiles: {
|
|
107
|
+
controllerIndex: string;
|
|
108
|
+
editorIndex: string;
|
|
101
109
|
};
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
110
|
+
pathLibCacheDir: string;
|
|
111
|
+
packageName: any;
|
|
112
|
+
packageNameSlug: string;
|
|
113
|
+
config: Config;
|
|
114
|
+
getResolvedSrcPathsScss: () => string[];
|
|
115
|
+
getResolvedNodesPaths: () => string[];
|
|
116
|
+
getListNodesFull: () => {
|
|
117
|
+
fullEditorPath: string;
|
|
118
|
+
fullPath: string;
|
|
119
|
+
name: string;
|
|
120
|
+
pascalName: string;
|
|
121
|
+
dashName: string;
|
|
122
|
+
relativeEditorPath: string;
|
|
123
|
+
relativePath: string;
|
|
124
|
+
nodeIdentifier: string;
|
|
125
|
+
fullControllerPath: string;
|
|
126
|
+
editor: {
|
|
127
|
+
tsPath: string;
|
|
128
|
+
htmlPath: string;
|
|
129
|
+
scssFiles: string[];
|
|
130
|
+
};
|
|
131
|
+
doc: {
|
|
132
|
+
mdxFiles: string[];
|
|
133
|
+
mdFiles: string[];
|
|
134
|
+
};
|
|
135
|
+
}[];
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
type BuildAllPackageParams = {
|
|
139
|
+
minify?: boolean;
|
|
140
|
+
};
|
|
141
|
+
declare function buildAllPackage(params?: BuildAllPackageParams): Promise<void>;
|
|
108
142
|
|
|
109
|
-
export { buildAllPackage, buildFinalDistIndexContent,
|
|
143
|
+
export { buildAllPackage, buildFinalDistIndexContent, currentInstance, generateCSSFromHTMLWithTailwind, getAllCompiledStyles, getControllerIndexContent, getEditorIndexContent, getNodesHtml, getNodesStyles, getSrcStyles, handleAllDoc, minifyHtml };
|
package/dist/builder/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import esbuild from 'esbuild';
|
|
2
|
-
|
|
3
1
|
type Config = {
|
|
4
2
|
libCacheDir: string;
|
|
5
3
|
srcDir: string;
|
|
@@ -24,7 +22,7 @@ type Config = {
|
|
|
24
22
|
};
|
|
25
23
|
};
|
|
26
24
|
|
|
27
|
-
declare const currentInstance: {
|
|
25
|
+
declare const currentInstance$1: {
|
|
28
26
|
currentDir: string;
|
|
29
27
|
pathSrcDir: string;
|
|
30
28
|
pathSrcNodesDir: string;
|
|
@@ -61,49 +59,85 @@ declare const currentInstance: {
|
|
|
61
59
|
};
|
|
62
60
|
}[];
|
|
63
61
|
};
|
|
62
|
+
type ListNodesFull = ReturnType<typeof currentInstance$1.getListNodesFull>;
|
|
64
63
|
|
|
65
|
-
declare function
|
|
66
|
-
declare function
|
|
67
|
-
declare function writeControllerIndex(): void;
|
|
68
|
-
declare function writeEditorIndex(): void;
|
|
64
|
+
declare function getControllerIndexContent(nodes: ListNodesFull): Promise<string>;
|
|
65
|
+
declare function getEditorIndexContent(nodes: ListNodesFull): Promise<string>;
|
|
69
66
|
|
|
70
|
-
declare function getNodesStyles(): {
|
|
67
|
+
declare function getNodesStyles(nodes: ListNodesFull): {
|
|
71
68
|
name: string;
|
|
72
|
-
styles: Record<string, string>;
|
|
73
69
|
mergedCompiledStyles: string;
|
|
74
70
|
scssFinal: string;
|
|
75
|
-
hasStyles: boolean;
|
|
76
71
|
}[];
|
|
72
|
+
declare function generateCSSFromHTMLWithTailwind(htmlString: string, tailwindConfig?: any): Promise<string>;
|
|
77
73
|
declare function getSrcStyles(): string;
|
|
78
|
-
|
|
74
|
+
type GetAllCompiledStylesParams = {
|
|
75
|
+
rawHtml: string;
|
|
76
|
+
minify?: boolean;
|
|
77
|
+
nodes: ListNodesFull;
|
|
78
|
+
};
|
|
79
|
+
declare function getAllCompiledStyles(params: GetAllCompiledStylesParams): Promise<string>;
|
|
79
80
|
|
|
80
|
-
declare function
|
|
81
|
-
|
|
81
|
+
declare function minifyHtml(content: string): Promise<string>;
|
|
82
|
+
type GetNodesHtmlParams = {
|
|
83
|
+
nodes: ListNodesFull;
|
|
84
|
+
minify?: boolean;
|
|
85
|
+
packageNameSlug: string;
|
|
86
|
+
};
|
|
87
|
+
declare function getNodesHtml(params: GetNodesHtmlParams): Promise<{
|
|
88
|
+
html: string;
|
|
89
|
+
allWrappedHtml: string;
|
|
90
|
+
}>;
|
|
82
91
|
|
|
83
|
-
declare function buildFinalDistIndexContent(
|
|
84
|
-
|
|
92
|
+
declare function buildFinalDistIndexContent(params?: WriteFinalDistIndexContentParams): Promise<string>;
|
|
93
|
+
type WriteFinalDistIndexContentParams = {
|
|
94
|
+
minify?: boolean;
|
|
95
|
+
nodes: ListNodesFull;
|
|
96
|
+
};
|
|
85
97
|
|
|
86
98
|
declare function handleAllDoc(): string;
|
|
87
99
|
|
|
88
|
-
declare
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
format: "cjs";
|
|
98
|
-
target: string;
|
|
99
|
-
loader: {
|
|
100
|
-
'.ts': "ts";
|
|
100
|
+
declare const currentInstance: {
|
|
101
|
+
currentDir: string;
|
|
102
|
+
pathSrcDir: string;
|
|
103
|
+
pathSrcNodesDir: string;
|
|
104
|
+
additionalResourcesDir: string;
|
|
105
|
+
pathDist: string;
|
|
106
|
+
cacheDirFiles: {
|
|
107
|
+
controllerIndex: string;
|
|
108
|
+
editorIndex: string;
|
|
101
109
|
};
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
110
|
+
pathLibCacheDir: string;
|
|
111
|
+
packageName: any;
|
|
112
|
+
packageNameSlug: string;
|
|
113
|
+
config: Config;
|
|
114
|
+
getResolvedSrcPathsScss: () => string[];
|
|
115
|
+
getResolvedNodesPaths: () => string[];
|
|
116
|
+
getListNodesFull: () => {
|
|
117
|
+
fullEditorPath: string;
|
|
118
|
+
fullPath: string;
|
|
119
|
+
name: string;
|
|
120
|
+
pascalName: string;
|
|
121
|
+
dashName: string;
|
|
122
|
+
relativeEditorPath: string;
|
|
123
|
+
relativePath: string;
|
|
124
|
+
nodeIdentifier: string;
|
|
125
|
+
fullControllerPath: string;
|
|
126
|
+
editor: {
|
|
127
|
+
tsPath: string;
|
|
128
|
+
htmlPath: string;
|
|
129
|
+
scssFiles: string[];
|
|
130
|
+
};
|
|
131
|
+
doc: {
|
|
132
|
+
mdxFiles: string[];
|
|
133
|
+
mdFiles: string[];
|
|
134
|
+
};
|
|
135
|
+
}[];
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
type BuildAllPackageParams = {
|
|
139
|
+
minify?: boolean;
|
|
140
|
+
};
|
|
141
|
+
declare function buildAllPackage(params?: BuildAllPackageParams): Promise<void>;
|
|
108
142
|
|
|
109
|
-
export { buildAllPackage, buildFinalDistIndexContent,
|
|
143
|
+
export { buildAllPackage, buildFinalDistIndexContent, currentInstance, generateCSSFromHTMLWithTailwind, getAllCompiledStyles, getControllerIndexContent, getEditorIndexContent, getNodesHtml, getNodesStyles, getSrcStyles, handleAllDoc, minifyHtml };
|
package/dist/builder/index.js
CHANGED
|
@@ -1,46 +1,51 @@
|
|
|
1
|
-
import
|
|
1
|
+
import W,{readFileSync}from'node:fs';import {cosmiconfigSync}from'cosmiconfig';import {globSync}from'glob';import {dash,pascal}from'radash';import M from'node:path';import H from'esbuild';import {minify}from'html-minifier-terser';import C from'node:fs/promises';import $e from'@fullhuman/postcss-purgecss';import Se from'autoprefixer';import Pe from'cssnano';import V from'postcss';import*as U from'sass';import we from'tailwindcss';var Z=Object.defineProperty;var j=Object.getOwnPropertySymbols;var ee=Object.prototype.hasOwnProperty,te=Object.prototype.propertyIsEnumerable;var I=(e,t,r)=>t in e?Z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))ee.call(t,r)&&I(e,r,t[r]);if(j)for(var r of j(t))te.call(t,r)&&I(e,r,t[r]);return e};var re=(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 i=(e,t,r)=>new Promise((o,s)=>{var n=l=>{try{c(r.next(l));}catch(a){s(a);}},m=l=>{try{c(r.throw(l));}catch(a){s(a);}},c=l=>l.done?o(l.value):Promise.resolve(l.value).then(n,m);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 b(e){return N(e)==="Symbol"}function O(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 v(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((a,p)=>{let S=e[p];return (!b(p)&&!Object.getOwnPropertyNames(t).includes(p)||b(p)&&!Object.getOwnPropertySymbols(t).includes(p))&&O(a,p,S,e),a},{});}let s=Object.getOwnPropertyNames(t),n=Object.getOwnPropertySymbols(t);return [...s,...n].reduce((c,l)=>{let a=t[l],p=x(e)?e[l]:void 0;p!==void 0&&x(a)&&(a=v(p,a));let S=a;return O(c,l,S,t),c},o)}function E(e,...t){return t.reduce((r,o)=>v(r,o),e)}var A={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 le="node-red-dx",ae=e=>e.replace("@","").replace("/","-");function ce(){let e=cosmiconfigSync(le);try{let t=e.search();return E(A,t?t.config:{})}catch(t){throw console.error("Error while loading configuration",t),t}}var f=ce(),g=process.cwd(),L=JSON.parse(readFileSync(`${g}/package.json`,"utf-8")),w=`${g}/${f.srcDir}`,me=`${g}/resources`,$=`${w}/${f.nodesDirName}`,F=`${g}/${f.libCacheDir}`;function pe(){return globSync(`${$}/*`,{withFileTypes:!0}).map(t=>{let r=t.fullpath(),o=`${r}/${f.nodes.editor.dirName}`,s=r.replace(g,"").slice(1),n=`${s}/${f.nodes.editor.dirName}`,m=globSync(`${o}/**/*.scss`),c=globSync(`${r}/doc.mdx`),l=globSync(`${r}/doc.md`),a=dash(t.name);return {fullEditorPath:o,fullPath:r,name:t.name,pascalName:pascal(t.name),dashName:a,relativeEditorPath:n,relativePath:s,nodeIdentifier:`${d.packageNameSlug}-${a}`,fullControllerPath:`${r}/${f.nodes.controllerName}.ts`,editor:{tsPath:`${o}/${f.nodes.editor.tsName}.ts`,htmlPath:`${o}/${f.nodes.editor.htmlName}.html`,scssFiles:m},doc:{mdxFiles:c,mdFiles:l}}})}function D(){return {currentDir:g,pathSrcDir:w,pathSrcNodesDir:$,additionalResourcesDir:me,pathDist:`${g}/${f.builder.outputDir}`,cacheDirFiles:{controllerIndex:`${F}/controller-index.ts`,editorIndex:`${F}/editor-index.ts`},pathLibCacheDir:F,packageName:L.name,packageNameSlug:ae(L.name),config:f,getResolvedSrcPathsScss:()=>globSync(`${w}/**/*.scss`,{ignore:`${$}/**/*.scss`}),getResolvedNodesPaths:()=>globSync(`${$}/*`),getListNodesFull:()=>pe()}}var d=D();function R(e=!1){return i(this,null,function*(){return H.build({entryPoints:[d.cacheDirFiles.controllerIndex],outfile:`${d.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 T(e=!1){return i(this,null,function*(){let t=yield H.build({entryPoints:[d.cacheDirFiles.editorIndex],bundle:!0,platform:"browser",format:"iife",target:"es6",sourcemap:!1,minify:e,minifyWhitespace:e,minifySyntax:e,minifyIdentifiers:e,legalComments:"none",inject:[M.resolve(__dirname,"..","./editor/global-solid.ts")],write:!1,loader:{".ts":"ts"}});return t.outputFiles&&t.outputFiles.length>0?t.outputFiles[0].text:""})}function k(){let e=d.getListNodesFull(),t=[];for(let r of e)if(r.doc.mdFiles[0]){let s=W.readFileSync(r.doc.mdFiles[0],"utf-8"),n=`
|
|
2
|
+
<script type="text/markdown" data-help-name="${r.name}">
|
|
3
|
+
${s}
|
|
4
|
+
</script>
|
|
5
|
+
`;t.push(n);}return t.length?t.join(`
|
|
6
|
+
`):""}function _(e){return e.trim().replace(/\n\s+/g,"")}function G(e){return i(this,null,function*(){for(let t of e)try{let r=M.resolve(t),o=yield C.stat(r).catch(()=>null);o!=null&&o.isDirectory()?(yield C.rm(r,{recursive:!0,force:!0}),console.log(`Successfully cleaned: ${r}`)):console.log(`Path does not exist or is not a directory: ${r}`);}catch(r){console.error(`Error cleaning path (${t}): ${r}`);}})}function B(e){let t=M.resolve(e);W.existsSync(t)||W.mkdirSync(t,{recursive:!0});}function h(e,t){return i(this,null,function*(){try{yield C.writeFile(e,t);}catch(r){console.error("Error writing controller index:",r);}})}function xe(e){return i(this,null,function*(){return minify(e,{collapseWhitespace:!0,removeComments:!0,removeRedundantAttributes:!1,useShortDoctype:!0,removeEmptyAttributes:!1,minifyCSS:!1,minifyJS:!1})})}function ye(e,t){return `
|
|
2
7
|
<script type="text/html" data-template-name="${e}">
|
|
3
|
-
|
|
4
|
-
<div class="${t}">${o}</div>
|
|
5
|
-
</div>
|
|
8
|
+
${t}
|
|
6
9
|
</script>
|
|
7
|
-
`}function
|
|
8
|
-
<
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
`}function he(e,t,r=!1){return i(this,null,function*(){let o=readFileSync(e.editor.htmlPath,"utf8"),s=`
|
|
11
|
+
<div class="${t}">
|
|
12
|
+
<div class="${e.nodeIdentifier}">${o}</div>
|
|
13
|
+
</div>
|
|
14
|
+
`,n=r?yield xe(s):s,m=ye(e.name,n);return {nodeName:e.name,nodeIdentifier:e.nodeIdentifier,html:n,wrappedHtml:m}})}function J(e){return i(this,null,function*(){let{nodes:t,minify:r=!1}=e,o=yield Promise.all(t.map(n=>he(n,e.packageNameSlug,r)));return {html:o.map(n=>n.html).join("").trim(),allWrappedHtml:o.map(n=>r?_(n.wrappedHtml):n.wrappedHtml).join("").trim()}})}function De(e,t){return i(this,null,function*(){return (yield V([$e({content:[{raw:t,extension:"html"}]}),Se,Pe({preset:"default"})]).process(e,{from:void 0})).css})}function Ce(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]=Ce(o);}return t}function je(e){return e.some(r=>r.editor.scssFiles.length)?e.filter(r=>r.editor.scssFiles.length).map(r=>{let o=q(r.editor.scssFiles),s=Object.values(o).join("");return {name:r.name,mergedCompiledStyles:s,scssFinal:`
|
|
15
|
+
#${r.nodeIdentifier}{
|
|
16
|
+
${s}
|
|
17
|
+
}`}}):[]}function Ie(r){return i(this,arguments,function*(e,t={}){let s=P(P({},{content:[{raw:e}],theme:{}}),t),n=globSync(`${M.resolve(__dirname,"..")}/${d.config.nodes.editor.dirName}/assets/tailwind.scss`)[0],m=n.length?W.readFileSync(n,"utf8"):"";return (yield V([we(s),re("autoprefixer")]).process(m,{from:void 0})).css})}function Oe(){let e=d.getResolvedSrcPathsScss(),t=q([...e]);return Object.values(t).join("")}function z(e){return i(this,null,function*(){let{rawHtml:t,minify:r=!1,nodes:o}=e||{},s=Oe(),n=je(o),m=yield Ie(t),c=p=>`.${d.packageNameSlug}{${p}}`,l=n.map(p=>p.scssFinal).join(`
|
|
18
|
+
`),a=c(`${m}${s}${l}`);return r?De(a,t):a})}function K(e){return i(this,null,function*(){let{minify:t=!1}=e||{},r=yield J({minify:t,nodes:e.nodes,packageNameSlug:d.packageNameSlug}),o=yield T(t),s=yield z({rawHtml:r.html,minify:t,nodes:e.nodes}),n=k(),m=`<script type="application/javascript">${o.trim()}</script>`,c=`<style>${s}</style>`;return `
|
|
19
|
+
${r.allWrappedHtml}
|
|
20
|
+
${c}
|
|
21
|
+
${m}
|
|
22
|
+
${n}`.trim()})}var Q=`
|
|
13
23
|
// generated by @keload/node-red-dev-xp
|
|
14
24
|
// do not modify this file
|
|
15
25
|
// do not commit this file
|
|
16
|
-
`;function
|
|
17
|
-
${
|
|
26
|
+
`;function X(e){return i(this,null,function*(){return `
|
|
27
|
+
${Q}
|
|
18
28
|
import type { NodeAPI } from 'node-red';
|
|
19
|
-
${
|
|
29
|
+
${e.map(t=>`import ${t.pascalName} from '${t.fullControllerPath}';`).join(`
|
|
20
30
|
`)}
|
|
21
31
|
|
|
22
32
|
|
|
23
33
|
export default async (RED: NodeAPI): Promise<void> => {
|
|
24
34
|
global.RED = RED;
|
|
25
35
|
|
|
26
|
-
${
|
|
27
|
-
global.RED.nodes.registerType('${
|
|
36
|
+
${e.map(t=>`// @ts-ignore
|
|
37
|
+
global.RED.nodes.registerType('${t.name}', ${t.pascalName});`).join(`
|
|
28
38
|
`)}
|
|
29
39
|
};
|
|
30
|
-
`.trim()}function
|
|
31
|
-
${
|
|
40
|
+
`.trim()})}function Y(e){return i(this,null,function*(){return `
|
|
41
|
+
${Q}
|
|
32
42
|
import type { NodeAPI } from 'node-red';
|
|
33
|
-
${
|
|
43
|
+
${e.map(t=>`import ${t.pascalName} from '${t.editor.tsPath}';`).join(`
|
|
34
44
|
`)}
|
|
35
45
|
|
|
36
46
|
declare const RED: NodeAPI;
|
|
37
47
|
|
|
38
|
-
${
|
|
39
|
-
window.RED.nodes.registerType('${
|
|
48
|
+
${e.map(t=>`// @ts-ignore
|
|
49
|
+
window.RED.nodes.registerType('${t.name}', ${t.pascalName});`).join(`
|
|
40
50
|
`)}
|
|
41
|
-
`.trim()}function
|
|
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};
|
|
51
|
+
`.trim()})}var u=D();function Wt(e){return i(this,null,function*(){let{minify:t=!1}=e||{},r=u.getListNodesFull();B(u.pathLibCacheDir),yield G([u.pathDist]);let o=X(r).then(n=>{h(`${u.cacheDirFiles.controllerIndex}`,n).then(()=>{R(t);});}),s=Y(r).then(n=>{h(`${u.cacheDirFiles.editorIndex}`,n).then(()=>{K({minify:t,nodes:r}).then(m=>i(this,null,function*(){yield h(`${u.pathDist}/index.html`,m);}));});});yield Promise.all([o,s,h(`${u.pathLibCacheDir}/config.json`,JSON.stringify(u.config,null,2))]);})}export{Wt as buildAllPackage,K as buildFinalDistIndexContent,u as currentInstance,Ie as generateCSSFromHTMLWithTailwind,z as getAllCompiledStyles,X as getControllerIndexContent,Y as getEditorIndexContent,J as getNodesHtml,je as getNodesStyles,Oe as getSrcStyles,k as handleAllDoc,xe as minifyHtml};
|
package/dist/cli/index.cjs
CHANGED
|
@@ -1,47 +1,52 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
'use strict';var
|
|
2
|
+
'use strict';var le=require('process'),commander=require('commander'),consola=require('consola'),M=require('fs'),cosmiconfig=require('cosmiconfig'),glob=require('glob'),radash=require('radash'),q=require('path'),H=require('esbuild'),htmlMinifierTerser=require('html-minifier-terser'),F=require('fs/promises'),ve=require('@fullhuman/postcss-purgecss'),Oe=require('autoprefixer'),ke=require('cssnano'),U=require('postcss'),K=require('sass'),Ee=require('tailwindcss'),Ge=require('prettyjson'),Ve=require('browser-sync'),Ue=require('chokidar'),ne=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 le__namespace=/*#__PURE__*/_interopNamespace(le);var M__default=/*#__PURE__*/_interopDefault(M);var q__default=/*#__PURE__*/_interopDefault(q);var H__default=/*#__PURE__*/_interopDefault(H);var F__default=/*#__PURE__*/_interopDefault(F);var ve__default=/*#__PURE__*/_interopDefault(ve);var Oe__default=/*#__PURE__*/_interopDefault(Oe);var ke__default=/*#__PURE__*/_interopDefault(ke);var U__default=/*#__PURE__*/_interopDefault(U);var K__namespace=/*#__PURE__*/_interopNamespace(K);var Ee__default=/*#__PURE__*/_interopDefault(Ee);var Ge__default=/*#__PURE__*/_interopDefault(Ge);var Ve__default=/*#__PURE__*/_interopDefault(Ve);var Ue__default=/*#__PURE__*/_interopDefault(Ue);var ne__default=/*#__PURE__*/_interopDefault(ne);var me=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var O={name:"@keload/node-red-dxp",version:"1.3.1",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","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(e){return Object.prototype.toString.call(e).slice(8,-1)}function h(e){if(w(e)!=="Object")return !1;let t=Object.getPrototypeOf(e);return !!t&&t.constructor===Object&&t===Object.prototype}function S(e){return w(e)==="Symbol"}function k(e,t,r,o){let n={}.propertyIsEnumerable.call(o,t)?"enumerable":"nonenumerable";n==="enumerable"&&(e[t]=r),n==="nonenumerable"&&Object.defineProperty(e,t,{value:r,enumerable:!1,writable:!0,configurable:!0});}function A(e,t,r){if(!h(t))return t;let o={};if(h(e)){let d=Object.getOwnPropertyNames(e),p=Object.getOwnPropertySymbols(e);o=[...d,...p].reduce((c,l)=>{let C=e[l];return (!S(l)&&!Object.getOwnPropertyNames(t).includes(l)||S(l)&&!Object.getOwnPropertySymbols(t).includes(l))&&k(c,l,C,e),c},{});}let n=Object.getOwnPropertyNames(t),s=Object.getOwnPropertySymbols(t);return [...n,...s].reduce((d,p)=>{let c=t[p],l=h(e)?e[p]:void 0;l!==void 0&&h(c)&&(c=A(l,c));let C=c;return k(d,p,C,t),d},o)}function E(e,...t){return t.reduce((r,o)=>A(r,o),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 he="node-red-dx",ye=e=>e.replace("@","").replace("/","-");function xe(){let e=cosmiconfig.cosmiconfigSync(he);try{let t=e.search();return E(R,t?t.config:{})}catch(t){throw console.error("Error while loading configuration",t),t}}var f=xe(),u=process.cwd(),L=JSON.parse(M.readFileSync(`${u}/package.json`,"utf-8")),j=`${u}/${f.srcDir}`,be=`${u}/resources`,$=`${j}/${f.nodesDirName}`,P=`${u}/${f.libCacheDir}`;function Ne(){return glob.globSync(`${$}/*`,{withFileTypes:!0}).map(t=>{let r=t.fullpath(),o=`${r}/${f.nodes.editor.dirName}`,n=r.replace(u,"").slice(1),s=`${n}/${f.nodes.editor.dirName}`,m=glob.globSync(`${o}/**/*.scss`),d=glob.globSync(`${r}/doc.mdx`),p=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:s,relativePath:n,nodeIdentifier:`${i.packageNameSlug}-${c}`,fullControllerPath:`${r}/${f.nodes.controllerName}.ts`,editor:{tsPath:`${o}/${f.nodes.editor.tsName}.ts`,htmlPath:`${o}/${f.nodes.editor.htmlName}.html`,scssFiles:m},doc:{mdxFiles:d,mdFiles:p}}})}function I(){return {currentDir:u,pathSrcDir:j,pathSrcNodesDir:$,additionalResourcesDir:be,pathDist:`${u}/${f.builder.outputDir}`,cacheDirFiles:{controllerIndex:`${P}/controller-index.ts`,editorIndex:`${P}/editor-index.ts`},pathLibCacheDir:P,packageName:L.name,packageNameSlug:ye(L.name),config:f,getResolvedSrcPathsScss:()=>glob.globSync(`${j}/**/*.scss`,{ignore:`${$}/**/*.scss`}),getResolvedNodesPaths:()=>glob.globSync(`${$}/*`),getListNodesFull:()=>Ne()}}var i=I();async function W(e=!1){return H__default.default.build({entryPoints:[i.cacheDirFiles.controllerIndex],outfile:`${i.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 T(e=!1){let t=await H__default.default.build({entryPoints:[i.cacheDirFiles.editorIndex],bundle:!0,platform:"browser",format:"iife",target:"es6",sourcemap:!1,minify:e,minifyWhitespace:e,minifySyntax:e,minifyIdentifiers:e,legalComments:"none",inject:[q__default.default.resolve(__dirname,"..","./editor/global-solid.ts")],write:!1,loader:{".ts":"ts"}});return t.outputFiles&&t.outputFiles.length>0?t.outputFiles[0].text:""}function B(){let e=i.getListNodesFull(),t=[];for(let r of e)if(r.doc.mdFiles[0]){let n=M__default.default.readFileSync(r.doc.mdFiles[0],"utf-8"),s=`
|
|
3
|
+
<script type="text/markdown" data-help-name="${r.name}">
|
|
4
|
+
${n}
|
|
5
|
+
</script>
|
|
6
|
+
`;t.push(s);}return t.length?t.join(`
|
|
7
|
+
`):""}function G(e){return e.trim().replace(/\n\s+/g,"")}async function J(e){for(let t of e)try{let r=q__default.default.resolve(t),o=await F__default.default.stat(r).catch(()=>null);o!=null&&o.isDirectory()?(await F__default.default.rm(r,{recursive:!0,force:!0}),console.log(`Successfully cleaned: ${r}`)):console.log(`Path does not exist or is not a directory: ${r}`);}catch(r){console.error(`Error cleaning path (${t}): ${r}`);}}function _(e){let t=q__default.default.resolve(e);M__default.default.existsSync(t)||M__default.default.mkdirSync(t,{recursive:!0});}async function b(e,t){try{await F__default.default.writeFile(e,t);}catch(r){console.error("Error writing controller index:",r);}}async function Pe(e){return htmlMinifierTerser.minify(e,{collapseWhitespace:!0,removeComments:!0,removeRedundantAttributes:!1,useShortDoctype:!0,removeEmptyAttributes:!1,minifyCSS:!1,minifyJS:!1})}function je(e,t){return `
|
|
3
8
|
<script type="text/html" data-template-name="${e}">
|
|
4
|
-
|
|
5
|
-
<div class="${t}">${n}</div>
|
|
6
|
-
</div>
|
|
9
|
+
${t}
|
|
7
10
|
</script>
|
|
8
|
-
`}async function
|
|
9
|
-
<
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
`}async function Ie(e,t,r=!1){let o=M.readFileSync(e.editor.htmlPath,"utf8"),n=`
|
|
12
|
+
<div class="${t}">
|
|
13
|
+
<div class="${e.nodeIdentifier}">${o}</div>
|
|
14
|
+
</div>
|
|
15
|
+
`,s=r?await Pe(n):n,m=je(e.name,s);return {nodeName:e.name,nodeIdentifier:e.nodeIdentifier,html:s,wrappedHtml:m}}async function V(e){let{nodes:t,minify:r=!1}=e,o=await Promise.all(t.map(s=>Ie(s,e.packageNameSlug,r)));return {html:o.map(s=>s.html).join("").trim(),allWrappedHtml:o.map(s=>r?G(s.wrappedHtml):s.wrappedHtml).join("").trim()}}async function Re(e,t){return (await U__default.default([ve__default.default({content:[{raw:t,extension:"html"}]}),Oe__default.default,ke__default.default({preset:"default"})]).process(e,{from:void 0})).css}function Le(e){return K__namespace.compile(e,{style:"expanded"}).css}function z(e){let t={};for(let r=0;r<e.length;r++){let o=e[r];t[o]=Le(o);}return t}function He(e){return e.some(r=>r.editor.scssFiles.length)?e.filter(r=>r.editor.scssFiles.length).map(r=>{let o=z(r.editor.scssFiles),n=Object.values(o).join("");return {name:r.name,mergedCompiledStyles:n,scssFinal:`
|
|
16
|
+
#${r.nodeIdentifier}{
|
|
17
|
+
${n}
|
|
18
|
+
}`}}):[]}async function We(e,t={}){let o={...{content:[{raw:e}],theme:{}},...t},n=glob.globSync(`${q__default.default.resolve(__dirname,"..")}/${i.config.nodes.editor.dirName}/assets/tailwind.scss`)[0],s=n.length?M__default.default.readFileSync(n,"utf8"):"";return (await U__default.default([Ee__default.default(o),me("autoprefixer")]).process(s,{from:void 0})).css}function Te(){let e=i.getResolvedSrcPathsScss(),t=z([...e]);return Object.values(t).join("")}async function Q(e){let{rawHtml:t,minify:r=!1,nodes:o}=e||{},n=Te(),s=He(o),m=await We(t),d=l=>`.${i.packageNameSlug}{${l}}`,p=s.map(l=>l.scssFinal).join(`
|
|
19
|
+
`),c=d(`${m}${n}${p}`);return r?Re(c,t):c}async function X(e){let{minify:t=!1}=e||{},r=await V({minify:t,nodes:e.nodes,packageNameSlug:i.packageNameSlug}),o=await T(t),n=await Q({rawHtml:r.html,minify:t,nodes:e.nodes}),s=B(),m=`<script type="application/javascript">${o.trim()}</script>`,d=`<style>${n}</style>`;return `
|
|
20
|
+
${r.allWrappedHtml}
|
|
21
|
+
${d}
|
|
22
|
+
${m}
|
|
23
|
+
${s}`.trim()}var Y=`
|
|
14
24
|
// generated by @keload/node-red-dev-xp
|
|
15
25
|
// do not modify this file
|
|
16
26
|
// do not commit this file
|
|
17
|
-
`;function
|
|
18
|
-
${
|
|
27
|
+
`;async function Z(e){return `
|
|
28
|
+
${Y}
|
|
19
29
|
import type { NodeAPI } from 'node-red';
|
|
20
|
-
${
|
|
30
|
+
${e.map(t=>`import ${t.pascalName} from '${t.fullControllerPath}';`).join(`
|
|
21
31
|
`)}
|
|
22
32
|
|
|
23
33
|
|
|
24
34
|
export default async (RED: NodeAPI): Promise<void> => {
|
|
25
35
|
global.RED = RED;
|
|
26
36
|
|
|
27
|
-
${
|
|
28
|
-
global.RED.nodes.registerType('${
|
|
37
|
+
${e.map(t=>`// @ts-ignore
|
|
38
|
+
global.RED.nodes.registerType('${t.name}', ${t.pascalName});`).join(`
|
|
29
39
|
`)}
|
|
30
40
|
};
|
|
31
|
-
`.trim()}function
|
|
32
|
-
${
|
|
41
|
+
`.trim()}async function ee(e){return `
|
|
42
|
+
${Y}
|
|
33
43
|
import type { NodeAPI } from 'node-red';
|
|
34
|
-
${
|
|
44
|
+
${e.map(t=>`import ${t.pascalName} from '${t.editor.tsPath}';`).join(`
|
|
35
45
|
`)}
|
|
36
46
|
|
|
37
47
|
declare const RED: NodeAPI;
|
|
38
48
|
|
|
39
|
-
${
|
|
40
|
-
window.RED.nodes.registerType('${
|
|
49
|
+
${e.map(t=>`// @ts-ignore
|
|
50
|
+
window.RED.nodes.registerType('${t.name}', ${t.pascalName});`).join(`
|
|
41
51
|
`)}
|
|
42
|
-
`.trim()}function
|
|
43
|
-
<script type="text/markdown" data-help-name="${o.name}">
|
|
44
|
-
${s}
|
|
45
|
-
</script>
|
|
46
|
-
`;t.push(g);}return t.length?t.join(`
|
|
47
|
-
`):""}async function Ne(e=!1){return W__default.default.build({entryPoints:[r.cacheDirFiles.controllerIndex],outfile:`${r.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 E(e=!1){let t=await W__default.default.build({entryPoints:[r.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 Se(){Ce__default.default.sync([r.pathDist]);}function Ie(){l__namespace.writeFileSync(`${r.pathLibCacheDir}/config.json`,JSON.stringify(r.config,null,2),"utf-8");}function De(e){let t=pe__default.default.resolve(e);l__namespace.existsSync(t)||l__namespace.mkdirSync(t,{recursive:!0});}async function p(e=!1){De(r.pathLibCacheDir),Se(),Ie(),B(),L(),await Ne(e),await v(e);}function O(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(Pe__default.default.render(r));});e.addCommand(t);}function M(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 o=await consola.consola.prompt("Enter node name:",{type:"text"}),n=radash.dash(o),s=await consola.consola.prompt(`This name is OK for you '${n}'?`,{type:"confirm"});console.log("userIsOk",s);});e.addCommand(t);}var T,w;function Be(){T=H__default.default({exec:`node-red -u ${r.config.watcher.nodeRed.path}`,ignore:["**/*"],ext:"js,html",verbose:!0}),H__default.default.once("start",()=>{w=Ee__default.default.create(),w.init({ui:!1,proxy:{target:r.config.watcher.nodeRed.url,ws:!0},ghostMode:!1,open:!1,reloadDelay:4e3});}).on("quit",()=>{consola.consola.info("Nodemon has quit"),process.exit(0);});}function Le(){T.restart(),w.reload();}var J=r.config.watcher.nodeRed.enabled&&r.config.watcher.nodeRed.path;function _(){Ae__default.default.watch(r.pathSrcDir,{}).on("ready",async()=>{consola.consola.info("Initial scan complete. Ready for changes"),await p(!1),consola.consola.success("Initial Build completed"),J?Be():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(r.currentDir,"")} has been changed`),await p(!1),consola.consola.success("Build completed"),J&&Le();});}var c=new commander.Command;c.name("node-red-dxp").description("node-red-dxp CLI").version(N.version);c.command("build").description("Build project").action(async e=>{consola.consola.start("Building..."),await p(!0),consola.consola.ready("Build completed");});c.command("watch").description("watch project").option("--minify <minify>","[WIP] Minify the output",!1).action(e=>{_();});O(c);q(c);M(c);c.parse(K__namespace.argv);
|
|
52
|
+
`.trim()}var a=I();async function N(e){let{minify:t=!1}=e||{},r=a.getListNodesFull();_(a.pathLibCacheDir),await J([a.pathDist]);let o=Z(r).then(s=>{b(`${a.cacheDirFiles.controllerIndex}`,s).then(()=>{W(t);});}),n=ee(r).then(s=>{b(`${a.cacheDirFiles.editorIndex}`,s).then(()=>{X({minify:t,nodes:r}).then(async m=>{await b(`${a.pathDist}/index.html`,m);});});});await Promise.all([o,n,b(`${a.pathLibCacheDir}/config.json`,JSON.stringify(a.config,null,2))]);}function te(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 re(e){let t=new commander.Command("info").description("Command to get information").description("Get information about the package").action(()=>{consola.consola.log(Ge__default.default.render(i));});e.addCommand(t);}function oe(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"}),o=radash.dash(r),n=await consola.consola.prompt(`This name is OK for you '${o}'?`,{type:"confirm"});console.log("userIsOk",n);});e.addCommand(t);}var ie,v;function Ke(){ie=ne__default.default({exec:`node-red -u ${a.config.watcher.nodeRed.path}`,ignore:["**/*"],ext:"js,html",verbose:!0}),ne__default.default.once("start",()=>{v=Ve__default.default.create(),v.init({ui:!1,proxy:{target:a.config.watcher.nodeRed.url,ws:!0},ghostMode:!1,open:!1,reloadDelay:4e3});}).on("quit",()=>{consola.consola.info("Nodemon has quit"),process.exit(0);});}function ze(){ie.restart(),v.reload();}var se=a.config.watcher.nodeRed.enabled&&a.config.watcher.nodeRed.path;function ae(){Ue__default.default.watch(a.pathSrcDir,{}).on("ready",async()=>{consola.consola.info("Initial scan complete. Ready for changes"),await N({minify:!1}),consola.consola.success("Initial Build completed"),se?Ke():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(a.currentDir,"")} has been changed`),await N({minify:!1}),consola.consola.success("Build completed"),se&&ze();});}var g=new commander.Command;g.name("node-red-dxp").description("node-red-dxp CLI").version(O.version);g.command("build").description("Build project").action(async e=>{consola.consola.start("Building..."),await N({minify:!0}),consola.consola.ready("Build completed");});g.command("watch").description("watch project").option("--minify <minify>","[WIP] Minify the output",!1).action(e=>{ae();});te(g);re(g);oe(g);g.parse(le__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};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keload/node-red-dxp",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
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"
|
|
@@ -46,33 +49,39 @@
|
|
|
46
49
|
"homepage": "https://github.com/clement-berard/node-red-dxp",
|
|
47
50
|
"devDependencies": {
|
|
48
51
|
"@biomejs/biome": "1.9.4",
|
|
52
|
+
"@release-it/conventional-changelog": "9.0.3",
|
|
49
53
|
"release-it": "17.10.0",
|
|
50
54
|
"tsup": "8.3.5",
|
|
51
55
|
"tsx": "4.19.2",
|
|
52
|
-
"typescript": "5.6.3"
|
|
56
|
+
"typescript": "5.6.3",
|
|
57
|
+
"vitepress": "1.5.0"
|
|
53
58
|
},
|
|
54
59
|
"dependencies": {
|
|
55
|
-
"@
|
|
60
|
+
"@fullhuman/postcss-purgecss": "^6.0.0",
|
|
56
61
|
"@types/html-minifier-terser": "7.0.2",
|
|
57
62
|
"@types/jquery": "3.5.32",
|
|
58
63
|
"@types/jqueryui": "1.12.23",
|
|
59
64
|
"@types/node-red": "1.3.5",
|
|
60
65
|
"@types/prettyjson": "0.0.33",
|
|
66
|
+
"autoprefixer": "^10.4.20",
|
|
61
67
|
"browser-sync": "3.0.3",
|
|
62
68
|
"chokidar": "4.0.1",
|
|
63
69
|
"commander": "12.1.0",
|
|
64
70
|
"consola": "3.2.3",
|
|
65
71
|
"cosmiconfig": "9.0.0",
|
|
66
|
-
"
|
|
72
|
+
"cssnano": "^7.0.6",
|
|
67
73
|
"esbuild": "0.24.0",
|
|
68
74
|
"glob": "11.0.0",
|
|
69
75
|
"handlebars": "4.7.8",
|
|
70
76
|
"html-minifier-terser": "7.2.0",
|
|
71
77
|
"merge-anything": "6.0.2",
|
|
72
78
|
"nodemon": "3.1.7",
|
|
79
|
+
"postcss": "^8.4.49",
|
|
73
80
|
"prettyjson": "1.2.5",
|
|
74
81
|
"radash": "12.1.0",
|
|
75
|
-
"sass": "1.81.0"
|
|
82
|
+
"sass": "1.81.0",
|
|
83
|
+
"solid-js": "1.9.3",
|
|
84
|
+
"tailwindcss": "^3.4.15"
|
|
76
85
|
},
|
|
77
86
|
"files": [
|
|
78
87
|
"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
|
-
|