backflow-ui-renderer 0.1.62 → 0.1.63

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/dist/vite.cjs CHANGED
@@ -1,17 +1,23 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("node:fs"),f=require("node:path"),S=require("node:module");var u=typeof document<"u"?document.currentScript:null;const g=S.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:u&&u.tagName.toUpperCase()==="SCRIPT"&&u.src||new URL("vite.cjs",document.baseURI).href),h="virtual:backflow-workflow-icons",d=`\0${h}`,$="@squeed/flow-sdk",y="\0backflow-empty-flow-sdk",I=e=>e.split("-").filter(Boolean).map(t=>t[0].toUpperCase()+t.slice(1)).join("");function p(e,t=new Set){if(Array.isArray(e)){for(const r of e)p(r,t);return t}if(!e||typeof e!="object")return t;for(const[r,o]of Object.entries(e)){const n=r==="icon"||r==="iconName"||r.endsWith("Icon"),s=typeof o=="string"&&/^[a-z0-9]+(?:-[a-z0-9]+)*$/i.test(o);n&&s&&t.add(o),p(o,t)}return t}function m(e){return Array.isArray(e)?e.some(m):!e||typeof e!="object"?!1:e.type==="flow"?!0:Object.values(e).some(m)}function k(e){const t=g.resolve(`react-icons/${e}`,{paths:[process.cwd()]}),r=w.readFileSync(f.join(f.dirname(t),"index.d.ts"),"utf-8");return new Set(Array.from(r.matchAll(/export declare const (\w+)/g),o=>o[1]))}function _(e,t){const[r,...o]=e.split("-");let n;if(o.length>0)try{t.has(r)||t.set(r,k(r)),n=r}catch{}const s=n?[n]:["fi","lu"],i=n?o.join("-"):e;for(const c of s){const l=`${I(c)}${I(i)}`;let a=t.get(c);if(!a)try{a=k(c),t.set(c,a)}catch{continue}if(a.has(l))return{name:e,packageName:`react-icons/${c}`,exportName:l}}throw new Error(`Unsupported workflow icon: ${e}`)}function b(e){const t=JSON.parse(w.readFileSync(e,"utf-8")),r=new Map,o=Array.from(p(t)).sort().map(i=>_(i,r)),n=o.map(({packageName:i,exportName:c},l)=>`import { ${c} as Icon${l} } from "${i}";`).join(`
2
- `),s=o.map(({name:i},c)=>` ${JSON.stringify(i)}: Icon${c},`).join(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("node:fs"),u=require("node:path"),U=require("node:module");var m=typeof document<"u"?document.currentScript:null;const L=U.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:m&&m.tagName.toUpperCase()==="SCRIPT"&&m.src||new URL("vite.cjs",document.baseURI).href),x="virtual:backflow-workflow-icons",d=`\0${x}`,A="@squeed/flow-sdk",I="\0backflow-empty-flow-sdk",S=e=>e.split("-").filter(Boolean).map(t=>t[0].toUpperCase()+t.slice(1)).join("");function g(e,t=new Set){if(Array.isArray(e)){for(const o of e)g(o,t);return t}if(!e||typeof e!="object")return t;for(const[o,r]of Object.entries(e)){const n=o==="icon"||o==="iconName"||o.endsWith("Icon"),c=typeof r=="string"&&/^[a-z0-9]+(?:-[a-z0-9]+)*$/i.test(r);n&&c&&t.add(r),g(r,t)}return t}function y(e){return Array.isArray(e)?e.some(y):!e||typeof e!="object"?!1:e.type==="flow"?!0:Object.values(e).some(y)}function k(e){const t=L.resolve(`react-icons/${e}`,{paths:[process.cwd()]}),o=h.readFileSync(u.join(u.dirname(t),"index.d.ts"),"utf-8");return new Set(Array.from(o.matchAll(/export declare const (\w+)/g),r=>r[1]))}function W(e,t){const[o,...r]=e.split("-");let n;if(r.length>0)try{t.has(o)||t.set(o,k(o)),n=o}catch{}const c=n?[n]:["fi","lu"],s=n?r.join("-"):e;for(const i of c){const a=`${S(i)}${S(s)}`;let l=t.get(i);if(!l)try{l=k(i),t.set(i,l)}catch{continue}if(l.has(a))return{name:e,packageName:`react-icons/${i}`,exportName:a}}throw new Error(`Unsupported workflow icon: ${e}`)}function D(e){const t=JSON.parse(h.readFileSync(e,"utf-8")),o=new Map,r=Array.from(g(t)).sort().map(s=>W(s,o)),n=r.map(({packageName:s,exportName:i},a)=>`import { ${i} as Icon${a} } from "${s}";`).join(`
2
+ `),c=r.map(({name:s},i)=>` ${JSON.stringify(s)}: Icon${i},`).join(`
3
3
  `);return`${n}
4
4
  import { createElement } from "react";
5
5
 
6
6
  const icons = {
7
- ${s}
7
+ ${c}
8
8
  };
9
9
 
10
10
  export const workflowIconResolver = (name, size, style) => {
11
11
  const Icon = icons[name];
12
12
  return Icon ? createElement(Icon, { size, style: { ...style, flexShrink: 0 } }) : null;
13
13
  };
14
- `}const F=`
14
+ `}const O=`
15
15
  export const createFlowDiagram = () => ({ nodes: [], edges: [] });
16
16
  export const FlowDiagram = () => null;
17
- `;function j({workflowPath:e}){const t=f.resolve(e),r=()=>JSON.parse(w.readFileSync(t,"utf-8"));return{name:"backflow-workflow-icons",enforce:"pre",buildStart(){this.addWatchFile(t)},resolveId(o){return o===$&&!m(r())?y:o===h?d:null},load(o){return o===y?F:o===d?b(t):null},handleHotUpdate({file:o,server:n}){if(f.resolve(o)!==t)return;const s=n.moduleGraph.getModuleById(d);return s?[s]:[]}}}exports.workflowIcons=j;
17
+ `,$="manifest.webmanifest",v="sw.js";function R(e){var c;const t=/^data:([^;,]+)(;base64)?,(.*)$/s.exec(e||"");if(!t)return null;const o=t[1],r=t[2]?Buffer.from(t[3],"base64"):Buffer.from(decodeURIComponent(t[3])),n=o.includes("svg")?"svg":((c=o.split("/")[1])==null?void 0:c.split("+")[0])||"png";return{mime:o,buffer:r,ext:n}}function B(e){var w,b;const t=(e==null?void 0:e.config)||{},o=String((e==null?void 0:e.title)||t.title||"App"),r=String(((w=t.colors)==null?void 0:w.primary)||"#111827"),n=String(((b=t.colors)==null?void 0:b.background)||"#ffffff"),c=String(t.logo||"");let s,i,a,l="512x512";const f=c.startsWith("data:image/")?R(c):null;if(f)s=`backflow-pwa-icon.${f.ext}`,i=f.mime,a=f.buffer,f.ext==="svg"&&(l="any");else{const E=(o.trim()[0]||"B").toUpperCase(),N=`<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512"><rect width="512" height="512" rx="96" fill="${r}"/><text x="50%" y="52%" font-size="300" font-family="Georgia,serif" fill="#ffffff" text-anchor="middle" dominant-baseline="middle">${E}</text></svg>`;s="backflow-pwa-icon.svg",i="image/svg+xml",a=Buffer.from(N),l="any"}const p=`/${s}`,_={name:o,short_name:o.slice(0,12),start_url:"/",scope:"/",display:"standalone",orientation:"portrait",background_color:n,theme_color:r,icons:[{src:p,sizes:l,type:i,purpose:"any"},{src:p,sizes:l,type:i,purpose:"maskable"}]},F=`// Backflow PWA service worker (network pass-through)
18
+ self.addEventListener("install", () => self.skipWaiting());
19
+ self.addEventListener("activate", (event) => event.waitUntil(self.clients.claim()));
20
+ self.addEventListener("fetch", () => { /* network only */ });
21
+ `,j=[`<link rel="manifest" href="/${$}">`,`<meta name="theme-color" content="${r}">`,'<meta name="mobile-web-app-capable" content="yes">','<meta name="apple-mobile-web-app-capable" content="yes">','<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">',`<link rel="apple-touch-icon" href="${p}">`,`<script>if('serviceWorker' in navigator){window.addEventListener('load',function(){navigator.serviceWorker.register('/${v}').catch(function(){});});}<\/script>`].join(`
22
+ `);return{files:[{name:$,source:JSON.stringify(_),type:"application/manifest+json"},{name:v,source:F,type:"text/javascript"},{name:s,source:a,type:i}],html:j}}function z({workflowPath:e}){const t=u.resolve(e),o=()=>JSON.parse(h.readFileSync(t,"utf-8")),r=()=>B(o());return{name:"backflow-workflow-icons",enforce:"pre",buildStart(){this.addWatchFile(t)},configureServer(n){n.middlewares.use((c,s,i)=>{const a=(c.url||"").split("?")[0];try{const f=r().files.find(p=>a===`/${p.name}`);if(f){s.setHeader("Content-Type",f.type),s.end(f.source);return}}catch{}i()})},generateBundle(){for(const n of r().files)this.emitFile({type:"asset",fileName:n.name,source:n.source})},transformIndexHtml:{order:"post",handler(n){const c=r().html;return n.replace("</head>",` ${c}
23
+ </head>`)}},resolveId(n){return n===A&&!y(o())?I:n===x?d:null},load(n){return n===I?O:n===d?D(t):null},handleHotUpdate({file:n,server:c}){if(u.resolve(n)!==t)return;const s=c.moduleGraph.getModuleById(d);return s?[s]:[]}}}exports.workflowIcons=z;
@@ -1 +1 @@
1
- {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAQnC,UAAU,oBAAoB;IAC5B,YAAY,EAAE,MAAM,CAAC;CACtB;AAsHD,wBAAgB,aAAa,CAAC,EAAE,YAAY,EAAE,EAAE,oBAAoB,GAAG,MAAM,CA4B5E"}
1
+ {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAQnC,UAAU,oBAAoB;IAC5B,YAAY,EAAE,MAAM,CAAC;CACtB;AA4MD,wBAAgB,aAAa,CAAC,EAAE,YAAY,EAAE,EAAE,oBAAoB,GAAG,MAAM,CA2D5E"}
package/dist/vite.js CHANGED
@@ -1,67 +1,67 @@
1
- import { readFileSync as m } from "node:fs";
2
- import { resolve as d, join as $, dirname as h } from "node:path";
3
- import { createRequire as g } from "node:module";
4
- const x = g(import.meta.url), k = "virtual:backflow-workflow-icons", f = `\0${k}`, S = "@squeed/flow-sdk", w = "\0backflow-empty-flow-sdk", y = (o) => o.split("-").filter(Boolean).map((t) => t[0].toUpperCase() + t.slice(1)).join("");
5
- function p(o, t = /* @__PURE__ */ new Set()) {
6
- if (Array.isArray(o)) {
7
- for (const r of o) p(r, t);
1
+ import { readFileSync as g } from "node:fs";
2
+ import { resolve as w, join as N, dirname as A } from "node:path";
3
+ import { createRequire as L } from "node:module";
4
+ const W = L(import.meta.url), v = "virtual:backflow-workflow-icons", m = `\0${v}`, D = "@squeed/flow-sdk", b = "\0backflow-empty-flow-sdk", x = (e) => e.split("-").filter(Boolean).map((t) => t[0].toUpperCase() + t.slice(1)).join("");
5
+ function u(e, t = /* @__PURE__ */ new Set()) {
6
+ if (Array.isArray(e)) {
7
+ for (const o of e) u(o, t);
8
8
  return t;
9
9
  }
10
- if (!o || typeof o != "object") return t;
11
- for (const [r, e] of Object.entries(o)) {
12
- const n = r === "icon" || r === "iconName" || r.endsWith("Icon"), c = typeof e == "string" && /^[a-z0-9]+(?:-[a-z0-9]+)*$/i.test(e);
13
- n && c && t.add(e), p(e, t);
10
+ if (!e || typeof e != "object") return t;
11
+ for (const [o, r] of Object.entries(e)) {
12
+ const n = o === "icon" || o === "iconName" || o.endsWith("Icon"), i = typeof r == "string" && /^[a-z0-9]+(?:-[a-z0-9]+)*$/i.test(r);
13
+ n && i && t.add(r), u(r, t);
14
14
  }
15
15
  return t;
16
16
  }
17
- function u(o) {
18
- return Array.isArray(o) ? o.some(u) : !o || typeof o != "object" ? !1 : o.type === "flow" ? !0 : Object.values(o).some(u);
17
+ function d(e) {
18
+ return Array.isArray(e) ? e.some(d) : !e || typeof e != "object" ? !1 : e.type === "flow" ? !0 : Object.values(e).some(d);
19
19
  }
20
- function I(o) {
21
- const t = x.resolve(`react-icons/${o}`, {
20
+ function $(e) {
21
+ const t = W.resolve(`react-icons/${e}`, {
22
22
  paths: [process.cwd()]
23
- }), r = m($(h(t), "index.d.ts"), "utf-8");
23
+ }), o = g(N(A(t), "index.d.ts"), "utf-8");
24
24
  return new Set(
25
25
  Array.from(
26
- r.matchAll(/export declare const (\w+)/g),
27
- (e) => e[1]
26
+ o.matchAll(/export declare const (\w+)/g),
27
+ (r) => r[1]
28
28
  )
29
29
  );
30
30
  }
31
- function b(o, t) {
32
- const [r, ...e] = o.split("-");
31
+ function U(e, t) {
32
+ const [o, ...r] = e.split("-");
33
33
  let n;
34
- if (e.length > 0)
34
+ if (r.length > 0)
35
35
  try {
36
- t.has(r) || t.set(r, I(r)), n = r;
36
+ t.has(o) || t.set(o, $(o)), n = o;
37
37
  } catch {
38
38
  }
39
- const c = n ? [n] : ["fi", "lu"], i = n ? e.join("-") : o;
40
- for (const s of c) {
41
- const l = `${y(s)}${y(i)}`;
42
- let a = t.get(s);
43
- if (!a)
39
+ const i = n ? [n] : ["fi", "lu"], s = n ? r.join("-") : e;
40
+ for (const c of i) {
41
+ const a = `${x(c)}${x(s)}`;
42
+ let l = t.get(c);
43
+ if (!l)
44
44
  try {
45
- a = I(s), t.set(s, a);
45
+ l = $(c), t.set(c, l);
46
46
  } catch {
47
47
  continue;
48
48
  }
49
- if (a.has(l))
50
- return { name: o, packageName: `react-icons/${s}`, exportName: l };
49
+ if (l.has(a))
50
+ return { name: e, packageName: `react-icons/${c}`, exportName: a };
51
51
  }
52
- throw new Error(`Unsupported workflow icon: ${o}`);
52
+ throw new Error(`Unsupported workflow icon: ${e}`);
53
53
  }
54
- function j(o) {
55
- const t = JSON.parse(m(o, "utf-8")), r = /* @__PURE__ */ new Map(), e = Array.from(p(t)).sort().map((i) => b(i, r)), n = e.map(
56
- ({ packageName: i, exportName: s }, l) => `import { ${s} as Icon${l} } from "${i}";`
54
+ function B(e) {
55
+ const t = JSON.parse(g(e, "utf-8")), o = /* @__PURE__ */ new Map(), r = Array.from(u(t)).sort().map((s) => U(s, o)), n = r.map(
56
+ ({ packageName: s, exportName: c }, a) => `import { ${c} as Icon${a} } from "${s}";`
57
57
  ).join(`
