pupt-lib 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/dist/components/ask/Choice.d.ts +155 -0
- package/dist/components/ask/Choice.d.ts.map +1 -0
- package/dist/components/ask/Confirm.d.ts +61 -0
- package/dist/components/ask/Confirm.d.ts.map +1 -0
- package/dist/components/ask/Date.d.ts +78 -0
- package/dist/components/ask/Date.d.ts.map +1 -0
- package/dist/components/ask/Editor.d.ts +66 -0
- package/dist/components/ask/Editor.d.ts.map +1 -0
- package/dist/components/ask/File.d.ts +84 -0
- package/dist/components/ask/File.d.ts.map +1 -0
- package/dist/components/ask/Label.d.ts +27 -0
- package/dist/components/ask/Label.d.ts.map +1 -0
- package/dist/components/ask/MultiSelect.d.ts +147 -0
- package/dist/components/ask/MultiSelect.d.ts.map +1 -0
- package/dist/components/ask/Number.d.ts +72 -0
- package/dist/components/ask/Number.d.ts.map +1 -0
- package/dist/components/ask/Option.d.ts +28 -0
- package/dist/components/ask/Option.d.ts.map +1 -0
- package/dist/components/ask/Path.d.ts +72 -0
- package/dist/components/ask/Path.d.ts.map +1 -0
- package/dist/components/ask/Rating.d.ts +78 -0
- package/dist/components/ask/Rating.d.ts.map +1 -0
- package/dist/components/ask/ReviewFile.d.ts +78 -0
- package/dist/components/ask/ReviewFile.d.ts.map +1 -0
- package/dist/components/ask/Secret.d.ts +66 -0
- package/dist/components/ask/Secret.d.ts.map +1 -0
- package/dist/components/ask/Select.d.ts +135 -0
- package/dist/components/ask/Select.d.ts.map +1 -0
- package/dist/components/ask/Text.d.ts +66 -0
- package/dist/components/ask/Text.d.ts.map +1 -0
- package/dist/components/ask/index.d.ts +34 -0
- package/dist/components/ask/index.d.ts.map +1 -0
- package/dist/components/ask/utils.d.ts +26 -0
- package/dist/components/ask/utils.d.ts.map +1 -0
- package/dist/components/control/ForEach.d.ts +31 -0
- package/dist/components/control/ForEach.d.ts.map +1 -0
- package/dist/components/control/If.d.ts +35 -0
- package/dist/components/control/If.d.ts.map +1 -0
- package/dist/components/control/index.d.ts +3 -0
- package/dist/components/control/index.d.ts.map +1 -0
- package/dist/components/data/Code.d.ts +30 -0
- package/dist/components/data/Code.d.ts.map +1 -0
- package/dist/components/data/Data.d.ts +30 -0
- package/dist/components/data/Data.d.ts.map +1 -0
- package/dist/components/data/File.d.ts +37 -0
- package/dist/components/data/File.d.ts.map +1 -0
- package/dist/components/data/Json.d.ts +24 -0
- package/dist/components/data/Json.d.ts.map +1 -0
- package/dist/components/data/Xml.d.ts +24 -0
- package/dist/components/data/Xml.d.ts.map +1 -0
- package/dist/components/data/index.d.ts +6 -0
- package/dist/components/data/index.d.ts.map +1 -0
- package/dist/components/examples/Example.d.ts +16 -0
- package/dist/components/examples/Example.d.ts.map +1 -0
- package/dist/components/examples/ExampleInput.d.ts +12 -0
- package/dist/components/examples/ExampleInput.d.ts.map +1 -0
- package/dist/components/examples/ExampleOutput.d.ts +12 -0
- package/dist/components/examples/ExampleOutput.d.ts.map +1 -0
- package/dist/components/examples/Examples.d.ts +12 -0
- package/dist/components/examples/Examples.d.ts.map +1 -0
- package/dist/components/examples/NegativeExample.d.ts +24 -0
- package/dist/components/examples/NegativeExample.d.ts.map +1 -0
- package/dist/components/examples/index.d.ts +6 -0
- package/dist/components/examples/index.d.ts.map +1 -0
- package/dist/components/index.d.ts +10 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/manifest.d.ts +15 -0
- package/dist/components/manifest.d.ts.map +1 -0
- package/dist/components/meta/Uses.d.ts +97 -0
- package/dist/components/meta/Uses.d.ts.map +1 -0
- package/dist/components/meta/index.d.ts +2 -0
- package/dist/components/meta/index.d.ts.map +1 -0
- package/dist/components/post-execution/OpenUrl.d.ts +28 -0
- package/dist/components/post-execution/OpenUrl.d.ts.map +1 -0
- package/dist/components/post-execution/PostExecution.d.ts +12 -0
- package/dist/components/post-execution/PostExecution.d.ts.map +1 -0
- package/dist/components/post-execution/ReviewFile.d.ts +29 -0
- package/dist/components/post-execution/ReviewFile.d.ts.map +1 -0
- package/dist/components/post-execution/RunCommand.d.ts +34 -0
- package/dist/components/post-execution/RunCommand.d.ts.map +1 -0
- package/dist/components/post-execution/index.d.ts +5 -0
- package/dist/components/post-execution/index.d.ts.map +1 -0
- package/dist/components/presets/constraint-presets.d.ts +13 -0
- package/dist/components/presets/constraint-presets.d.ts.map +1 -0
- package/dist/components/presets/default-constraints.d.ts +6 -0
- package/dist/components/presets/default-constraints.d.ts.map +1 -0
- package/dist/components/presets/guardrail-presets.d.ts +22 -0
- package/dist/components/presets/guardrail-presets.d.ts.map +1 -0
- package/dist/components/presets/index.d.ts +13 -0
- package/dist/components/presets/index.d.ts.map +1 -0
- package/dist/components/presets/provider-adaptations.d.ts +30 -0
- package/dist/components/presets/provider-adaptations.d.ts.map +1 -0
- package/dist/components/presets/role-presets.d.ts +19 -0
- package/dist/components/presets/role-presets.d.ts.map +1 -0
- package/dist/components/presets/steps-presets.d.ts +12 -0
- package/dist/components/presets/steps-presets.d.ts.map +1 -0
- package/dist/components/presets/task-presets.d.ts +14 -0
- package/dist/components/presets/task-presets.d.ts.map +1 -0
- package/dist/components/reasoning/ChainOfThought.d.ts +36 -0
- package/dist/components/reasoning/ChainOfThought.d.ts.map +1 -0
- package/dist/components/reasoning/Step.d.ts +24 -0
- package/dist/components/reasoning/Step.d.ts.map +1 -0
- package/dist/components/reasoning/Steps.d.ts +69 -0
- package/dist/components/reasoning/Steps.d.ts.map +1 -0
- package/dist/components/reasoning/index.d.ts +4 -0
- package/dist/components/reasoning/index.d.ts.map +1 -0
- package/dist/components/structural/Audience.d.ts +55 -0
- package/dist/components/structural/Audience.d.ts.map +1 -0
- package/dist/components/structural/Constraint.d.ts +49 -0
- package/dist/components/structural/Constraint.d.ts.map +1 -0
- package/dist/components/structural/Constraints.d.ts +50 -0
- package/dist/components/structural/Constraints.d.ts.map +1 -0
- package/dist/components/structural/Context.d.ts +72 -0
- package/dist/components/structural/Context.d.ts.map +1 -0
- package/dist/components/structural/Contexts.d.ts +36 -0
- package/dist/components/structural/Contexts.d.ts.map +1 -0
- package/dist/components/structural/Criterion.d.ts +36 -0
- package/dist/components/structural/Criterion.d.ts.map +1 -0
- package/dist/components/structural/EdgeCases.d.ts +46 -0
- package/dist/components/structural/EdgeCases.d.ts.map +1 -0
- package/dist/components/structural/Fallback.d.ts +43 -0
- package/dist/components/structural/Fallback.d.ts.map +1 -0
- package/dist/components/structural/Fallbacks.d.ts +46 -0
- package/dist/components/structural/Fallbacks.d.ts.map +1 -0
- package/dist/components/structural/Format.d.ts +79 -0
- package/dist/components/structural/Format.d.ts.map +1 -0
- package/dist/components/structural/Guardrails.d.ts +63 -0
- package/dist/components/structural/Guardrails.d.ts.map +1 -0
- package/dist/components/structural/Objective.d.ts +42 -0
- package/dist/components/structural/Objective.d.ts.map +1 -0
- package/dist/components/structural/Prompt.d.ts +243 -0
- package/dist/components/structural/Prompt.d.ts.map +1 -0
- package/dist/components/structural/Reference.d.ts +50 -0
- package/dist/components/structural/Reference.d.ts.map +1 -0
- package/dist/components/structural/References.d.ts +123 -0
- package/dist/components/structural/References.d.ts.map +1 -0
- package/dist/components/structural/Role.d.ts +74 -0
- package/dist/components/structural/Role.d.ts.map +1 -0
- package/dist/components/structural/Section.d.ts +30 -0
- package/dist/components/structural/Section.d.ts.map +1 -0
- package/dist/components/structural/Specialization.d.ts +36 -0
- package/dist/components/structural/Specialization.d.ts.map +1 -0
- package/dist/components/structural/Style.d.ts +43 -0
- package/dist/components/structural/Style.d.ts.map +1 -0
- package/dist/components/structural/SuccessCriteria.d.ts +96 -0
- package/dist/components/structural/SuccessCriteria.d.ts.map +1 -0
- package/dist/components/structural/Task.d.ts +60 -0
- package/dist/components/structural/Task.d.ts.map +1 -0
- package/dist/components/structural/Tone.d.ts +61 -0
- package/dist/components/structural/Tone.d.ts.map +1 -0
- package/dist/components/structural/When.d.ts +44 -0
- package/dist/components/structural/When.d.ts.map +1 -0
- package/dist/components/structural/WhenUncertain.d.ts +30 -0
- package/dist/components/structural/WhenUncertain.d.ts.map +1 -0
- package/dist/components/structural/index.d.ts +25 -0
- package/dist/components/structural/index.d.ts.map +1 -0
- package/dist/components/utility/Cwd.d.ts +10 -0
- package/dist/components/utility/Cwd.d.ts.map +1 -0
- package/dist/components/utility/DateTime.d.ts +22 -0
- package/dist/components/utility/DateTime.d.ts.map +1 -0
- package/dist/components/utility/Hostname.d.ts +10 -0
- package/dist/components/utility/Hostname.d.ts.map +1 -0
- package/dist/components/utility/Timestamp.d.ts +10 -0
- package/dist/components/utility/Timestamp.d.ts.map +1 -0
- package/dist/components/utility/UUID.d.ts +10 -0
- package/dist/components/utility/UUID.d.ts.map +1 -0
- package/dist/components/utility/Username.d.ts +10 -0
- package/dist/components/utility/Username.d.ts.map +1 -0
- package/dist/components/utility/index.d.ts +7 -0
- package/dist/components/utility/index.d.ts.map +1 -0
- package/dist/index.js +1 -1
- package/dist/src/api.d.ts +38 -0
- package/dist/src/api.d.ts.map +1 -0
- package/dist/src/component.d.ts +112 -0
- package/dist/src/component.d.ts.map +1 -0
- package/dist/src/create-prompt.d.ts +118 -0
- package/dist/src/create-prompt.d.ts.map +1 -0
- package/dist/src/index.d.ts +39 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/jsx-runtime/index.d.ts +29 -0
- package/dist/src/jsx-runtime/index.d.ts.map +1 -0
- package/dist/src/jsx-runtime/jsx-dev-runtime.d.ts +26 -0
- package/dist/src/jsx-runtime/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/src/render.d.ts +19 -0
- package/dist/src/render.d.ts.map +1 -0
- package/dist/src/services/babel-plugins/index.d.ts +3 -0
- package/dist/src/services/babel-plugins/index.d.ts.map +1 -0
- package/dist/src/services/babel-plugins/name-hoisting.d.ts +8 -0
- package/dist/src/services/babel-plugins/name-hoisting.d.ts.map +1 -0
- package/dist/src/services/babel-plugins/uses-to-import.d.ts +16 -0
- package/dist/src/services/babel-plugins/uses-to-import.d.ts.map +1 -0
- package/dist/src/services/browser-support.d.ts +185 -0
- package/dist/src/services/browser-support.d.ts.map +1 -0
- package/dist/src/services/component-discovery.d.ts +42 -0
- package/dist/src/services/component-discovery.d.ts.map +1 -0
- package/dist/src/services/file-search-engine.d.ts +162 -0
- package/dist/src/services/file-search-engine.d.ts.map +1 -0
- package/dist/src/services/formula-parser.d.ts +9 -0
- package/dist/src/services/formula-parser.d.ts.map +1 -0
- package/dist/src/services/input-iterator.d.ts +54 -0
- package/dist/src/services/input-iterator.d.ts.map +1 -0
- package/dist/src/services/module-evaluator.d.ts +38 -0
- package/dist/src/services/module-evaluator.d.ts.map +1 -0
- package/dist/src/services/module-loader.d.ts +92 -0
- package/dist/src/services/module-loader.d.ts.map +1 -0
- package/dist/src/services/preprocessor.d.ts +39 -0
- package/dist/src/services/preprocessor.d.ts.map +1 -0
- package/dist/src/services/prop-validator.d.ts +21 -0
- package/dist/src/services/prop-validator.d.ts.map +1 -0
- package/dist/src/services/search-engine.d.ts +10 -0
- package/dist/src/services/search-engine.d.ts.map +1 -0
- package/dist/src/services/transformer.d.ts +19 -0
- package/dist/src/services/transformer.d.ts.map +1 -0
- package/dist/{index.d.ts → src/types/context.d.ts} +425 -458
- package/dist/src/types/context.d.ts.map +1 -0
- package/dist/src/types/element.d.ts +47 -0
- package/dist/src/types/element.d.ts.map +1 -0
- package/dist/src/types/index.d.ts +10 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/types/input.d.ts +51 -0
- package/dist/src/types/input.d.ts.map +1 -0
- package/dist/src/types/module.d.ts +61 -0
- package/dist/src/types/module.d.ts.map +1 -0
- package/dist/src/types/render.d.ts +82 -0
- package/dist/src/types/render.d.ts.map +1 -0
- package/dist/src/types/search.d.ts +59 -0
- package/dist/src/types/search.d.ts.map +1 -0
- package/dist/src/types/symbols.d.ts +9 -0
- package/dist/src/types/symbols.d.ts.map +1 -0
- package/dist/src/utils/children.d.ts +29 -0
- package/dist/src/utils/children.d.ts.map +1 -0
- package/dist/src/utils/delimiter.d.ts +13 -0
- package/dist/src/utils/delimiter.d.ts.map +1 -0
- package/package.json +4 -4
- package/dist/jsx-dev-runtime.d.ts +0 -483
- package/dist/jsx-runtime/index.d.ts +0 -2
- package/dist/jsx-runtime/jsx-dev-runtime.d.ts +0 -2
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { ZodObject, ZodRawShape } from 'zod';
|
|
2
|
+
import { PuptNode, RenderContext } from './types';
|
|
3
|
+
import { LlmProvider } from './types/context';
|
|
4
|
+
/**
|
|
5
|
+
* Symbol used to mark Component classes for identification
|
|
6
|
+
*/
|
|
7
|
+
export declare const COMPONENT_MARKER: unique symbol;
|
|
8
|
+
/**
|
|
9
|
+
* Abstract base class for pupt-lib components.
|
|
10
|
+
* Extend this class to create class-based components with access to render context.
|
|
11
|
+
*
|
|
12
|
+
* Components can implement:
|
|
13
|
+
* - `resolve()` only: Compute a value (rendered as string, no visual output)
|
|
14
|
+
* - `render()` only: Produce visual output (backward compatible)
|
|
15
|
+
* - Both `resolve()` and `render()`: Compute value, then render with that value
|
|
16
|
+
*
|
|
17
|
+
* Both resolve and render methods can be synchronous or asynchronous.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* // Component with resolve() only - value is stringified
|
|
22
|
+
* class ValueComponent extends Component<{ value: string }, string> {
|
|
23
|
+
* resolve(props: { value: string }) {
|
|
24
|
+
* return props.value.toUpperCase();
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
*
|
|
28
|
+
* // Component with only render() (backward compatible)
|
|
29
|
+
* class Greeting extends Component<{ name: string }> {
|
|
30
|
+
* render(props: { name: string }) {
|
|
31
|
+
* return `Hello, ${props.name}!`;
|
|
32
|
+
* }
|
|
33
|
+
* }
|
|
34
|
+
*
|
|
35
|
+
* // Component with both resolve() and render()
|
|
36
|
+
* class DataFetcher extends Component<{ id: number }, { data: string }> {
|
|
37
|
+
* resolve(props: { id: number }) {
|
|
38
|
+
* return { data: `Data for ${props.id}` };
|
|
39
|
+
* }
|
|
40
|
+
* render(props: { id: number }, value: { data: string }) {
|
|
41
|
+
* return `Fetched: ${value.data}`;
|
|
42
|
+
* }
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare abstract class Component<Props = Record<string, unknown>, ResolveType = void> {
|
|
47
|
+
static [COMPONENT_MARKER]: boolean;
|
|
48
|
+
/** Zod schema for validating component props (excluding children) */
|
|
49
|
+
static schema: ZodObject<ZodRawShape>;
|
|
50
|
+
/** Optional Zod schema for validating the resolved value */
|
|
51
|
+
static resolveSchema?: ZodObject<ZodRawShape>;
|
|
52
|
+
/**
|
|
53
|
+
* When true, the name-hoisting Babel plugin will hoist this component's
|
|
54
|
+
* `name` prop to a variable declaration. Components that use `name` for
|
|
55
|
+
* variable creation (e.g., File, ReviewFile) should set this to true.
|
|
56
|
+
* Components that use `name` for identification (e.g., Section, Role)
|
|
57
|
+
* leave this unset.
|
|
58
|
+
*/
|
|
59
|
+
static hoistName?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Optional: Compute the resolved value for this component.
|
|
62
|
+
*
|
|
63
|
+
* If implemented, this method is called before render().
|
|
64
|
+
* The resolved value is stored and can be passed to other components.
|
|
65
|
+
*
|
|
66
|
+
* @param props - The properties passed to the component
|
|
67
|
+
* @param context - The render context containing environment and inputs
|
|
68
|
+
* @returns The resolved value, or a Promise resolving to the value for async components
|
|
69
|
+
*/
|
|
70
|
+
resolve?(props: Props, context: RenderContext): ResolveType | Promise<ResolveType>;
|
|
71
|
+
/**
|
|
72
|
+
* Get the LLM provider from the render context.
|
|
73
|
+
*
|
|
74
|
+
* @param context - The render context
|
|
75
|
+
* @returns The LLM provider string
|
|
76
|
+
*/
|
|
77
|
+
protected getProvider(context: RenderContext): LlmProvider;
|
|
78
|
+
/**
|
|
79
|
+
* Get the appropriate delimiter based on the output format in the render context.
|
|
80
|
+
* Returns 'markdown' if the output format is markdown, otherwise 'xml'.
|
|
81
|
+
*
|
|
82
|
+
* @param context - The render context
|
|
83
|
+
* @returns The delimiter style to use
|
|
84
|
+
*/
|
|
85
|
+
protected getDelimiter(context: RenderContext): 'xml' | 'markdown' | 'none';
|
|
86
|
+
/**
|
|
87
|
+
* Check if children has meaningful content.
|
|
88
|
+
* Returns false for undefined, null, empty arrays, and empty strings.
|
|
89
|
+
*/
|
|
90
|
+
protected hasContent(children: PuptNode): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Optional: Render the component with the given props and resolved value.
|
|
93
|
+
*
|
|
94
|
+
* If the component has a resolve() method, the resolved value is passed as the
|
|
95
|
+
* second argument. For backward compatibility, components without resolve() will
|
|
96
|
+
* receive undefined as the resolved value.
|
|
97
|
+
*
|
|
98
|
+
* @param props - The properties passed to the component
|
|
99
|
+
* @param resolvedValue - The value returned by resolve(), or undefined if no resolve() method
|
|
100
|
+
* @param context - The render context containing environment and inputs
|
|
101
|
+
* @returns The rendered output as a PuptNode, or a Promise resolving to a PuptNode for async components
|
|
102
|
+
*/
|
|
103
|
+
render?(props: Props, resolvedValue: ResolveType, context: RenderContext): PuptNode | Promise<PuptNode>;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Type guard to check if a value is a Component class (not an instance).
|
|
107
|
+
*
|
|
108
|
+
* @param value - The value to check
|
|
109
|
+
* @returns true if the value is a class extending Component
|
|
110
|
+
*/
|
|
111
|
+
export declare function isComponentClass(value: unknown): value is typeof Component;
|
|
112
|
+
//# sourceMappingURL=component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/component.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EA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
|
3
|
+
* Custom component registration for browser environments.
|
|
4
|
+
*
|
|
5
|
+
* In browser environments, dynamically evaluated code can only import from URLs
|
|
6
|
+
* that the import map knows about. For custom components that aren't published
|
|
7
|
+
* to npm, you can pass them here and reference them by name in your source.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const element = await createPromptFromSource(source, 'test.prompt', {
|
|
12
|
+
* components: {
|
|
13
|
+
* MyHeader: MyHeaderComponent,
|
|
14
|
+
* CustomCard: CustomCardComponent,
|
|
15
|
+
* }
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* Then in your source:
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <Prompt name="test">
|
|
22
|
+
* <MyHeader>Title</MyHeader>
|
|
23
|
+
* <CustomCard>Content</CustomCard>
|
|
24
|
+
* </Prompt>
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export interface CreatePromptOptions {
|
|
28
|
+
/**
|
|
29
|
+
* Custom components to make available in the evaluated source.
|
|
30
|
+
* Keys are component names, values are component classes.
|
|
31
|
+
*
|
|
32
|
+
* In browser environments, this is the primary way to use custom components
|
|
33
|
+
* that aren't published to npm.
|
|
34
|
+
*/
|
|
35
|
+
components?: Record<string, ComponentType>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Global key used for injecting custom components.
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
export declare const CUSTOM_COMPONENTS_GLOBAL = "__PUPT_CUSTOM_COMPONENTS__";
|
|
42
|
+
/**
|
|
43
|
+
* Declare the global type for TypeScript
|
|
44
|
+
*/
|
|
45
|
+
declare global {
|
|
46
|
+
var __PUPT_CUSTOM_COMPONENTS__: Record<string, ComponentType> | undefined;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Create a PuptElement from a TSX source string.
|
|
50
|
+
* Transforms the JSX and evaluates it to produce an element tree.
|
|
51
|
+
*
|
|
52
|
+
* For .prompt files or raw JSX without imports, built-in component imports
|
|
53
|
+
* are automatically injected.
|
|
54
|
+
*
|
|
55
|
+
* For .tsx files with imports, the source is used as-is.
|
|
56
|
+
*
|
|
57
|
+
* @param source - TSX source code
|
|
58
|
+
* @param filename - Filename for error messages and source maps
|
|
59
|
+
* @param options - Optional configuration
|
|
60
|
+
* @returns The default export as a PuptElement
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* // .tsx file with imports
|
|
65
|
+
* const source = `
|
|
66
|
+
* import { Prompt, Role } from 'pupt-lib';
|
|
67
|
+
* export default (
|
|
68
|
+
* <Prompt name="test">
|
|
69
|
+
* <Role>Assistant</Role>
|
|
70
|
+
* </Prompt>
|
|
71
|
+
* );
|
|
72
|
+
* `;
|
|
73
|
+
* const element = await createPromptFromSource(source, 'test.tsx');
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* // .prompt file (auto-imports built-in components)
|
|
79
|
+
* const source = `
|
|
80
|
+
* <Prompt name="test">
|
|
81
|
+
* <Role>Assistant</Role>
|
|
82
|
+
* </Prompt>
|
|
83
|
+
* `;
|
|
84
|
+
* const element = await createPromptFromSource(source, 'test.prompt');
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* // Using custom components in browser environments
|
|
90
|
+
* const source = `
|
|
91
|
+
* <Prompt name="test">
|
|
92
|
+
* <MyCustomHeader>Welcome</MyCustomHeader>
|
|
93
|
+
* </Prompt>
|
|
94
|
+
* `;
|
|
95
|
+
* const element = await createPromptFromSource(source, 'test.prompt', {
|
|
96
|
+
* components: {
|
|
97
|
+
* MyCustomHeader: MyCustomHeaderComponent,
|
|
98
|
+
* }
|
|
99
|
+
* });
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
export declare function createPromptFromSource(source: string, filename: string, options?: CreatePromptOptions): Promise<PuptElement>;
|
|
103
|
+
/**
|
|
104
|
+
* Create a PuptElement by loading and transforming a TSX file.
|
|
105
|
+
* Reads the file, transforms the JSX, and evaluates it.
|
|
106
|
+
*
|
|
107
|
+
* @param filePath - Path to the TSX file
|
|
108
|
+
* @param options - Optional configuration
|
|
109
|
+
* @returns The default export as a PuptElement
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* const element = await createPrompt('./prompts/greeting.tsx');
|
|
114
|
+
* const result = render(element, { inputs: { name: 'World' } });
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
export declare function createPrompt(filePath: string, options?: CreatePromptOptions): Promise<PuptElement>;
|
|
118
|
+
//# sourceMappingURL=create-prompt.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export declare const VERSION = "0.0.0-development";
|
|
2
|
+
export { TYPE, PROPS, CHILDREN, DEFERRED_REF } from './types/symbols';
|
|
3
|
+
export { isPuptElement, isDeferredRef } from './types/element';
|
|
4
|
+
export type { PuptNode, PuptElement, ComponentType, DeferredRef, LlmConfig, LlmProvider, OutputConfig, CodeConfig, UserConfig, RuntimeConfig, PromptConfig, EnvironmentContext, RenderContext, RenderOptions, RenderResult, RenderSuccess, RenderFailure, RenderError, PostExecutionAction, ReviewFileAction, OpenUrlAction, RunCommandAction, InputRequirement, ValidationResult, ValidationError, SearchablePrompt, SearchOptions, SearchResult, SearchResultMatch, SearchEngineConfig, PuptConfig, PuptLibrary, DiscoveredPrompt, LibraryLoadResult, PuptInitConfig, } from './types';
|
|
5
|
+
export { LLM_PROVIDERS, inferProviderFromModel, DEFAULT_ENVIRONMENT, createEnvironment, createRuntimeConfig, ensureRuntimeCacheReady, } from './types';
|
|
6
|
+
export { Component, isComponentClass, COMPONENT_MARKER } from './component';
|
|
7
|
+
export { render } from './render';
|
|
8
|
+
export { wrapWithDelimiter } from './utils/delimiter';
|
|
9
|
+
export { findChildrenOfType, partitionChildren, isElementOfType } from './utils/children';
|
|
10
|
+
export { PROVIDER_ADAPTATIONS, LANGUAGE_CONVENTIONS, ROLE_PRESETS, TASK_PRESETS, CONSTRAINT_PRESETS, STEPS_PRESETS, DEFAULT_CONSTRAINTS, STANDARD_GUARDRAILS, EDGE_CASE_PRESETS, FALLBACK_PRESETS, } from '../components/presets';
|
|
11
|
+
export type { ProviderAdaptations } from '../components/presets';
|
|
12
|
+
export type { RolePresetConfig } from '../components/presets';
|
|
13
|
+
export type { TaskPresetConfig } from '../components/presets';
|
|
14
|
+
export type { ConstraintPresetConfig } from '../components/presets';
|
|
15
|
+
export type { StepsPresetConfig } from '../components/presets';
|
|
16
|
+
export { createInputIterator } from './services/input-iterator';
|
|
17
|
+
export type { InputIterator, InputIteratorOptions, OnMissingDefaultStrategy } from './services/input-iterator';
|
|
18
|
+
export { evaluateFormula } from './services/formula-parser';
|
|
19
|
+
export { Transformer } from './services/transformer';
|
|
20
|
+
export { evaluateModule } from './services/module-evaluator';
|
|
21
|
+
export type { EvaluateOptions } from './services/module-evaluator';
|
|
22
|
+
export { preprocessSource, isPromptFile, needsPreprocessing } from './services/preprocessor';
|
|
23
|
+
export type { PreprocessOptions } from './services/preprocessor';
|
|
24
|
+
export { getBuiltinComponents, getAskComponents, getAskShorthand, getStructuralComponents, } from './services/component-discovery';
|
|
25
|
+
export { ModuleLoader } from './services/module-loader';
|
|
26
|
+
export type { SourceType, LoadedLibrary, ParsedPackageSource } from './services/module-loader';
|
|
27
|
+
export { resolveCdn, generateImportMap, serializeImportMap, generateImportMapScript, generatePuptLibImportMap, generatePuptLibImportMapScript, } from './services/browser-support';
|
|
28
|
+
export type { CdnProvider, CdnOptions, Dependency, ImportMap, PuptLibImportMapOptions, } from './services/browser-support';
|
|
29
|
+
export * from '../components';
|
|
30
|
+
export { askBaseSchema, attachRequirement } from '../components/ask/utils';
|
|
31
|
+
export { createPromptFromSource, createPrompt } from './create-prompt';
|
|
32
|
+
export type { CreatePromptOptions } from './create-prompt';
|
|
33
|
+
export { Pupt } from './api';
|
|
34
|
+
export type { DiscoveredPromptWithMethods } from './api';
|
|
35
|
+
export { createSearchEngine } from './services/search-engine';
|
|
36
|
+
export type { SearchEngine } from './services/search-engine';
|
|
37
|
+
export { FileSearchEngine, createFileSearchEngine } from './services/file-search-engine';
|
|
38
|
+
export type { FileInfo, FileSearchResult, FileSearchEngineConfig, } from './services/file-search-engine';
|
|
39
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":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AG9B,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,MAAM,+BAA+B,CAAC;AACzF,YAAY,EACV,QAAQ,EACR,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { PuptElement, PuptNode, ComponentType } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Fragment symbol for grouping elements without a wrapper
|
|
4
|
+
*/
|
|
5
|
+
export declare const Fragment: unique symbol;
|
|
6
|
+
/**
|
|
7
|
+
* Create a JSX element with a single child.
|
|
8
|
+
* Called by the JSX transform for elements with one child.
|
|
9
|
+
*
|
|
10
|
+
* @param type - Element type (string tag, symbol like Fragment, or component)
|
|
11
|
+
* @param props - Properties including children
|
|
12
|
+
* @returns A PuptElement
|
|
13
|
+
*/
|
|
14
|
+
export declare function jsx<P extends Record<string, unknown>>(type: string | symbol | ComponentType<P>, props: P & {
|
|
15
|
+
children?: PuptNode;
|
|
16
|
+
}): PuptElement<P>;
|
|
17
|
+
/**
|
|
18
|
+
* Create a JSX element with multiple children.
|
|
19
|
+
* Called by the JSX transform for elements with multiple children.
|
|
20
|
+
* Implementation is the same as jsx since we normalize children either way.
|
|
21
|
+
*
|
|
22
|
+
* @param type - Element type (string tag, symbol like Fragment, or component)
|
|
23
|
+
* @param props - Properties including children array
|
|
24
|
+
* @returns A PuptElement
|
|
25
|
+
*/
|
|
26
|
+
export declare function jsxs<P extends Record<string, unknown>>(type: string | symbol | ComponentType<P>, props: P & {
|
|
27
|
+
children?: PuptNode;
|
|
28
|
+
}): PuptElement<P>;
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/jsx-runtime/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,aAAa,EAAe,MAAM,UAAU,CAAC;AAGlF;;GAEG;AACH,eAAO,MAAM,QAAQ,eAA8B,CAAC;AA6IpD;;;;;;;GAOG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACnD,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC,EACxC,KAAK,EAAE,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,QAAQ,CAAA;CAAE,GACjC,WAAW,CAAC,CAAC,CAAC,CAQhB;AAED;;;;;;;;GAQG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpD,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC,EACxC,KAAK,EAAE,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,QAAQ,CAAA;CAAE,GACjC,WAAW,CAAC,CAAC,CAAC,CAEhB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { PuptElement, PuptNode, ComponentType } from '../types';
|
|
2
|
+
export { Fragment, jsx, jsxs } from './index';
|
|
3
|
+
/**
|
|
4
|
+
* Source location information for development debugging
|
|
5
|
+
*/
|
|
6
|
+
export interface JSXSource {
|
|
7
|
+
fileName: string;
|
|
8
|
+
lineNumber: number;
|
|
9
|
+
columnNumber: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Development version of jsx that includes source location tracking.
|
|
13
|
+
* Used by React/JSX transforms in development mode.
|
|
14
|
+
*
|
|
15
|
+
* @param type - Element type
|
|
16
|
+
* @param props - Properties including children
|
|
17
|
+
* @param _key - Element key (unused in pupt-lib)
|
|
18
|
+
* @param _isStaticChildren - Whether children are static (unused)
|
|
19
|
+
* @param _source - Source location for debugging
|
|
20
|
+
* @param _self - Self reference (unused)
|
|
21
|
+
* @returns A PuptElement
|
|
22
|
+
*/
|
|
23
|
+
export declare function jsxDEV<P extends Record<string, unknown>>(type: string | symbol | ComponentType<P>, props: P & {
|
|
24
|
+
children?: PuptNode;
|
|
25
|
+
}, _key: string | undefined, _isStaticChildren: boolean, _source: JSXSource, _self: unknown): PuptElement<P>;
|
|
26
|
+
//# sourceMappingURL=jsx-dev-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-dev-runtime.d.ts","sourceRoot":"","sources":["../../../src/jsx-runtime/jsx-dev-runtime.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGrE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACtD,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC,EACxC,KAAK,EAAE,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,QAAQ,CAAA;CAAE,EAClC,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,iBAAiB,EAAE,OAAO,EAC1B,OAAO,EAAE,SAAS,EAClB,KAAK,EAAE,OAAO,GACb,WAAW,CAAC,CAAC,CAAC,CAIhB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { PuptElement, RenderResult, RenderOptions } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Render a PuptElement tree to a string.
|
|
4
|
+
*
|
|
5
|
+
* This function is async to support components with async render methods.
|
|
6
|
+
* Components can perform async operations like API calls in their render methods.
|
|
7
|
+
*
|
|
8
|
+
* @param element - The root PuptElement to render
|
|
9
|
+
* @param options - Render options including inputs and environment
|
|
10
|
+
* @returns A Promise resolving to the RenderResult
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const result = await render(<MyPrompt />);
|
|
15
|
+
* console.log(result.text);
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function render(element: PuptElement, options?: RenderOptions): Promise<RenderResult>;
|
|
19
|
+
//# sourceMappingURL=render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAY,YAAY,EAAE,aAAa,EAAmD,MAAM,SAAS,CAAC;AAuInI;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,MAAM,CAC1B,OAAO,EAAE,WAAW,EACpB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,YAAY,CAAC,CA2DvB"}
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PluginObj, types as BabelTypes } from '@babel/core';
|
|
2
|
+
/**
|
|
3
|
+
* Babel plugin that hoists named JSX elements to variable declarations.
|
|
4
|
+
*/
|
|
5
|
+
export declare function nameHoistingPlugin({ types: t }: {
|
|
6
|
+
types: typeof BabelTypes;
|
|
7
|
+
}): PluginObj;
|
|
8
|
+
//# sourceMappingURL=name-hoisting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"name-hoisting.d.ts","sourceRoot":"","sources":["../../../../src/services/babel-plugins/name-hoisting.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,IAAI,UAAU,EAAY,MAAM,aAAa,CAAC;AAuJ5E;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAAE,KAAK,EAAE,OAAO,UAAU,CAAA;CAAE,GAAG,SAAS,CA0GxF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PluginObj, types as BabelTypes } from '@babel/core';
|
|
2
|
+
interface PluginState {
|
|
3
|
+
file: {
|
|
4
|
+
path: {
|
|
5
|
+
unshiftContainer: (key: string, node: BabelTypes.Statement | BabelTypes.Statement[]) => void;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Babel plugin that transforms <Uses> elements to import declarations.
|
|
11
|
+
*/
|
|
12
|
+
export declare function usesToImportPlugin({ types: t }: {
|
|
13
|
+
types: typeof BabelTypes;
|
|
14
|
+
}): PluginObj<PluginState>;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=uses-to-import.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uses-to-import.d.ts","sourceRoot":"","sources":["../../../../src/services/babel-plugins/uses-to-import.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,aAAa,CAAC;AAElE,UAAU,WAAW;IACnB,IAAI,EAAE;QACJ,IAAI,EAAE;YACJ,gBAAgB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC,SAAS,GAAG,UAAU,CAAC,SAAS,EAAE,KAAK,IAAI,CAAC;SAC9F,CAAC;KACH,CAAC;CACH;AA0GD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAAE,KAAK,EAAE,OAAO,UAAU,CAAA;CAAE,GAAG,SAAS,CAAC,WAAW,CAAC,CA6CrG"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser support utilities for pupt-lib.
|
|
3
|
+
* Provides import map generation and CDN URL resolution for browser environments.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Supported CDN providers
|
|
7
|
+
*/
|
|
8
|
+
export type CdnProvider = 'esm.sh' | 'unpkg' | 'jsdelivr' | 'skypack';
|
|
9
|
+
/**
|
|
10
|
+
* Options for CDN resolution
|
|
11
|
+
*/
|
|
12
|
+
export interface CdnOptions {
|
|
13
|
+
/** CDN provider to use */
|
|
14
|
+
cdn?: CdnProvider;
|
|
15
|
+
/** Custom template URL with {name}, {version}, and optionally {path} placeholders */
|
|
16
|
+
cdnTemplate?: string;
|
|
17
|
+
/** Optional path within the package (e.g., 'dist/index.js') */
|
|
18
|
+
path?: string;
|
|
19
|
+
/** Optional scopes for import map */
|
|
20
|
+
scopes?: Record<string, Record<string, string>>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Represents a dependency for import map generation
|
|
24
|
+
*/
|
|
25
|
+
export interface Dependency {
|
|
26
|
+
name: string;
|
|
27
|
+
version: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Standard import map structure
|
|
31
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap
|
|
32
|
+
*/
|
|
33
|
+
export interface ImportMap {
|
|
34
|
+
imports: Record<string, string>;
|
|
35
|
+
scopes?: Record<string, Record<string, string>>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Resolve a CDN URL for a package.
|
|
39
|
+
*
|
|
40
|
+
* @param name - Package name (e.g., '@acme/pkg' or 'lodash')
|
|
41
|
+
* @param version - Package version (e.g., '1.0.0')
|
|
42
|
+
* @param options - CDN options
|
|
43
|
+
* @returns The resolved CDN URL
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* resolveCdn('@acme/pkg', '1.0.0', { cdn: 'esm.sh' });
|
|
48
|
+
* // => 'https://esm.sh/@acme/pkg@1.0.0'
|
|
49
|
+
*
|
|
50
|
+
* resolveCdn('@acme/pkg', '1.0.0', { cdn: 'unpkg' });
|
|
51
|
+
* // => 'https://unpkg.com/@acme/pkg@1.0.0'
|
|
52
|
+
*
|
|
53
|
+
* resolveCdn('@acme/pkg', '1.0.0', {
|
|
54
|
+
* cdnTemplate: 'https://cdn.example.com/{name}@{version}'
|
|
55
|
+
* });
|
|
56
|
+
* // => 'https://cdn.example.com/@acme/pkg@1.0.0'
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare function resolveCdn(name: string, version: string, options: CdnOptions): string;
|
|
60
|
+
/**
|
|
61
|
+
* Generate an import map for a list of dependencies.
|
|
62
|
+
*
|
|
63
|
+
* @param dependencies - Array of dependencies with name and version
|
|
64
|
+
* @param options - CDN options
|
|
65
|
+
* @returns An ImportMap object ready to be serialized
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const deps = [
|
|
70
|
+
* { name: 'pupt-lib', version: '1.0.0' },
|
|
71
|
+
* { name: '@acme/prompts', version: '2.0.0' },
|
|
72
|
+
* ];
|
|
73
|
+
*
|
|
74
|
+
* const importMap = generateImportMap(deps, { cdn: 'esm.sh' });
|
|
75
|
+
* // => {
|
|
76
|
+
* // imports: {
|
|
77
|
+
* // 'pupt-lib': 'https://esm.sh/pupt-lib@1.0.0',
|
|
78
|
+
* // '@acme/prompts': 'https://esm.sh/@acme/prompts@2.0.0'
|
|
79
|
+
* // }
|
|
80
|
+
* // }
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export declare function generateImportMap(dependencies: Dependency[], options: CdnOptions): ImportMap;
|
|
84
|
+
/**
|
|
85
|
+
* Serialize an import map to a JSON string for embedding in HTML.
|
|
86
|
+
*
|
|
87
|
+
* @param importMap - The import map to serialize
|
|
88
|
+
* @returns JSON string
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* const json = serializeImportMap(importMap);
|
|
93
|
+
* // Use in HTML: <script type="importmap">${json}</script>
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export declare function serializeImportMap(importMap: ImportMap): string;
|
|
97
|
+
/**
|
|
98
|
+
* Generate an HTML script tag with an import map.
|
|
99
|
+
*
|
|
100
|
+
* @param dependencies - Array of dependencies with name and version
|
|
101
|
+
* @param options - CDN options
|
|
102
|
+
* @returns HTML string for the import map script tag
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* const html = generateImportMapScript(deps, { cdn: 'esm.sh' });
|
|
107
|
+
* // => <script type="importmap">{"imports": {...}}</script>
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
export declare function generateImportMapScript(dependencies: Dependency[], options: CdnOptions): string;
|
|
111
|
+
/**
|
|
112
|
+
* Options for generating pupt-lib import map
|
|
113
|
+
*/
|
|
114
|
+
export interface PuptLibImportMapOptions {
|
|
115
|
+
/** CDN provider to use (default: 'esm.sh') */
|
|
116
|
+
cdn?: CdnProvider;
|
|
117
|
+
/** Custom CDN template URL */
|
|
118
|
+
cdnTemplate?: string;
|
|
119
|
+
/** pupt-lib version (default: current installed version) */
|
|
120
|
+
puptLibVersion?: string;
|
|
121
|
+
/** Additional dependencies to include */
|
|
122
|
+
additionalDependencies?: Dependency[];
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Generate an import map for browser usage of pupt-lib.
|
|
126
|
+
*
|
|
127
|
+
* This creates the minimal import map required to use `createPromptFromSource`
|
|
128
|
+
* in browser environments. It includes:
|
|
129
|
+
* - pupt-lib main entry
|
|
130
|
+
* - pupt-lib/jsx-runtime subpath
|
|
131
|
+
*
|
|
132
|
+
* Note: zod, minisearch, and @babel/standalone are bundled into pupt-lib's dist
|
|
133
|
+
* and do not need separate import map entries.
|
|
134
|
+
*
|
|
135
|
+
* @param options - Configuration options
|
|
136
|
+
* @returns An ImportMap object ready to be serialized
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```typescript
|
|
140
|
+
* // Using esm.sh (default)
|
|
141
|
+
* const importMap = generatePuptLibImportMap({ puptLibVersion: '1.1.0' });
|
|
142
|
+
*
|
|
143
|
+
* // Using unpkg
|
|
144
|
+
* const importMap = generatePuptLibImportMap({
|
|
145
|
+
* puptLibVersion: '1.1.0',
|
|
146
|
+
* cdn: 'unpkg'
|
|
147
|
+
* });
|
|
148
|
+
*
|
|
149
|
+
* // With additional dependencies
|
|
150
|
+
* const importMap = generatePuptLibImportMap({
|
|
151
|
+
* puptLibVersion: '1.1.0',
|
|
152
|
+
* additionalDependencies: [
|
|
153
|
+
* { name: 'my-component-lib', version: '2.0.0' }
|
|
154
|
+
* ]
|
|
155
|
+
* });
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```html
|
|
160
|
+
* <!-- Usage in HTML -->
|
|
161
|
+
* <script type="importmap">
|
|
162
|
+
* {
|
|
163
|
+
* "imports": {
|
|
164
|
+
* "pupt-lib": "https://esm.sh/pupt-lib@1.1.0",
|
|
165
|
+
* "pupt-lib/jsx-runtime": "https://esm.sh/pupt-lib@1.1.0/jsx-runtime"
|
|
166
|
+
* }
|
|
167
|
+
* }
|
|
168
|
+
* </script>
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
export declare function generatePuptLibImportMap(options?: PuptLibImportMapOptions): ImportMap;
|
|
172
|
+
/**
|
|
173
|
+
* Generate an HTML script tag with the pupt-lib import map.
|
|
174
|
+
*
|
|
175
|
+
* @param options - Configuration options
|
|
176
|
+
* @returns HTML string for the import map script tag
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```typescript
|
|
180
|
+
* const html = generatePuptLibImportMapScript({ puptLibVersion: '1.1.0' });
|
|
181
|
+
* // Use in HTML head: document.head.insertAdjacentHTML('afterbegin', html);
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
export declare function generatePuptLibImportMapScript(options?: PuptLibImportMapOptions): string;
|
|
185
|
+
//# sourceMappingURL=browser-support.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-support.d.ts","sourceRoot":"","sources":["../../../src/services/browser-support.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,CAAC;AAYtE;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,0BAA0B;IAC1B,GAAG,CAAC,EAAE,WAAW,CAAC;IAClB,qFAAqF;IACrF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+DAA+D;IAC/D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACjD;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,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.
|
|
3
|
+
*
|
|
4
|
+
* Instead of importing a static manifest from components/, this module
|
|
5
|
+
* builds component lists lazily from the actual component exports.
|
|
6
|
+
* src/index.ts registers a thunk that provides the exports; the lists
|
|
7
|
+
* are computed on first access (at runtime, when all modules are loaded).
|
|
8
|
+
*/
|
|
9
|
+
type ExportMap = Record<string, unknown>;
|
|
10
|
+
type ExportThunk = () => ExportMap;
|
|
11
|
+
/**
|
|
12
|
+
* Register a thunk that returns the component exports.
|
|
13
|
+
* Called by src/index.ts during module initialization.
|
|
14
|
+
* The thunk is evaluated lazily to avoid circular dependency issues.
|
|
15
|
+
*/
|
|
16
|
+
export declare function setComponentExportsThunk(thunk: ExportThunk): void;
|
|
17
|
+
/**
|
|
18
|
+
* All built-in non-Ask component names, derived from actual exports.
|
|
19
|
+
* Includes 'Component' (the base class).
|
|
20
|
+
*/
|
|
21
|
+
export declare function getBuiltinComponents(): readonly string[];
|
|
22
|
+
/**
|
|
23
|
+
* All Ask component names (Ask namespace + individual AskX exports).
|
|
24
|
+
*/
|
|
25
|
+
export declare function getAskComponents(): readonly string[];
|
|
26
|
+
/**
|
|
27
|
+
* Shorthand aliases: short name → AskX full name.
|
|
28
|
+
* e.g., { Text: 'AskText', Number: 'AskNumber', ... }
|
|
29
|
+
*
|
|
30
|
+
* Skips shorthands that would conflict with builtin component names.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getAskShorthand(): Record<string, string>;
|
|
33
|
+
/**
|
|
34
|
+
* Structural component names whose `name` prop is for identification,
|
|
35
|
+
* not variable creation. The name-hoisting Babel plugin skips these.
|
|
36
|
+
*
|
|
37
|
+
* Computed as: all builtins minus Component (base class), minus components
|
|
38
|
+
* with `static hoistName = true`, plus Fragment.
|
|
39
|
+
*/
|
|
40
|
+
export declare function getStructuralComponents(): readonly string[];
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=component-discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-discovery.d.ts","sourceRoot":"","sources":["../../../src/services/component-discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,KAAK,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACzC,KAAK,WAAW,GAAG,MAAM,SAAS,CAAC;AAUnC;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAOjE;AAWD;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,SAAS,MAAM,EAAE,CAcxD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,SAAS,MAAM,EAAE,CAapD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAgBxD;AAUD;;;;;;GAMG;AACH,wBAAgB,uBAAuB,IAAI,SAAS,MAAM,EAAE,CAa3D"}
|