pupt-lib 1.3.8 → 1.3.9

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/index.js CHANGED
@@ -42959,6 +42959,53 @@ function jsxNewlineLiteralPlugin({ types: t }) {
42959
42959
  }
42960
42960
  };
42961
42961
  }
42962
+ function customComponentInjectionPlugin({ types: t }) {
42963
+ return {
42964
+ name: "custom-component-injection",
42965
+ visitor: {
42966
+ Program: {
42967
+ exit(path) {
42968
+ const opts = this.opts;
42969
+ const { componentNames, globalKey } = opts;
42970
+ if (!componentNames || componentNames.length === 0) {
42971
+ return;
42972
+ }
42973
+ const declaration = t.variableDeclaration("const", [
42974
+ t.variableDeclarator(
42975
+ t.objectPattern(
42976
+ componentNames.map(
42977
+ (name) => t.objectProperty(
42978
+ t.identifier(name),
42979
+ t.identifier(name),
42980
+ false,
42981
+ true
42982
+ // shorthand
42983
+ )
42984
+ )
42985
+ ),
42986
+ t.memberExpression(
42987
+ t.identifier("globalThis"),
42988
+ t.identifier(globalKey)
42989
+ )
42990
+ )
42991
+ ]);
42992
+ const body = path.get("body");
42993
+ let lastImportIndex = -1;
42994
+ for (let i = 0; i < body.length; i++) {
42995
+ if (body[i].isImportDeclaration()) {
42996
+ lastImportIndex = i;
42997
+ }
42998
+ }
42999
+ if (lastImportIndex >= 0) {
43000
+ body[lastImportIndex].insertAfter(declaration);
43001
+ } else {
43002
+ path.unshiftContainer("body", declaration);
43003
+ }
43004
+ }
43005
+ }
43006
+ }
43007
+ };
43008
+ }
42962
43009
  let BabelInstance = null;
42963
43010
  let pluginsRegistered = false;
