pupt-lib 1.3.4 → 1.3.5
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/components/data/File.d.ts +1 -1
- package/dist/components/data/File.d.ts.map +1 -1
- package/dist/index.js +115 -38
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/services/babel-plugins/index.d.ts +1 -0
- package/dist/src/services/babel-plugins/index.d.ts.map +1 -1
- package/dist/src/services/babel-plugins/jsx-newline-literal.d.ts +9 -0
- package/dist/src/services/babel-plugins/jsx-newline-literal.d.ts.map +1 -0
- package/dist/src/services/file-search-engine.d.ts +14 -3
- package/dist/src/services/file-search-engine.d.ts.map +1 -1
- package/dist/src/services/preprocessor.d.ts +18 -20
- package/dist/src/services/preprocessor.d.ts.map +1 -1
- package/dist/src/services/transformer.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -31,7 +31,7 @@ export declare class File extends Component<FileProps> {
|
|
|
31
31
|
encoding: z.ZodOptional<z.ZodString>;
|
|
32
32
|
}, z.ZodTypeAny, "passthrough">>;
|
|
33
33
|
static hoistName: boolean;
|
|
34
|
-
render({ path, language, encoding }: FileProps, _resolvedValue: void, _context: RenderContext): PuptNode
|
|
34
|
+
render({ path, language, encoding }: FileProps, _resolvedValue: void, _context: RenderContext): Promise<PuptNode>;
|
|
35
35
|
}
|
|
36
36
|
export {};
|
|
37
37
|
//# sourceMappingURL=File.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"File.d.ts","sourceRoot":"","sources":["../../../components/data/File.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAKxD,eAAO,MAAM,UAAU;;;;;;;;;;;;gCAIP,CAAC;AAEjB,KAAK,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,cAAc,CAAA;CAAE,CAAC;AAyD5E,qBAAa,IAAK,SAAQ,SAAS,CAAC,SAAS,CAAC;IAC5C,MAAM,CAAC,MAAM;;;;;;;;;;;;qCAAc;IAC3B,MAAM,CAAC,SAAS,UAAQ;
|
|
1
|
+
{"version":3,"file":"File.d.ts","sourceRoot":"","sources":["../../../components/data/File.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAKxD,eAAO,MAAM,UAAU;;;;;;;;;;;;gCAIP,CAAC;AAEjB,KAAK,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,cAAc,CAAA;CAAE,CAAC;AAyD5E,qBAAa,IAAK,SAAQ,SAAS,CAAC,SAAS,CAAC;IAC5C,MAAM,CAAC,MAAM;;;;;;;;;;;;qCAAc;IAC3B,MAAM,CAAC,SAAS,UAAQ;IAElB,MAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAkB,EAAE,EAAE,SAAS,EAAE,cAAc,EAAE,IAAI,EAAE,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,QAAQ,CAAC;CA+BlI"}
|
package/dist/index.js
CHANGED
|
@@ -42869,12 +42869,79 @@ function nameHoistingPlugin({ types: t }) {
|
|
|
42869
42869
|
}
|
|
42870
42870
|
};
|
|
42871
42871
|
}
|
|
42872
|
+
function isBlockLikeText(text) {
|
|
42873
|
+
if (text[0] !== "\n") {
|
|
42874
|
+
return false;
|
|
42875
|
+
}
|
|
42876
|
+
const lastNewlineIdx = text.lastIndexOf("\n");
|
|
42877
|
+
const trailing = text.slice(lastNewlineIdx + 1);
|
|
42878
|
+
if (trailing.trim() !== "") {
|
|
42879
|
+
return false;
|
|
42880
|
+
}
|
|
42881
|
+
return true;
|
|
42882
|
+
}
|
|
42883
|
+
function dedentJsxText(text) {
|
|
42884
|
+
const lines = text.split("\n");
|
|
42885
|
+
while (lines.length > 0 && lines[0].trim() === "") {
|
|
42886
|
+
lines.shift();
|
|
42887
|
+
}
|
|
42888
|
+
while (lines.length > 0 && lines[lines.length - 1].trim() === "") {
|
|
42889
|
+
lines.pop();
|
|
42890
|
+
}
|
|
42891
|
+
if (lines.length === 0) {
|
|
42892
|
+
return null;
|
|
42893
|
+
}
|
|
42894
|
+
let minIndent = Infinity;
|
|
42895
|
+
for (const line of lines) {
|
|
42896
|
+
if (line.trim() === "") continue;
|
|
42897
|
+
const match = line.match(/^(\s*)/);
|
|
42898
|
+
const indent = match ? match[1].length : 0;
|
|
42899
|
+
if (indent < minIndent) {
|
|
42900
|
+
minIndent = indent;
|
|
42901
|
+
}
|
|
42902
|
+
}
|
|
42903
|
+
if (minIndent === Infinity) {
|
|
42904
|
+
minIndent = 0;
|
|
42905
|
+
}
|
|
42906
|
+
const dedented = lines.map((line) => {
|
|
42907
|
+
if (line.trim() === "") return "";
|
|
42908
|
+
return line.slice(minIndent);
|
|
42909
|
+
});
|
|
42910
|
+
return dedented.join("\n");
|
|
42911
|
+
}
|
|
42912
|
+
function jsxNewlineLiteralPlugin({ types: t }) {
|
|
42913
|
+
return {
|
|
42914
|
+
name: "pupt-jsx-newline-literal",
|
|
42915
|
+
visitor: {
|
|
42916
|
+
JSXText(path) {
|
|
42917
|
+
const text = path.node.value;
|
|
42918
|
+
if (!text.includes("\n")) {
|
|
42919
|
+
return;
|
|
42920
|
+
}
|
|
42921
|
+
if (text.trim() === "") {
|
|
42922
|
+
return;
|
|
42923
|
+
}
|
|
42924
|
+
if (!isBlockLikeText(text)) {
|
|
42925
|
+
return;
|
|
42926
|
+
}
|
|
42927
|
+
const dedented = dedentJsxText(text);
|
|
42928
|
+
if (dedented === null) {
|
|
42929
|
+
return;
|
|
42930
|
+
}
|
|
42931
|
+
path.replaceWith(
|
|
42932
|
+
t.jsxExpressionContainer(t.stringLiteral(dedented))
|
|
42933
|
+
);
|
|
42934
|
+
}
|
|
42935
|
+
}
|
|
42936
|
+
};
|
|
42937
|
+
}
|
|
42872
42938
|
let BabelInstance = null;
|
|
42873
42939
|
let pluginsRegistered = false;
|
|
42874
42940
|
function registerPlugins(Babel) {
|
|
42875
42941
|
if (pluginsRegistered) return;
|
|
42876
42942
|
Babel.registerPlugin("uses-to-import", usesToImportPlugin);
|
|
42877
42943
|
Babel.registerPlugin("name-hoisting", nameHoistingPlugin);
|
|
42944
|
+
Babel.registerPlugin("jsx-newline-literal", jsxNewlineLiteralPlugin);
|
|
42878
42945
|
pluginsRegistered = true;
|
|
42879
42946
|
}
|
|
42880
42947
|
async function getBabel() {
|
|
@@ -42894,6 +42961,8 @@ function getTransformOptions(filename) {
|
|
|
42894
42961
|
"uses-to-import",
|
|
42895
42962
|
// Hoist named elements to variable declarations (must run before JSX transform)
|
|
42896
42963
|
"name-hoisting",
|
|
42964
|
+
// Preserve newlines in multi-line JSX text (must run before JSX transform)
|
|
42965
|
+
"jsx-newline-literal",
|
|
42897
42966
|
// Transform JSX to jsx() calls
|
|
42898
42967
|
["transform-react-jsx", {
|
|
42899
42968
|
runtime: "automatic",
|
|
@@ -43068,17 +43137,6 @@ async function evaluateModule(code, options) {
|
|
|
43068
43137
|
function isPromptFile(filename) {
|
|
43069
43138
|
return filename.endsWith(".prompt");
|
|
43070
43139
|
}
|
|
43071
|
-
function needsImportInjection(source) {
|
|
43072
|
-
const hasImport = /^\s*import\s+/m.test(source);
|
|
43073
|
-
return !hasImport;
|
|
43074
|
-
}
|
|
43075
|
-
function needsExportWrapper(source) {
|
|
43076
|
-
const hasExportDefault = /^\s*export\s+default\s+/m.test(source);
|
|
43077
|
-
return !hasExportDefault;
|
|
43078
|
-
}
|
|
43079
|
-
function needsPreprocessing(source) {
|
|
43080
|
-
return needsImportInjection(source) || needsExportWrapper(source);
|
|
43081
|
-
}
|
|
43082
43140
|
function generateImports() {
|
|
43083
43141
|
const builtinComponents = getBuiltinComponents();
|
|
43084
43142
|
const askComponents = getAskComponents();
|
|
@@ -43096,27 +43154,29 @@ function generateImports() {
|
|
|
43096
43154
|
lines.push(aliases);
|
|
43097
43155
|
return lines.join("\n");
|
|
43098
43156
|
}
|
|
43157
|
+
function extractUses(source) {
|
|
43158
|
+
const uses = [];
|
|
43159
|
+
const remaining = source.replace(/^\s*<Uses\s[^>]*\/>\s*$/gm, (match) => {
|
|
43160
|
+
uses.push(match.trim());
|
|
43161
|
+
return "";
|
|
43162
|
+
});
|
|
43163
|
+
return { uses, remaining };
|
|
43164
|
+
}
|
|
43099
43165
|
function preprocessSource(source, options) {
|
|
43100
43166
|
const { filename } = options;
|
|
43101
|
-
|
|
43102
|
-
const wrapExport = needsExportWrapper(source);
|
|
43103
|
-
if (!injectImports && !wrapExport) {
|
|
43167
|
+
if (!isPromptFile(filename)) {
|
|
43104
43168
|
return source;
|
|
43105
43169
|
}
|
|
43106
|
-
const imports =
|
|
43107
|
-
|
|
43108
|
-
|
|
43109
|
-
|
|
43110
|
-
${
|
|
43170
|
+
const imports = generateImports();
|
|
43171
|
+
const { uses, remaining } = extractUses(source);
|
|
43172
|
+
const usesSection = uses.length > 0 ? uses.join("\n") + "\n\n" : "";
|
|
43173
|
+
const result = `export default (
|
|
43174
|
+
${remaining}
|
|
43111
43175
|
);`;
|
|
43112
|
-
}
|
|
43113
|
-
if (injectImports) {
|
|
43114
|
-
result = `// Preprocessed from: ${filename}
|
|
43176
|
+
return `// Preprocessed from: ${filename}
|
|
43115
43177
|
${imports}
|
|
43116
43178
|
|
|
43117
|
-
${result}`;
|
|
43118
|
-
}
|
|
43119
|
-
return result;
|
|
43179
|
+
${usesSection}${result}`;
|
|
43120
43180
|
}
|
|
43121
43181
|
const isNode = typeof process !== "undefined" && ((_b = process.versions) == null ? void 0 : _b.node);
|
|
43122
43182
|
async function resolveLocalPath(source) {
|
|
@@ -45727,16 +45787,16 @@ function getBasename(filePath) {
|
|
|
45727
45787
|
return lastSlash >= 0 ? filePath.slice(lastSlash + 1) : filePath;
|
|
45728
45788
|
}
|
|
45729
45789
|
class File extends Component {
|
|
45730
|
-
render({ path, language, encoding = "utf-8" }, _resolvedValue, _context) {
|
|
45790
|
+
async render({ path, language, encoding = "utf-8" }, _resolvedValue, _context) {
|
|
45731
45791
|
if (isBrowser$1) {
|
|
45732
45792
|
return `[Error: File component is not available in browser environments. Path: ${path}]`;
|
|
45733
45793
|
}
|
|
45734
45794
|
try {
|
|
45735
45795
|
if (!fsModule$1) {
|
|
45736
|
-
fsModule$1 =
|
|
45796
|
+
fsModule$1 = await import("fs");
|
|
45737
45797
|
}
|
|
45738
45798
|
if (!pathModule$1) {
|
|
45739
|
-
pathModule$1 =
|
|
45799
|
+
pathModule$1 = await import("path");
|
|
45740
45800
|
}
|
|
45741
45801
|
const content = fsModule$1.readFileSync(path, { encoding });
|
|
45742
45802
|
const ext = getExtname(path);
|
|
@@ -47950,18 +48010,26 @@ const isBrowser = typeof window !== "undefined" && typeof window.document !== "u
|
|
|
47950
48010
|
let pathModule = null;
|
|
47951
48011
|
let fsModule = null;
|
|
47952
48012
|
let osModule = null;
|
|
48013
|
+
async function loadNodeModules() {
|
|
48014
|
+
if (isBrowser) return;
|
|
48015
|
+
if (pathModule && fsModule && osModule) return;
|
|
48016
|
+
const [p, f, o] = await Promise.all([
|
|
48017
|
+
import("path"),
|
|
48018
|
+
import("fs"),
|
|
48019
|
+
import("os")
|
|
48020
|
+
]);
|
|
48021
|
+
pathModule = p;
|
|
48022
|
+
fsModule = f;
|
|
48023
|
+
osModule = o;
|
|
48024
|
+
}
|
|
47953
48025
|
function getNodeModules() {
|
|
47954
48026
|
if (isBrowser) {
|
|
47955
48027
|
throw new Error("FileSearchEngine is not available in browser environments");
|
|
47956
48028
|
}
|
|
47957
|
-
if (!pathModule) {
|
|
47958
|
-
|
|
47959
|
-
|
|
47960
|
-
|
|
47961
|
-
fsModule = require("fs");
|
|
47962
|
-
}
|
|
47963
|
-
if (!osModule) {
|
|
47964
|
-
osModule = require("os");
|
|
48029
|
+
if (!pathModule || !fsModule || !osModule) {
|
|
48030
|
+
throw new Error(
|
|
48031
|
+
"Node modules not loaded. Use FileSearchEngine.create() or await loadNodeModules() before constructing FileSearchEngine."
|
|
48032
|
+
);
|
|
47965
48033
|
}
|
|
47966
48034
|
return { path: pathModule, fs: fsModule, os: osModule };
|
|
47967
48035
|
}
|
|
@@ -47979,6 +48047,14 @@ class FileSearchEngine {
|
|
|
47979
48047
|
this.cacheTimeout = config.cacheTimeout ?? 5e3;
|
|
47980
48048
|
this.maxCacheEntries = config.maxCacheEntries ?? 100;
|
|
47981
48049
|
}
|
|
48050
|
+
/**
|
|
48051
|
+
* Create a FileSearchEngine instance, loading Node.js modules first.
|
|
48052
|
+
* This is the preferred way to create a FileSearchEngine in ESM contexts.
|
|
48053
|
+
*/
|
|
48054
|
+
static async create(config) {
|
|
48055
|
+
await loadNodeModules();
|
|
48056
|
+
return new FileSearchEngine(config);
|
|
48057
|
+
}
|
|
47982
48058
|
/**
|
|
47983
48059
|
* Search for files matching the query.
|
|
47984
48060
|
* Supports directory navigation and fuzzy matching.
|
|
@@ -48218,7 +48294,8 @@ class FileSearchEngine {
|
|
|
48218
48294
|
}
|
|
48219
48295
|
}
|
|
48220
48296
|
}
|
|
48221
|
-
function createFileSearchEngine(config) {
|
|
48297
|
+
async function createFileSearchEngine(config) {
|
|
48298
|
+
await loadNodeModules();
|
|
48222
48299
|
return new FileSearchEngine(config);
|
|
48223
48300
|
}
|
|
48224
48301
|
const VERSION = "0.0.0-development";
|
|
@@ -48340,7 +48417,7 @@ export {
|
|
|
48340
48417
|
isElementOfType,
|
|
48341
48418
|
isPromptFile,
|
|
48342
48419
|
isPuptElement,
|
|
48343
|
-
|
|
48420
|
+
loadNodeModules,
|
|
48344
48421
|
partitionChildren,
|
|
48345
48422
|
preprocessSource,
|
|
48346
48423
|
render,
|
package/dist/src/index.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export { evaluateFormula } from './services/formula-parser';
|
|
|
19
19
|
export { Transformer } from './services/transformer';
|
|
20
20
|
export { evaluateModule } from './services/module-evaluator';
|
|
21
21
|
export type { EvaluateOptions } from './services/module-evaluator';
|
|
22
|
-
export { preprocessSource, isPromptFile
|
|
22
|
+
export { preprocessSource, isPromptFile } from './services/preprocessor';
|
|
23
23
|
export type { PreprocessOptions } from './services/preprocessor';
|
|
24
24
|
export { getBuiltinComponents, getAskComponents, getAskShorthand, getStructuralComponents, } from './services/component-discovery';
|
|
25
25
|
export { ModuleLoader } from './services/module-loader';
|
|
@@ -34,6 +34,6 @@ export { Pupt } from './api';
|
|
|
34
34
|
export type { DiscoveredPromptWithMethods } from './api';
|
|
35
35
|
export { createSearchEngine } from './services/search-engine';
|
|
36
36
|
export type { SearchEngine } from './services/search-engine';
|
|
37
|
-
export { FileSearchEngine, createFileSearchEngine } from './services/file-search-engine';
|
|
37
|
+
export { FileSearchEngine, createFileSearchEngine, loadNodeModules } from './services/file-search-engine';
|
|
38
38
|
export type { FileInfo, FileSearchResult, FileSearchEngineConfig, } from './services/file-search-engine';
|
|
39
39
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,sBAAsB,CAAC;AAG3C,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGtE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAG/D,YAAY,EACV,QAAQ,EACR,WAAW,EACX,aAAa,EACb,WAAW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gCAAgC,CAAC;AAIxC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAG/F,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,wBAAwB,EACxB,8BAA8B,GAC/B,MAAM,4BAA4B,CAAC;AACpC,YAAY,EACV,WAAW,EACX,UAAU,EACV,UAAU,EACV,SAAS,EACT,uBAAuB,GACxB,MAAM,4BAA4B,CAAC;AAIpC,cAAc,eAAe,CAAC;AAG9B,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG3E,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACvE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAG3D,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC7B,YAAY,EAAE,2BAA2B,EAAE,MAAM,OAAO,CAAC;AAGzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,YAAY,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAG7D,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAC1G,YAAY,EACV,QAAQ,EACR,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,+BAA+B,CAAC"}
|
|
@@ -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"}
|
|
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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PluginObj, types as BabelTypes } from '@babel/core';
|
|
2
|
+
/**
|
|
3
|
+
* Babel plugin that converts block-like multi-line JSXText nodes into
|
|
4
|
+
* JSXExpressionContainers with string literals to preserve newlines.
|
|
5
|
+
*/
|
|
6
|
+
export declare function jsxNewlineLiteralPlugin({ types: t }: {
|
|
7
|
+
types: typeof BabelTypes;
|
|
8
|
+
}): PluginObj;
|
|
9
|
+
//# sourceMappingURL=jsx-newline-literal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-newline-literal.d.ts","sourceRoot":"","sources":["../../../../src/services/babel-plugins/jsx-newline-literal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,aAAa,CAAC;AAsFlE;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAAE,KAAK,EAAE,OAAO,UAAU,CAAA;CAAE,GAAG,SAAS,CAsC7F"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
type PathModule = typeof import('path');
|
|
2
2
|
type FsModule = typeof import('fs');
|
|
3
3
|
type OsModule = typeof import('os');
|
|
4
|
+
/**
|
|
5
|
+
* Load Node.js modules asynchronously using dynamic import().
|
|
6
|
+
* Must be called before using getNodeModules().
|
|
7
|
+
* Safe to call multiple times (subsequent calls are no-ops).
|
|
8
|
+
*/
|
|
9
|
+
export declare function loadNodeModules(): Promise<void>;
|
|
4
10
|
/**
|
|
5
11
|
* Inject mock modules for testing. Only use in test environments.
|
|
6
12
|
* @internal
|
|
@@ -68,6 +74,11 @@ export declare class FileSearchEngine {
|
|
|
68
74
|
private cacheTimeout;
|
|
69
75
|
private cacheTimestamps;
|
|
70
76
|
private maxCacheEntries;
|
|
77
|
+
/**
|
|
78
|
+
* Create a FileSearchEngine instance, loading Node.js modules first.
|
|
79
|
+
* This is the preferred way to create a FileSearchEngine in ESM contexts.
|
|
80
|
+
*/
|
|
81
|
+
static create(config?: FileSearchEngineConfig): Promise<FileSearchEngine>;
|
|
71
82
|
constructor(config?: FileSearchEngineConfig);
|
|
72
83
|
/**
|
|
73
84
|
* Search for files matching the query.
|
|
@@ -152,11 +163,11 @@ export declare class FileSearchEngine {
|
|
|
152
163
|
private addToCache;
|
|
153
164
|
}
|
|
154
165
|
/**
|
|
155
|
-
* Create a new FileSearchEngine instance.
|
|
166
|
+
* Create a new FileSearchEngine instance, loading Node.js modules first.
|
|
156
167
|
*
|
|
157
168
|
* @param config - Configuration options
|
|
158
|
-
* @returns FileSearchEngine instance
|
|
169
|
+
* @returns Promise resolving to FileSearchEngine instance
|
|
159
170
|
*/
|
|
160
|
-
export declare function createFileSearchEngine(config?: FileSearchEngineConfig): FileSearchEngine
|
|
171
|
+
export declare function createFileSearchEngine(config?: FileSearchEngineConfig): Promise<FileSearchEngine>;
|
|
161
172
|
export {};
|
|
162
173
|
//# sourceMappingURL=file-search-engine.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-search-engine.d.ts","sourceRoot":"","sources":["../../../src/services/file-search-engine.ts"],"names":[],"mappings":"AAIA,KAAK,UAAU,GAAG,cAAc,MAAM,CAAC,CAAC;AACxC,KAAK,QAAQ,GAAG,cAAc,IAAI,CAAC,CAAC;AACpC,KAAK,QAAQ,GAAG,cAAc,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"file-search-engine.d.ts","sourceRoot":"","sources":["../../../src/services/file-search-engine.ts"],"names":[],"mappings":"AAIA,KAAK,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AsB,CAAC,MAAM,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAGvG"}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Preprocessor for .prompt files.
|
|
3
3
|
* Injects imports for built-in components and wraps raw JSX with export default.
|
|
4
|
+
*
|
|
5
|
+
* Preprocessing is determined by file extension, not by scanning source content.
|
|
6
|
+
* .prompt files always receive full preprocessing (import injection + export wrapping).
|
|
7
|
+
* All other files (.tsx, .ts, etc.) are returned unchanged — they are expected to
|
|
8
|
+
* manage their own imports and exports.
|
|
9
|
+
*
|
|
10
|
+
* This avoids false positives from content-based regex detection, where non-JS
|
|
11
|
+
* `import` keywords (e.g., Python's `import hashlib`) or `export default` inside
|
|
12
|
+
* code examples could be mistakenly detected as real JS statements (issue #29).
|
|
4
13
|
*/
|
|
5
14
|
export interface PreprocessOptions {
|
|
6
15
|
/** Original filename for error messages */
|
|
@@ -11,28 +20,17 @@ export interface PreprocessOptions {
|
|
|
11
20
|
*/
|
|
12
21
|
export declare function isPromptFile(filename: string): boolean;
|
|
13
22
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*/
|
|
23
|
-
export declare function needsExportWrapper(source: string): boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Check if source code needs any preprocessing.
|
|
26
|
-
* Returns true if the source needs import injection or export wrapper.
|
|
27
|
-
* @deprecated Use needsImportInjection and needsExportWrapper instead
|
|
28
|
-
*/
|
|
29
|
-
export declare function needsPreprocessing(source: string): boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Preprocess source code for .prompt files and raw JSX.
|
|
32
|
-
* Injects imports for built-in components if needed, and wraps with export default if needed.
|
|
23
|
+
* Preprocess source code for .prompt files.
|
|
24
|
+
*
|
|
25
|
+
* .prompt files always receive:
|
|
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
|
|
29
|
+
*
|
|
30
|
+
* Non-.prompt files are returned unchanged.
|
|
33
31
|
*
|
|
34
32
|
* @param source - Raw source code
|
|
35
|
-
* @param options - Preprocessing options
|
|
33
|
+
* @param options - Preprocessing options (must include filename)
|
|
36
34
|
* @returns Preprocessed source code ready for Babel transformation
|
|
37
35
|
*/
|
|
38
36
|
export declare function preprocessSource(source: string, options: PreprocessOptions): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preprocessor.d.ts","sourceRoot":"","sources":["../../../src/services/preprocessor.ts"],"names":[],"mappings":"AAAA
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformer.d.ts","sourceRoot":"","sources":["../../../src/services/transformer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
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"}
|