58
- `), c = e.map(({ name: i }, s) => ` ${JSON.stringify(i)}: Icon${s},`).join(`
58
+ `), i = r.map(({ name: s }, c) => ` ${JSON.stringify(s)}: Icon${c},`).join(`
59
59
  `);
60
60
  return `${n}
61
61
  import { createElement } from "react";
62
62
 
63
63
  const icons = {
64
- ${c}
64
+ ${i}
65
65
  };
66
66
 
67
67
  export const workflowIconResolver = (name, size, style) => {
@@ -70,31 +70,114 @@ export const workflowIconResolver = (name, size, style) => {
70
70
  };
71
71
  `;
72
72
  }
73
- const A = `
73
+ const O = `
74
74
  export const createFlowDiagram = () => ({ nodes: [], edges: [] });
75
75
  export const FlowDiagram = () => null;
76
- `;
77
- function O({ workflowPath: o }) {
78
- const t = d(o), r = () => JSON.parse(m(t, "utf-8"));
76
+ `, k = "manifest.webmanifest", I = "sw.js";
77
+ function z(e) {
78
+ var i;
79
+ const t = /^data:([^;,]+)(;base64)?,(.*)$/s.exec(e || "");
80
+ if (!t) return null;
81
+ const o = t[1], r = t[2] ? Buffer.from(t[3], "base64") : Buffer.from(decodeURIComponent(t[3])), n = o.includes("svg") ? "svg" : ((i = o.split("/")[1]) == null ? void 0 : i.split("+")[0]) || "png";
82
+ return { mime: o, buffer: r, ext: n };
83
+ }
84
+ function M(e) {
85
+ var y, h;
86
+ const t = (e == null ? void 0 : e.config) || {}, o = String((e == null ? void 0 : e.title) || t.title || "App"), r = String(((y = t.colors) == null ? void 0 : y.primary) || "#111827"), n = String(((h = t.colors) == null ? void 0 : h.background) || "#ffffff"), i = String(t.logo || "");
87
+ let s, c, a, l = "512x512";
88
+ const f = i.startsWith("data:image/") ? z(i) : null;
89
+ if (f)
90
+ s = `backflow-pwa-icon.${f.ext}`, c = f.mime, a = f.buffer, f.ext === "svg" && (l = "any");
91
+ else {
92
+ const j = (o.trim()[0] || "B").toUpperCase(), F = `<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512"><rect width="512" height="512" rx="96" fill="${r}"/><text x="50%" y="52%" font-size="300" font-family="Georgia,serif" fill="#ffffff" text-anchor="middle" dominant-baseline="middle">${j}</text></svg>`;
93
+ s = "backflow-pwa-icon.svg", c = "image/svg+xml", a = Buffer.from(F), l = "any";
94
+ }
95
+ const p = `/${s}`, S = {
96
+ name: o,
97
+ short_name: o.slice(0, 12),
98
+ start_url: "/",
99
+ scope: "/",
100
+ display: "standalone",
101
+ orientation: "portrait",
102
+ background_color: n,
103
+ theme_color: r,
104
+ icons: [
105
+ { src: p, sizes: l, type: c, purpose: "any" },
106
+ { src: p, sizes: l, type: c, purpose: "maskable" }
107
+ ]
108
+ }, E = `// Backflow PWA service worker (network pass-through)
109
+ self.addEventListener("install", () => self.skipWaiting());
110
+ self.addEventListener("activate", (event) => event.waitUntil(self.clients.claim()));
111
+ self.addEventListener("fetch", () => { /* network only */ });
112
+ `, _ = [
113
+ `<link rel="manifest" href="/${k}">`,
114
+ `<meta name="theme-color" content="${r}">`,
115
+ '<meta name="mobile-web-app-capable" content="yes">',
116
+ '<meta name="apple-mobile-web-app-capable" content="yes">',
117
+ '<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">',
118
+ `<link rel="apple-touch-icon" href="${p}">`,
119
+ `<script>if('serviceWorker' in navigator){window.addEventListener('load',function(){navigator.serviceWorker.register('/${I}').catch(function(){});});}<\/script>`
120
+ ].join(`
121
+ `);
122
+ return {
123
+ files: [
124
+ { name: k, source: JSON.stringify(S), type: "application/manifest+json" },
125
+ { name: I, source: E, type: "text/javascript" },
126
+ { name: s, source: a, type: c }
127
+ ],
128
+ html: _
129
+ };
130
+ }
131
+ function C({ workflowPath: e }) {
132
+ const t = w(e), o = () => JSON.parse(g(t, "utf-8")), r = () => M(o());
79
133
  return {
80
134
  name: "backflow-workflow-icons",
81
135
  enforce: "pre",
82
136
  buildStart() {
83
137
  this.addWatchFile(t);
84
138
  },
85
- resolveId(e) {
86
- return e === S && !u(r()) ? w : e === k ? f : null;
139
+ configureServer(n) {
140
+ n.middlewares.use((i, s, c) => {
141
+ const a = (i.url || "").split("?")[0];
142
+ try {
143
+ const f = r().files.find((p) => a === `/${p.name}`);
144
+ if (f) {
145
+ s.setHeader("Content-Type", f.type), s.end(f.source);
146
+ return;
147
+ }
148
+ } catch {
149
+ }
150
+ c();
151
+ });
152
+ },
153
+ generateBundle() {
154
+ for (const n of r().files)
155
+ this.emitFile({ type: "asset", fileName: n.name, source: n.source });
156
+ },
157
+ transformIndexHtml: {
158
+ order: "post",
159
+ handler(n) {
160
+ const i = r().html;
161
+ return n.replace(
162
+ "</head>",
163
+ ` ${i}
164
+ </head>`
165
+ );
166
+ }
167
+ },
168
+ resolveId(n) {
169
+ return n === D && !d(o()) ? b : n === v ? m : null;
87
170
  },
88
- load(e) {
89
- return e === w ? A : e === f ? j(t) : null;
171
+ load(n) {
172
+ return n === b ? O : n === m ? B(t) : null;
90
173
  },
91
- handleHotUpdate({ file: e, server: n }) {
92
- if (d(e) !== t) return;
93
- const c = n.moduleGraph.getModuleById(f);
94
- return c ? [c] : [];
174
+ handleHotUpdate({ file: n, server: i }) {
175
+ if (w(n) !== t) return;
176
+ const s = i.moduleGraph.getModuleById(m);
177
+ return s ? [s] : [];
95
178
  }
96
179
  };
97
180
  }
98
181
  export {
99
- O as workflowIcons
182
+ C as workflowIcons
100
183
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backflow-ui-renderer",
3
- "version": "0.1.62",
3
+ "version": "0.1.63",
4
4
  "description": "Standalone React workflow renderer for Backflow",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",