@runtypelabs/persona 3.27.0 → 3.28.0
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/codegen.cjs +80 -0
- package/dist/codegen.d.cts +143 -0
- package/dist/codegen.d.ts +143 -0
- package/dist/codegen.js +80 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.global.js +20 -20
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +8 -2
- package/src/codegen.test.ts +39 -0
- package/src/codegen.ts +20 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runtypelabs/persona",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.28.0",
|
|
4
4
|
"description": "Themeable, pluggable streaming agent widget for websites, in plain JS with support for voice input and reasoning / tool output.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -17,6 +17,11 @@
|
|
|
17
17
|
"import": "./dist/theme-reference.js",
|
|
18
18
|
"require": "./dist/theme-reference.cjs"
|
|
19
19
|
},
|
|
20
|
+
"./codegen": {
|
|
21
|
+
"types": "./dist/codegen.d.ts",
|
|
22
|
+
"import": "./dist/codegen.js",
|
|
23
|
+
"require": "./dist/codegen.cjs"
|
|
24
|
+
},
|
|
20
25
|
"./theme-editor": {
|
|
21
26
|
"types": "./dist/theme-editor.d.ts",
|
|
22
27
|
"import": "./dist/theme-editor.js",
|
|
@@ -99,12 +104,13 @@
|
|
|
99
104
|
"access": "public"
|
|
100
105
|
},
|
|
101
106
|
"scripts": {
|
|
102
|
-
"build": "rimraf dist && pnpm run build:styles && pnpm run build:client && pnpm run build:installer && pnpm run build:launcher && pnpm run build:theme-ref && pnpm run build:theme-editor && pnpm run build:testing && pnpm run build:smart-dom-reader && pnpm run build:animations",
|
|
107
|
+
"build": "rimraf dist && pnpm run build:styles && pnpm run build:client && pnpm run build:installer && pnpm run build:launcher && pnpm run build:theme-ref && pnpm run build:codegen && pnpm run build:theme-editor && pnpm run build:testing && pnpm run build:smart-dom-reader && pnpm run build:animations",
|
|
103
108
|
"build:theme-editor": "tsup src/theme-editor.ts --format esm,cjs --minify --dts --out-dir dist --no-splitting",
|
|
104
109
|
"build:testing": "tsup src/testing.ts --format esm,cjs --minify --dts --out-dir dist --no-splitting",
|
|
105
110
|
"build:smart-dom-reader": "tsup src/smart-dom-reader.ts --format esm,cjs --minify --dts --out-dir dist --no-splitting",
|
|
106
111
|
"build:animations": "tsup src/animations/glyph-cycle.ts src/animations/wipe.ts --format esm,cjs --minify --dts --out-dir dist/animations --no-splitting",
|
|
107
112
|
"build:theme-ref": "tsup src/theme-reference.ts --format esm,cjs --minify --dts",
|
|
113
|
+
"build:codegen": "tsup src/codegen.ts --format esm,cjs --minify --dts",
|
|
108
114
|
"build:styles": "node -e \"const fs=require('fs');fs.mkdirSync('dist',{recursive:true});fs.copyFileSync('src/styles/widget.css','dist/widget.css');\"",
|
|
109
115
|
"build:client": "tsup src/index.ts --format esm,cjs --minify --sourcemap --splitting false --dts --loader \".css=text\" && tsup src/index-global.ts --format iife --global-name AgentWidget --minify --sourcemap --splitting false --out-dir dist --loader \".css=text\" && node -e \"const fs=require('fs');for(const ext of ['.global.js','.global.js.map']){const from='dist/index-global'+ext;if(fs.existsSync(from))fs.renameSync(from,'dist/index'+ext);}\"",
|
|
110
116
|
"build:installer": "tsup src/install.ts --format iife --global-name SiteAgentInstaller --out-dir dist --minify --sourcemap --no-splitting",
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { generateCodeSnippet as fromSubpath } from "./codegen";
|
|
3
|
+
import { generateCodeSnippet as fromInternal } from "./utils/code-generators";
|
|
4
|
+
import { VERSION } from "./version";
|
|
5
|
+
|
|
6
|
+
// The `@runtypelabs/persona/codegen` subpath is the server/Worker-safe entry for
|
|
7
|
+
// snippet generation. It must expose the exact same generator as the internal
|
|
8
|
+
// module (and, transitively, the main barrel) — no fork, no drift.
|
|
9
|
+
describe("codegen subpath", () => {
|
|
10
|
+
const config = {
|
|
11
|
+
apiUrl: "https://api.example.com/chat",
|
|
12
|
+
clientToken: "ct_test_123",
|
|
13
|
+
launcher: { enabled: true, title: "Chat" },
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
it("re-exports the same generateCodeSnippet implementation", () => {
|
|
17
|
+
expect(fromSubpath).toBe(fromInternal);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("produces identical output via the subpath for every format", () => {
|
|
21
|
+
const formats = [
|
|
22
|
+
"esm",
|
|
23
|
+
"script-installer",
|
|
24
|
+
"script-manual",
|
|
25
|
+
"script-advanced",
|
|
26
|
+
"react-component",
|
|
27
|
+
"react-advanced",
|
|
28
|
+
] as const;
|
|
29
|
+
for (const format of formats) {
|
|
30
|
+
expect(fromSubpath(config, format)).toBe(fromInternal(config, format));
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("pins the installer CDN url to the package version (not @latest)", () => {
|
|
35
|
+
const code = fromSubpath(config, "script-installer");
|
|
36
|
+
expect(code).toContain(`@runtypelabs/persona@${VERSION}/dist/install.global.js`);
|
|
37
|
+
expect(code).not.toContain("@latest");
|
|
38
|
+
});
|
|
39
|
+
});
|
package/src/codegen.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure code-snippet generation entry (`@runtypelabs/persona/codegen`).
|
|
3
|
+
*
|
|
4
|
+
* `generateCodeSnippet` is pure string-templating — it builds install snippets
|
|
5
|
+
* from a widget config and depends only on a type import + the `VERSION`
|
|
6
|
+
* constant. The main `index.ts` barrel re-exports it too, but that barrel pulls
|
|
7
|
+
* in the full widget runtime (`index-core` → idiomorph / marked / DOM), which is
|
|
8
|
+
* unacceptable for server/Worker consumers that only need snippet strings.
|
|
9
|
+
*
|
|
10
|
+
* This subpath exposes the generator on its own (mirroring `theme-reference`) so
|
|
11
|
+
* those consumers import it without dragging in the browser runtime. Existing
|
|
12
|
+
* npm consumers keep using the barrel export unchanged.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export { generateCodeSnippet } from "./utils/code-generators";
|
|
16
|
+
export type {
|
|
17
|
+
CodeFormat,
|
|
18
|
+
CodeGeneratorHooks,
|
|
19
|
+
CodeGeneratorOptions
|
|
20
|
+
} from "./utils/code-generators";
|