pupt-lib 1.3.2 → 1.3.4
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
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
|
@@ -42970,21 +42970,19 @@ function isBareSpecifier(specifier) {
|
|
|
42970
42970
|
return true;
|
|
42971
42971
|
}
|
|
42972
42972
|
async function resolveBareSpecifier(specifier) {
|
|
42973
|
-
|
|
42974
|
-
const { pathToFileURL } = await import("./__vite-browser-external-2Ng8QIWW.js");
|
|
42975
|
-
if (specifier === "pupt-lib" || specifier === "pupt-lib/jsx-runtime") {
|
|
42973
|
+
if (typeof import.meta.resolve === "function") {
|
|
42976
42974
|
try {
|
|
42977
|
-
|
|
42978
|
-
|
|
42979
|
-
|
|
42980
|
-
|
|
42981
|
-
const distPath = path.join(process.cwd(), "dist", subpath);
|
|
42982
|
-
return pathToFileURL(distPath).href;
|
|
42975
|
+
return import.meta.resolve(specifier);
|
|
42976
|
+
} catch (error) {
|
|
42977
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
42978
|
+
throw new Error(`Cannot resolve module "${specifier}": ${message}`);
|
|
42983
42979
|
}
|
|
42984
42980
|
}
|
|
42981
|
+
const { pathToFileURL } = await import("url");
|
|
42982
|
+
const { createRequire } = await import("module");
|
|
42983
|
+
const esmRequire = createRequire(import.meta.url);
|
|
42985
42984
|
try {
|
|
42986
|
-
|
|
42987
|
-
return pathToFileURL(resolved).href;
|
|
42985
|
+
return pathToFileURL(esmRequire.resolve(specifier)).href;
|
|
42988
42986
|
} catch (error) {
|
|
42989
42987
|
const message = error instanceof Error ? error.message : String(error);
|
|
42990
42988
|
throw new Error(`Cannot resolve module "${specifier}": ${message}`);
|
|
@@ -43024,7 +43022,7 @@ async function evaluateInNode(code, filename) {
|
|
|
43024
43022
|
const path = await import("path");
|
|
43025
43023
|
const os = await import("os");
|
|
43026
43024
|
const crypto2 = await import("crypto");
|
|
43027
|
-
const { pathToFileURL } = await import("
|
|
43025
|
+
const { pathToFileURL } = await import("url");
|
|
43028
43026
|
const rewrittenCode = await rewriteAllImports(code);
|
|
43029
43027
|
const hash = crypto2.createHash("md5").update(rewrittenCode).digest("hex").slice(0, 8);
|
|
43030
43028
|
const tempDir = path.join(os.tmpdir(), "pupt-lib");
|
|
@@ -43126,7 +43124,7 @@ async function resolveLocalPath(source) {
|
|
|
43126
43124
|
return source;
|
|
43127
43125
|
}
|
|
43128
43126
|
const path = await import("path");
|
|
43129
|
-
const url = await import("
|
|
43127
|
+
const url = await import("url");
|
|
43130
43128
|
const absolutePath = path.resolve(process.cwd(), source);
|
|
43131
43129
|
return url.pathToFileURL(absolutePath).href;
|
|
43132
43130
|
}
|
|
@@ -47910,7 +47908,7 @@ class Pupt {
|
|
|
47910
47908
|
const isNode2 = typeof process !== "undefined" && ((_a2 = process.versions) == null ? void 0 : _a2.node);
|
|
47911
47909
|
if (isNode2 && (source.startsWith("./") || source.startsWith("/") || source.startsWith("../"))) {
|
|
47912
47910
|
const path = await import("path");
|
|
47913
|
-
const url = await import("
|
|
47911
|
+
const url = await import("url");
|
|
47914
47912
|
const absolutePath = path.resolve(process.cwd(), source);
|
|
47915
47913
|
const fileUrl = url.pathToFileURL(absolutePath).href;
|
|
47916
47914
|
return await import(
|
|
@@ -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;
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pupt-lib",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
4
4
|
"description": "TypeScript library for creating AI prompts using JSX syntax",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "",
|
|
@@ -37,15 +37,18 @@
|
|
|
37
37
|
"exports": {
|
|
38
38
|
".": {
|
|
39
39
|
"types": "./dist/src/index.d.ts",
|
|
40
|
-
"import": "./dist/index.js"
|
|
40
|
+
"import": "./dist/index.js",
|
|
41
|
+
"default": "./dist/index.js"
|
|
41
42
|
},
|
|
42
43
|
"./jsx-runtime": {
|
|
43
44
|
"types": "./dist/src/jsx-runtime/index.d.ts",
|
|
44
|
-
"import": "./dist/jsx-runtime/index.js"
|
|
45
|
+
"import": "./dist/jsx-runtime/index.js",
|
|
46
|
+
"default": "./dist/jsx-runtime/index.js"
|
|
45
47
|
},
|
|
46
48
|
"./jsx-dev-runtime": {
|
|
47
49
|
"types": "./dist/src/jsx-runtime/jsx-dev-runtime.d.ts",
|
|
48
|
-
"import": "./dist/jsx-runtime/jsx-dev-runtime.js"
|
|
50
|
+
"import": "./dist/jsx-runtime/jsx-dev-runtime.js",
|
|
51
|
+
"default": "./dist/jsx-runtime/jsx-dev-runtime.js"
|
|
49
52
|
}
|
|
50
53
|
},
|
|
51
54
|
"scripts": {
|