pupt-lib 1.3.1 → 1.3.3
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/README.md +16 -34
- package/dist/index.js +5 -5
- package/package.json +1 -1
- package/dist/__vite-browser-external-2Ng8QIWW.js +0 -4
package/README.md
CHANGED
|
@@ -290,35 +290,22 @@ See [docs/COMPONENTS.md](docs/COMPONENTS.md) for the full list of preset keys.
|
|
|
290
290
|
|
|
291
291
|
## Creating Custom Components
|
|
292
292
|
|
|
293
|
-
|
|
293
|
+
Create a component by extending `Component` and exporting it from a file:
|
|
294
294
|
|
|
295
295
|
```typescript
|
|
296
|
+
// my-components.ts
|
|
296
297
|
import { Component } from 'pupt-lib';
|
|
297
|
-
import type { PuptNode
|
|
298
|
-
import { z } from 'zod';
|
|
298
|
+
import type { PuptNode } from 'pupt-lib';
|
|
299
299
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
type WarningProps = z.infer<typeof warningSchema> & { children?: PuptNode };
|
|
305
|
-
|
|
306
|
-
class Warning extends Component<WarningProps> {
|
|
307
|
-
static schema = warningSchema;
|
|
308
|
-
|
|
309
|
-
render(props: WarningProps, _resolvedValue: void, context: RenderContext): PuptNode {
|
|
310
|
-
const prefix = {
|
|
311
|
-
info: 'INFO',
|
|
312
|
-
warning: 'WARNING',
|
|
313
|
-
error: 'ERROR',
|
|
314
|
-
}[props.level];
|
|
315
|
-
|
|
316
|
-
return `[${prefix}] ${props.children}`;
|
|
300
|
+
export class Warning extends Component<{ level: string; children?: PuptNode }> {
|
|
301
|
+
render({ level, children }) {
|
|
302
|
+
const prefix = { info: 'INFO', warning: 'WARNING', error: 'ERROR' }[level];
|
|
303
|
+
return `[${prefix}] ${children}`;
|
|
317
304
|
}
|
|
318
305
|
}
|
|
319
306
|
```
|
|
320
307
|
|
|
321
|
-
|
|
308
|
+
Import it in a `.prompt` file with `<Uses>`:
|
|
322
309
|
|
|
323
310
|
```xml
|
|
324
311
|
<Uses component="Warning" from="./my-components" />
|
|
@@ -328,10 +315,13 @@ Use in `.prompt` files with `<Uses>`:
|
|
|
328
315
|
</Prompt>
|
|
329
316
|
```
|
|
330
317
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
318
|
+
Or in a `.tsx` file with a standard import:
|
|
319
|
+
|
|
320
|
+
```tsx
|
|
321
|
+
import { Warning } from './my-components';
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
See [docs/MODULES.md](docs/MODULES.md) for the full guide — including function components, prop validation, async components, and publishing to npm.
|
|
335
325
|
|
|
336
326
|
## Advanced Features
|
|
337
327
|
|
|
@@ -402,17 +392,9 @@ For build-time JSX transformation, configure `tsconfig.json`:
|
|
|
402
392
|
}
|
|
403
393
|
```
|
|
404
394
|
|
|
405
|
-
Or use the Babel preset for runtime transformation:
|
|
406
|
-
|
|
407
|
-
```javascript
|
|
408
|
-
// babel.config.js
|
|
409
|
-
module.exports = {
|
|
410
|
-
presets: ['pupt-lib/babel-preset'],
|
|
411
|
-
};
|
|
412
|
-
```
|
|
413
|
-
|
|
414
395
|
## Reference Documentation
|
|
415
396
|
|
|
397
|
+
- **[docs/MODULES.md](docs/MODULES.md)** — Guide to creating, importing, and publishing reusable components and prompts
|
|
416
398
|
- **[docs/COMPONENTS.md](docs/COMPONENTS.md)** — Full component reference (all 50+ components with all props)
|
|
417
399
|
- **[docs/API.md](docs/API.md)** — Full API reference (functions, types, base class, utilities)
|
|
418
400
|
|
package/dist/index.js
CHANGED
|
@@ -4718,7 +4718,7 @@ const PROVIDER_ADAPTATIONS = {
|
|
|
4718
4718
|
"unspecified": {
|
|
4719
4719
|
rolePrefix: "You are ",
|
|
4720
4720
|
constraintStyle: "positive",
|
|
4721
|
-
formatPreference: "
|
|
4721
|
+
formatPreference: "markdown",
|
|
4722
4722
|
instructionStyle: "structured"
|
|
4723
4723
|
}
|
|
4724
4724
|
};
|
|
@@ -42971,7 +42971,7 @@ function isBareSpecifier(specifier) {
|
|
|
42971
42971
|
}
|
|
42972
42972
|
async function resolveBareSpecifier(specifier) {
|
|
42973
42973
|
const path = await import("path");
|
|
42974
|
-
const { pathToFileURL } = await import("
|
|
42974
|
+
const { pathToFileURL } = await import("url");
|
|
42975
42975
|
if (specifier === "pupt-lib" || specifier === "pupt-lib/jsx-runtime") {
|
|
42976
42976
|
try {
|
|
42977
42977
|
const resolved = require.resolve(specifier);
|
|
@@ -43024,7 +43024,7 @@ async function evaluateInNode(code, filename) {
|
|
|
43024
43024
|
const path = await import("path");
|
|
43025
43025
|
const os = await import("os");
|
|
43026
43026
|
const crypto2 = await import("crypto");
|
|
43027
|
-
const { pathToFileURL } = await import("
|
|
43027
|
+
const { pathToFileURL } = await import("url");
|
|
43028
43028
|
const rewrittenCode = await rewriteAllImports(code);
|
|
43029
43029
|
const hash = crypto2.createHash("md5").update(rewrittenCode).digest("hex").slice(0, 8);
|
|
43030
43030
|
const tempDir = path.join(os.tmpdir(), "pupt-lib");
|
|
@@ -43126,7 +43126,7 @@ async function resolveLocalPath(source) {
|
|
|
43126
43126
|
return source;
|
|
43127
43127
|
}
|
|
43128
43128
|
const path = await import("path");
|
|
43129
|
-
const url = await import("
|
|
43129
|
+
const url = await import("url");
|
|
43130
43130
|
const absolutePath = path.resolve(process.cwd(), source);
|
|
43131
43131
|
return url.pathToFileURL(absolutePath).href;
|
|
43132
43132
|
}
|
|
@@ -47910,7 +47910,7 @@ class Pupt {
|
|
|
47910
47910
|
const isNode2 = typeof process !== "undefined" && ((_a2 = process.versions) == null ? void 0 : _a2.node);
|
|
47911
47911
|
if (isNode2 && (source.startsWith("./") || source.startsWith("/") || source.startsWith("../"))) {
|
|
47912
47912
|
const path = await import("path");
|
|
47913
|
-
const url = await import("
|
|
47913
|
+
const url = await import("url");
|
|
47914
47914
|
const absolutePath = path.resolve(process.cwd(), source);
|
|
47915
47915
|
const fileUrl = url.pathToFileURL(absolutePath).href;
|
|
47916
47916
|
return await import(
|
package/package.json
CHANGED