@runtypelabs/persona 3.26.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.
Files changed (39) hide show
  1. package/README.md +29 -13
  2. package/dist/animations/glyph-cycle.d.cts +1 -1
  3. package/dist/animations/glyph-cycle.d.ts +1 -1
  4. package/dist/animations/{types-BZVr1YOV.d.cts → types-CxvHw0X6.d.cts} +551 -1
  5. package/dist/animations/{types-BZVr1YOV.d.ts → types-CxvHw0X6.d.ts} +551 -1
  6. package/dist/animations/wipe.d.cts +1 -1
  7. package/dist/animations/wipe.d.ts +1 -1
  8. package/dist/codegen.cjs +80 -0
  9. package/dist/codegen.d.cts +143 -0
  10. package/dist/codegen.d.ts +143 -0
  11. package/dist/codegen.js +80 -0
  12. package/dist/index.cjs +35 -35
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +1230 -3
  15. package/dist/index.d.ts +1230 -3
  16. package/dist/index.global.js +35 -35
  17. package/dist/index.global.js.map +1 -1
  18. package/dist/index.js +31 -31
  19. package/dist/index.js.map +1 -1
  20. package/dist/install.global.js +1 -1
  21. package/dist/install.global.js.map +1 -1
  22. package/dist/launcher.global.js +133 -0
  23. package/dist/launcher.global.js.map +1 -0
  24. package/dist/smart-dom-reader.d.cts +551 -1
  25. package/dist/smart-dom-reader.d.ts +551 -1
  26. package/dist/theme-editor.d.cts +551 -1
  27. package/dist/theme-editor.d.ts +551 -1
  28. package/package.json +14 -4
  29. package/src/client.test.ts +9 -9
  30. package/src/codegen.test.ts +39 -0
  31. package/src/codegen.ts +20 -0
  32. package/src/generated/runtype-openapi-contract.ts +1249 -0
  33. package/src/index-core.ts +19 -0
  34. package/src/install.test.ts +442 -0
  35. package/src/install.ts +283 -49
  36. package/src/launcher-global.ts +115 -0
  37. package/src/runtime/init.test.ts +71 -0
  38. package/src/runtime/init.ts +17 -1
  39. package/src/types.ts +14 -8
@@ -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";