@teleporthq/teleport-plugin-next-workflows 0.43.37 → 0.43.38

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.
@@ -1,4 +1,39 @@
1
1
  export function handlerToString(fn) {
2
2
  return fn.toString();
3
3
  }
4
+ // Resolves the name a handler's entry function is ACTUALLY declared with in
5
+ // `source`, rather than assuming it always equals the
6
+ // `nodeType.replace(/-/g, '_')` convention name.
7
+ //
8
+ // Handlers built from `handlerToString(fn)` on a real function embed
9
+ // `fn.toString()` — a snapshot of whatever `fn` was actually named at the
10
+ // moment it's read. When this package is bundled and minified by a consumer
11
+ // (e.g. teleport-gui's browser packer worker, built with Next.js/Terser), the
12
+ // minifier freely renames `fn`'s declaration: nothing in the bundle calls it
13
+ // by name, only this runtime `.toString()` read does, which is invisible to
14
+ // the minifier. Callers that then reference the embedded handler by the
15
+ // static convention name get a "Collecting page data"/prerender
16
+ // ReferenceError, since local dev never runs a minifier.
17
+ //
18
+ // Handlers composed from string-literal templates (not `fn.toString()`) are
19
+ // immune to that class of breakage — a minifier never rewrites the contents
20
+ // of a string literal — so the convention name is still correct for those;
21
+ // this only needs to look further when it's genuinely absent from `source`.
22
+ export function resolveHandlerEntryName(source, nodeType) {
23
+ const conventionName = nodeType.replace(/-/g, '_');
24
+ const conventionNameUsed = new RegExp(`(?:^|[^\\w$])${conventionName}\\s*\\(`).test(source);
25
+ if (conventionNameUsed) {
26
+ return conventionName;
27
+ }
28
+ // `source` came from `handlerToString(fn)` on a real, possibly-minified
29
+ // function — its ENTIRE text is that one function's declaration, so
30
+ // whatever name follows the leading `function`/`async function` keyword is
31
+ // the name it was actually assigned at runtime.
32
+ const leadingDeclaration = source.match(/^(?:async\s+)?function\s*([A-Za-z0-9_$]+)\s*\(/);
33
+ if (leadingDeclaration) {
34
+ return leadingDeclaration[1];
35
+ }
36
+ throw new Error(`Could not resolve the entry function for workflow node type "${nodeType}" — ` +
37
+ `expected a "${conventionName}" declaration or a single toString()'d function, found neither.`);
38
+ }
4
39
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/nodes/types.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,eAAe,CAAC,EAAa;IAC3C,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAA;AACtB,CAAC"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/nodes/types.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,eAAe,CAAC,EAAa;IAC3C,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAA;AACtB,CAAC;AAED,4EAA4E;AAC5E,sDAAsD;AACtD,iDAAiD;AACjD,EAAE;AACF,qEAAqE;AACrE,0EAA0E;AAC1E,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,4EAA4E;AAC5E,wEAAwE;AACxE,gEAAgE;AAChE,yDAAyD;AACzD,EAAE;AACF,4EAA4E;AAC5E,4EAA4E;AAC5E,2EAA2E;AAC3E,4EAA4E;AAC5E,MAAM,UAAU,uBAAuB,CAAC,MAAc,EAAE,QAAgB;IACtE,MAAM,cAAc,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IAClD,MAAM,kBAAkB,GAAG,IAAI,MAAM,CAAC,gBAAgB,cAAc,SAAS,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC3F,IAAI,kBAAkB,EAAE;QACtB,OAAO,cAAc,CAAA;KACtB;IAED,wEAAwE;IACxE,oEAAoE;IACpE,2EAA2E;IAC3E,gDAAgD;IAChD,MAAM,kBAAkB,GAAG,MAAM,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAA;IACzF,IAAI,kBAAkB,EAAE;QACtB,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAA;KAC7B;IAED,MAAM,IAAI,KAAK,CACb,gEAAgE,QAAQ,MAAM;QAC5E,eAAe,cAAc,iEAAiE,CACjG,CAAA;AACH,CAAC"}