42964
43011
  function registerPlugins(Babel) {
@@ -42966,6 +43013,7 @@ function registerPlugins(Babel) {
42966
43013
  Babel.registerPlugin("uses-to-import", usesToImportPlugin);
42967
43014
  Babel.registerPlugin("name-hoisting", nameHoistingPlugin);
42968
43015
  Babel.registerPlugin("jsx-newline-literal", jsxNewlineLiteralPlugin);
43016
+ Babel.registerPlugin("custom-component-injection", customComponentInjectionPlugin);
42969
43017
  pluginsRegistered = true;
42970
43018
  }
42971
43019
  async function getBabel() {
@@ -42976,28 +43024,34 @@ async function getBabel() {
42976
43024
  }
42977
43025
  return BabelInstance;
42978
43026
  }
42979
- function getTransformOptions(filename) {
43027
+ function getTransformOptions(filename, options) {
43028
+ const plugins2 = [
43029
+ // Transform <Uses> to import declarations (must run before JSX transform)
43030
+ "uses-to-import",
43031
+ // Hoist named elements to variable declarations (must run before JSX transform)
43032
+ "name-hoisting",
43033
+ // Preserve newlines in multi-line JSX text (must run before JSX transform)
43034
+ "jsx-newline-literal",
43035
+ // Transform JSX to jsx() calls
43036
+ ["transform-react-jsx", {
43037
+ runtime: "automatic",
43038
+ importSource: "pupt-lib"
43039
+ }]
43040
+ ];
43041
+ if (options == null ? void 0 : options.extraPlugins) {
43042
+ for (const plugin of options.extraPlugins) {
43043
+ plugins2.push(plugin);
43044
+ }
43045
+ }
42980
43046
  return {
42981
43047
  presets: ["typescript"],
42982
43048
  filename,
42983
- plugins: [
42984
- // Transform <Uses> to import declarations (must run before JSX transform)
42985
- "uses-to-import",
42986
- // Hoist named elements to variable declarations (must run before JSX transform)
42987
- "name-hoisting",
42988
- // Preserve newlines in multi-line JSX text (must run before JSX transform)
42989
- "jsx-newline-literal",
42990
- // Transform JSX to jsx() calls
42991
- ["transform-react-jsx", {
42992
- runtime: "automatic",
42993
- importSource: "pupt-lib"
42994
- }]
42995
- ]
43049
+ plugins: plugins2
42996
43050
  };
42997
43051
  }
42998
- async function transformWithBabelAsync(source, filename) {
43052
+ async function transformWithBabelAsync(source, filename, options) {
42999
43053
  const Babel = await getBabel();
43000
- const result = Babel.transform(source, getTransformOptions(filename));
43054
+ const result = Babel.transform(source, getTransformOptions(filename, options));
43001
43055
  if (!(result == null ? void 0 : result.code)) {
43002
43056
  throw new Error(`Failed to transform: ${filename}`);
43003
43057
  }
@@ -43010,11 +43064,12 @@ class Transformer2 {
43010
43064
  *
43011
43065
  * @param source - The TSX source code to transform
43012
43066
  * @param filename - Filename used for error messages and source maps
43067
+ * @param options - Optional transform configuration (e.g., extra plugins)
43013
43068
  * @returns The transformed JavaScript code
43014
43069
  * @throws Error if transformation fails
43015
43070
  */
43016
- async transformSourceAsync(source, filename) {
43017
- return transformWithBabelAsync(source, filename);
43071
+ async transformSourceAsync(source, filename, options) {
43072
+ return transformWithBabelAsync(source, filename, options);
43018
43073
  }
43019
43074
  }
43020
43075
  function isNodeEnvironment() {
@@ -43081,34 +43136,83 @@ async function resolveBareSpecifier(specifier) {
43081
43136
  throw new Error(`Cannot resolve module "${specifier}": ${message}`);
43082
43137
  }
43083
43138
  }
43139
+ let babelPackagesCache = null;
43140
+ async function loadBabelPackages() {
43141
+ if (babelPackagesCache) return babelPackagesCache;
43142
+ const babelModule = await import("./babel-DZMWDenp.js").then((n) => n.b);
43143
+ const Babel = babelModule.default || babelModule;
43144
+ const { parser, generator: generatorMod } = Babel.packages;
43145
+ const generate = typeof generatorMod === "function" ? generatorMod : generatorMod.default;
43146
+ babelPackagesCache = {
43147
+ parse: parser.parse.bind(parser),
43148
+ generate
43149
+ };
43150
+ return babelPackagesCache;
43151
+ }
43152
+ function walkAst(node, visitor) {
43153
+ if (!node || typeof node !== "object") return;
43154
+ if (node.type) {
43155
+ visitor(node);
43156
+ }
43157
+ for (const key of Object.keys(node)) {
43158
+ if (key === "type" || key === "start" || key === "end" || key === "loc") continue;
43159
+ const child = node[key];
43160
+ if (Array.isArray(child)) {
43161
+ for (const item of child) {
43162
+ if (item && typeof item === "object" && item.type) {
43163
+ walkAst(item, visitor);
43164
+ }
43165
+ }
43166
+ } else if (child && typeof child === "object" && child.type) {
43167
+ walkAst(child, visitor);
43168
+ }
43169
+ }
43170
+ }
43084
43171
  async function rewriteAllImports(code) {
43085
- const importRegex = /from\s+['"]([^'"]+)['"]|import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
43086
- const specifiers = /* @__PURE__ */ new Set();
43087
- let match;
43088
- while ((match = importRegex.exec(code)) !== null) {
43089
- const specifier = match[1] || match[2];
43090
- if (isBareSpecifier(specifier)) {
43091
- specifiers.add(specifier);
43172
+ const { parse, generate } = await loadBabelPackages();
43173
+ const ast = parse(code, { sourceType: "module", errorRecovery: true });
43174
+ const nodesToRewrite = [];
43175
+ for (const stmt of ast.program.body) {
43176
+ if (stmt.type === "ImportDeclaration" && stmt.source) {
43177
+ const specifier = stmt.source.value;
43178
+ if (isBareSpecifier(specifier)) {
43179
+ nodesToRewrite.push({ node: stmt.source, specifier });
43180
+ }
43181
+ }
43182
+ }
43183
+ walkAst(ast, (node) => {
43184
+ var _a2, _b2;
43185
+ if (node.type === "CallExpression" && ((_a2 = node.callee) == null ? void 0 : _a2.type) === "Import" && ((_b2 = node.arguments) == null ? void 0 : _b2.length) > 0 && node.arguments[0].type === "StringLiteral") {
43186
+ const specifier = node.arguments[0].value;
43187
+ if (isBareSpecifier(specifier)) {
43188
+ nodesToRewrite.push({ node: node.arguments[0], specifier });
43189
+ }
43092
43190
  }
43191
+ });
43192
+ if (nodesToRewrite.length === 0) {
43193
+ return code;
43093
43194
  }
43195
+ const uniqueSpecifiers = new Set(nodesToRewrite.map((n) => n.specifier));
43094
43196
  const resolutions = /* @__PURE__ */ new Map();
43095
- for (const specifier of specifiers) {
43197
+ for (const specifier of uniqueSpecifiers) {
43096
43198
  const resolved = await resolveBareSpecifier(specifier);
43097
43199
  resolutions.set(specifier, resolved);
43098
43200
  }
43099
- let rewritten = code;
43100
- for (const [specifier, resolved] of resolutions) {
43101
- const escaped = specifier.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
43102
- rewritten = rewritten.replace(
43103
- new RegExp(`from\\s+(['"])${escaped}\\1`, "g"),
43104
- `from $1${resolved}$1`
43105
- );
43106
- rewritten = rewritten.replace(
43107
- new RegExp(`import\\s*\\(\\s*(['"])${escaped}\\1\\s*\\)`, "g"),
43108
- `import($1${resolved}$1)`
43109
- );
43201
+ for (const { node, specifier } of nodesToRewrite) {
43202
+ const resolved = resolutions.get(specifier);
43203
+ if (resolved) {
43204
+ node.value = resolved;
43205
+ }
43206
+ }
43207
+ return generate(ast).code;
43208
+ }
43209
+ async function rewriteImportsForFile(code, filename) {
43210
+ try {
43211
+ return await rewriteAllImports(code);
43212
+ } catch (error) {
43213
+ const message = error instanceof Error ? error.message : String(error);
43214
+ throw new Error(`Failed to evaluate module ${filename}: ${message}`);
43110
43215
  }
43111
- return rewritten;
43112
43216
  }
43113
43217
  async function evaluateInNode(code, filename) {
43114
43218
  const fs = await import("fs/promises");
@@ -43116,7 +43220,7 @@ async function evaluateInNode(code, filename) {
43116
43220
  const os = await import("os");
43117
43221
  const crypto2 = await import("crypto");
43118
43222
  const { pathToFileURL } = await import("url");
43119
- const rewrittenCode = await rewriteAllImports(code);
43223
+ const rewrittenCode = await rewriteImportsForFile(code, filename);
43120
43224
  const hash = crypto2.createHash("md5").update(rewrittenCode).digest("hex").slice(0, 8);
43121
43225
  const tempDir = path.join(os.tmpdir(), "pupt-lib");
43122
43226
  await fs.mkdir(tempDir, { recursive: true });
@@ -43178,62 +43282,51 @@ function generateImports() {
43178
43282
  lines.push(aliases);
43179
43283
  return lines.join("\n");
43180
43284
  }
43181
- function extractUses(source) {
43182
- const uses = [];
43183
- const remaining = source.replace(/^\s*<Uses\s[^>]*\/>\s*$/gm, (match) => {
43184
- uses.push(match.trim());
43185
- return "";
43186
- });
43187
- return { uses, remaining };
43188
- }
43189
43285
  function preprocessSource(source, options) {
43190
43286
  const { filename } = options;
43191
43287
  if (!isPromptFile(filename)) {
43192
43288
  return source;
43193
43289
  }
43194
43290
  const imports = generateImports();
43195
- const { uses, remaining } = extractUses(source);
43196
- const usesSection = uses.length > 0 ? uses.join("\n") + "\n\n" : "";
43197
43291
  const result = `export default (
43198
- ${remaining}
43292
+ <>
43293
+ ${source}
43294
+ </>
43199
43295
  );`;
43200
43296
  return `// Preprocessed from: ${filename}
43201
43297
  ${imports}
43202
43298
 
43203
- ${usesSection}${result}`;
43299
+ ${result}`;
43204
43300
  }
43205
43301
  const CUSTOM_COMPONENTS_GLOBAL = "__PUPT_CUSTOM_COMPONENTS__";
43206
43302
  async function createPromptFromSource(source, filename, options = {}) {
43207
43303
  const { components } = options;
43208
- let processedSource = preprocessSource(source, { filename });
43304
+ const processedSource = preprocessSource(source, { filename });
43209
43305
  if (components && Object.keys(components).length > 0) {
43210
43306
  globalThis[CUSTOM_COMPONENTS_GLOBAL] = components;
43211
- const componentNames = Object.keys(components);
43212
- const extractCode = `const { ${componentNames.join(", ")} } = globalThis.${CUSTOM_COMPONENTS_GLOBAL};
43213
- `;
43214
- let lastImportEnd = 0;
43215
- const fullImportRegex = /import\s+(?:(?:\{[^}]*\}|[^;{]*)\s+from\s+)?['"][^'"]+['"];?/g;
43216
- let match;
43217
- while ((match = fullImportRegex.exec(processedSource)) !== null) {
43218
- const matchEnd = match.index + match[0].length;
43219
- if (matchEnd > lastImportEnd) {
43220
- lastImportEnd = matchEnd;
43221
- }
43222
- }
43223
- if (lastImportEnd > 0) {
43224
- processedSource = processedSource.slice(0, lastImportEnd) + "\n" + extractCode + processedSource.slice(lastImportEnd);
43225
- } else {
43226
- processedSource = extractCode + processedSource;
43227
- }
43228
43307
  }
43308
+ const extraPlugins = components && Object.keys(components).length > 0 ? [["custom-component-injection", {
43309
+ componentNames: Object.keys(components),
43310
+ globalKey: CUSTOM_COMPONENTS_GLOBAL
43311
+ }]] : void 0;
43229
43312
  try {
43230
43313
  const transformer = new Transformer2();
43231
- const code = await transformer.transformSourceAsync(processedSource, filename);
43314
+ const code = await transformer.transformSourceAsync(processedSource, filename, { extraPlugins });
43232
43315
  const module = await evaluateModule(code, { filename });
43233
43316
  if (module.default === void 0) {
43234
43317
  throw new Error(`${filename} must have a default export`);
43235
43318
  }
43236
- return module.default;
43319
+ let element = module.default;
43320
+ if (isPromptFile(filename) && element && element[TYPE] === Fragment) {
43321
+ const children = element[CHILDREN];
43322
+ const meaningful = children.filter(
43323
+ (child) => !(typeof child === "string" && child.trim() === "")
43324
+ );
43325
+ if (meaningful.length === 1) {
43326
+ element = meaningful[0];
43327
+ }
43328
+ }
43329
+ return element;
43237
43330
  } finally {
43238
43331
  if (components) {
43239
43332
  delete globalThis[CUSTOM_COMPONENTS_GLOBAL];
@@ -1 +1 @@
1
- {"version":3,"file":"create-prompt.d.ts","sourceRoot":"","sources":["../../src/create-prompt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CAC5C;AAED;;;GAGG;AACH,eAAO,MAAM,wBAAwB,+BAA+B,CAAC;AAErE;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,0BAA0B,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,SAAS,CAAC;CAC3E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,WAAW,CAAC,CAiEtB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,YAAY,CAChC,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,WAAW,CAAC,CAKtB"}
1
+ {"version":3,"file":"create-prompt.d.ts","sourceRoot":"","sources":["../../src/create-prompt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAY,MAAM,SAAS,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CAC5C;AAED;;;GAGG;AACH,eAAO,MAAM,wBAAwB,+BAA+B,CAAC;AAErE;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,0BAA0B,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,SAAS,CAAC;CAC3E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,WAAW,CAAC,CA8DtB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,YAAY,CAChC,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,WAAW,CAAC,CAKtB"}
@@ -0,0 +1,5 @@
1
+ import { PluginObj, types as BabelTypes } from '@babel/core';
2
+ export declare function customComponentInjectionPlugin({ types: t }: {
3
+ types: typeof BabelTypes;
4
+ }): PluginObj;
5
+ //# sourceMappingURL=custom-component-injection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-component-injection.d.ts","sourceRoot":"","sources":["../../../../src/services/babel-plugins/custom-component-injection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,aAAa,CAAC;AAOlE,wBAAgB,8BAA8B,CAC5C,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAAE,KAAK,EAAE,OAAO,UAAU,CAAA;CAAE,GACzC,SAAS,CAoDX"}
@@ -1,4 +1,5 @@
1
1
  export { usesToImportPlugin } from './uses-to-import';
2
2
  export { nameHoistingPlugin } from './name-hoisting';
3
3
  export { jsxNewlineLiteralPlugin } from './jsx-newline-literal';
4
+ export { customComponentInjectionPlugin } from './custom-component-injection';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/services/babel-plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/services/babel-plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,8BAA8B,EAAE,MAAM,8BAA8B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"module-evaluator.d.ts","sourceRoot":"","sources":["../../../src/services/module-evaluator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAgBH,MAAM,WAAW,eAAe;IAC9B,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAC;CAClB;AA+LD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC,CAexD"}
1
+ {"version":3,"file":"module-evaluator.d.ts","sourceRoot":"","sources":["../../../src/services/module-evaluator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAgBH,MAAM,WAAW,eAAe;IAC9B,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAC;CAClB;AA4RD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC,CAexD"}
@@ -24,8 +24,9 @@ export declare function isPromptFile(filename: string): boolean;
24
24
  *
25
25
  * .prompt files always receive:
26
26
  * - Import injection for all built-in components
27
- * - Extraction of <Uses> elements to module level (for the babel plugin)
28
- * - Export default wrapping around the remaining JSX content
27
+ * - Fragment wrapping around the content (so the uses-to-import Babel plugin
28
+ * can find and transform any <Uses> elements within the JSX tree)
29
+ * - Export default wrapping
29
30
  *
30
31
  * Non-.prompt files are returned unchanged.
31
32
  *
@@ -1 +1 @@
1
- {"version":3,"file":"preprocessor.d.ts","sourceRoot":"","sources":["../../../src/services/preprocessor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAQH,MAAM,WAAW,iBAAiB;IAChC,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEtD;AAkDD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAiBnF"}
1
+ {"version":3,"file":"preprocessor.d.ts","sourceRoot":"","sources":["../../../src/services/preprocessor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAQH,MAAM,WAAW,iBAAiB;IAChC,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEtD;AAkCD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAiBnF"}
@@ -4,6 +4,10 @@
4
4
  *
5
5
  * Works in both Node.js and browser environments.
6
6
  */
7
+ export interface TransformOptions {
8
+ /** Additional Babel plugins to include in the transform. Each entry is [pluginName, options]. */
9
+ extraPlugins?: Array<[string, Record<string, unknown>]>;
10
+ }
7
11
  export declare class Transformer {
8
12
  /**
9
13
  * Transform a source string containing TSX code.
@@ -11,9 +15,10 @@ export declare class Transformer {
11
15
  *
12
16
  * @param source - The TSX source code to transform
13
17
  * @param filename - Filename used for error messages and source maps
18
+ * @param options - Optional transform configuration (e.g., extra plugins)
14
19
  * @returns The transformed JavaScript code
15
20
  * @throws Error if transformation fails
16
21
  */
17
- transformSourceAsync(source: string, filename: string): Promise<string>;
22
+ transformSourceAsync(source: string, filename: string, options?: TransformOptions): Promise<string>;
18
23
  }
19
24
  //# sourceMappingURL=transformer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transformer.d.ts","sourceRoot":"","sources":["../../../src/services/transformer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAkFH,qBAAa,WAAW;IACtB;;;;;;;;OAQG;IACG,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAG9E"}
1
+ {"version":3,"file":"transformer.d.ts","sourceRoot":"","sources":["../../../src/services/transformer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,MAAM,WAAW,gBAAgB;IAC/B,iGAAiG;IACjG,YAAY,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CACzD;AA0FD,qBAAa,WAAW;IACtB;;;;;;;;;OASG;IACG,oBAAoB,CACxB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,MAAM,CAAC;CAGnB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pupt-lib",
3
- "version": "1.3.8",
3
+ "version": "1.3.9",
4
4
  "description": "TypeScript library for creating AI prompts using JSX syntax",
5
5
  "license": "MIT",
6
6
  "author": "",