@popcraft/kit 0.1.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 (171) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/LICENSE +21 -0
  3. package/README.md +74 -0
  4. package/dist/index.js +160558 -0
  5. package/package.json +40 -0
  6. package/types/design-script.d.ts +39 -0
  7. package/types/lib/agent/design-script/build.d.ts +35 -0
  8. package/types/lib/agent/design-script/check.d.ts +11 -0
  9. package/types/lib/agent/design-script/helper-names.d.ts +1 -0
  10. package/types/lib/agent/design-script/kit-modules.d.ts +43 -0
  11. package/types/lib/agent/design-script/recorder.d.ts +52 -0
  12. package/types/lib/agent/design-script/replay.d.ts +13 -0
  13. package/types/lib/agent/design-script/run-node.d.ts +2 -0
  14. package/types/lib/ai/audio-models.d.ts +66 -0
  15. package/types/lib/ai/content.d.ts +27 -0
  16. package/types/lib/ai/limits.d.ts +42 -0
  17. package/types/lib/audio/presentation/loudness.d.ts +80 -0
  18. package/types/lib/audio/presentation/types.d.ts +112 -0
  19. package/types/lib/brand/apply.d.ts +25 -0
  20. package/types/lib/brand/review-kits.d.ts +10 -0
  21. package/types/lib/brand/types.d.ts +20 -0
  22. package/types/lib/code/hash.d.ts +2 -0
  23. package/types/lib/document/auto-layout.d.ts +10 -0
  24. package/types/lib/document/breakpoints.d.ts +45 -0
  25. package/types/lib/document/clone.d.ts +6 -0
  26. package/types/lib/document/color.d.ts +52 -0
  27. package/types/lib/document/detach.d.ts +12 -0
  28. package/types/lib/document/effects.d.ts +60 -0
  29. package/types/lib/document/expressions.d.ts +78 -0
  30. package/types/lib/document/instance-layout.d.ts +94 -0
  31. package/types/lib/document/instances.d.ts +63 -0
  32. package/types/lib/document/libraries.d.ts +97 -0
  33. package/types/lib/document/node-delta.d.ts +21 -0
  34. package/types/lib/document/page-tokens.d.ts +16 -0
  35. package/types/lib/document/photo-frames.d.ts +14 -0
  36. package/types/lib/document/print-pages.d.ts +85 -0
  37. package/types/lib/document/scene-graph.d.ts +194 -0
  38. package/types/lib/document/scene3d.d.ts +76 -0
  39. package/types/lib/document/shader-graph-effects.d.ts +8 -0
  40. package/types/lib/document/shader-graph.d.ts +134 -0
  41. package/types/lib/document/shader-params.d.ts +65 -0
  42. package/types/lib/document/shape-to-path.d.ts +20 -0
  43. package/types/lib/document/text-styles.d.ts +28 -0
  44. package/types/lib/document/text-tokens.d.ts +6 -0
  45. package/types/lib/document/transform.d.ts +79 -0
  46. package/types/lib/document/transform3d.d.ts +99 -0
  47. package/types/lib/document/trim.d.ts +35 -0
  48. package/types/lib/document/types.d.ts +2560 -0
  49. package/types/lib/document/variables.d.ts +14 -0
  50. package/types/lib/editor/easing.d.ts +46 -0
  51. package/types/lib/editor/modes/types.d.ts +131 -0
  52. package/types/lib/editor/prototype-connect.d.ts +49 -0
  53. package/types/lib/editor/smart-animate.d.ts +37 -0
  54. package/types/lib/engine/geometry/flatten.d.ts +2 -0
  55. package/types/lib/engine/geometry/shape-outline.d.ts +24 -0
  56. package/types/lib/engine/pixel/cells.d.ts +12 -0
  57. package/types/lib/engine/pixel/palettes.d.ts +25 -0
  58. package/types/lib/engine/readiness.d.ts +20 -0
  59. package/types/lib/engine/routing.d.ts +41 -0
  60. package/types/lib/engine/shader-graph-presets.d.ts +22 -0
  61. package/types/lib/engine/shader-presets-legacy.d.ts +7 -0
  62. package/types/lib/engine/shader-presets.d.ts +43 -0
  63. package/types/lib/engine/text/atlas.d.ts +120 -0
  64. package/types/lib/engine/text/emoji/segment.d.ts +15 -0
  65. package/types/lib/engine/text/fallback-fonts.d.ts +47 -0
  66. package/types/lib/engine/text/fontkit-lazy.d.ts +8 -0
  67. package/types/lib/engine/text/fonts.d.ts +33 -0
  68. package/types/lib/engine/text/glyph-linear.d.ts +22 -0
  69. package/types/lib/engine/text/google-fonts.d.ts +17 -0
  70. package/types/lib/engine/text/hyphenate/en-us.d.ts +6 -0
  71. package/types/lib/engine/text/hyphenate/liang.d.ts +21 -0
  72. package/types/lib/engine/text/layout-access.d.ts +16 -0
  73. package/types/lib/engine/text/layout.d.ts +168 -0
  74. package/types/lib/engine/text/lists.d.ts +16 -0
  75. package/types/lib/engine/text/measure.d.ts +58 -0
  76. package/types/lib/engine/text/outline-sdf.d.ts +34 -0
  77. package/types/lib/engine/text/shaper.d.ts +88 -0
  78. package/types/lib/engine/text/text-area.d.ts +16 -0
  79. package/types/lib/engine/text/text-fit.d.ts +51 -0
  80. package/types/lib/engine/text/text-path.d.ts +134 -0
  81. package/types/lib/engine/text/text-rings.d.ts +17 -0
  82. package/types/lib/engine/text/wrap-obstacles.d.ts +20 -0
  83. package/types/lib/i18n/catalogs.d.ts +10 -0
  84. package/types/lib/i18n/format.d.ts +27 -0
  85. package/types/lib/i18n/locales.d.ts +25 -0
  86. package/types/lib/i18n/pseudo.d.ts +10 -0
  87. package/types/lib/i18n/runtime.d.ts +27 -0
  88. package/types/lib/io/codecs/wav.d.ts +7 -0
  89. package/types/lib/io/codecs/webp.d.ts +7 -0
  90. package/types/lib/io/export-ir/children.d.ts +2 -0
  91. package/types/lib/io/json-export.d.ts +11 -0
  92. package/types/lib/media-library/types.d.ts +39 -0
  93. package/types/lib/motion/audio-analysis.d.ts +44 -0
  94. package/types/lib/motion/audio-clips.d.ts +92 -0
  95. package/types/lib/motion/audio-onsets.d.ts +13 -0
  96. package/types/lib/motion/audio-signals.d.ts +59 -0
  97. package/types/lib/motion/author.d.ts +80 -0
  98. package/types/lib/motion/composition.d.ts +99 -0
  99. package/types/lib/motion/instances.d.ts +95 -0
  100. package/types/lib/motion/key-selection.d.ts +100 -0
  101. package/types/lib/motion/keys.d.ts +41 -0
  102. package/types/lib/motion/layer-time-edit.d.ts +40 -0
  103. package/types/lib/motion/markers.d.ts +31 -0
  104. package/types/lib/motion/modifier-edit.d.ts +84 -0
  105. package/types/lib/motion/modifiers.d.ts +44 -0
  106. package/types/lib/motion/morph.d.ts +14 -0
  107. package/types/lib/motion/pose-layout.d.ts +6 -0
  108. package/types/lib/motion/pose.d.ts +115 -0
  109. package/types/lib/motion/presets.d.ts +148 -0
  110. package/types/lib/motion/properties.d.ts +74 -0
  111. package/types/lib/motion/sample-keys.d.ts +8 -0
  112. package/types/lib/motion/sample.d.ts +51 -0
  113. package/types/lib/motion/sound.d.ts +25 -0
  114. package/types/lib/motion/spatial-curve.d.ts +15 -0
  115. package/types/lib/motion/spatial.d.ts +38 -0
  116. package/types/lib/motion/text-animators.d.ts +79 -0
  117. package/types/lib/motion/text-units.d.ts +47 -0
  118. package/types/lib/motion/time.d.ts +58 -0
  119. package/types/lib/motion/transitions.d.ts +99 -0
  120. package/types/lib/motion/values.d.ts +12 -0
  121. package/types/lib/motion/video-clip.d.ts +63 -0
  122. package/types/lib/presets/page-presets.d.ts +50 -0
  123. package/types/lib/storage/media-hash.d.ts +4 -0
  124. package/types/lib/storage/media-refs.d.ts +2 -0
  125. package/types/lib/storage/media-store.d.ts +70 -0
  126. package/types/lib/templates/apply.d.ts +38 -0
  127. package/types/lib/templates/capture.d.ts +25 -0
  128. package/types/lib/templates/groups.d.ts +82 -0
  129. package/types/lib/templates/layout.d.ts +20 -0
  130. package/types/lib/templates/quality.d.ts +59 -0
  131. package/types/lib/templates/resize.d.ts +34 -0
  132. package/types/lib/templates/safe-areas.d.ts +42 -0
  133. package/types/lib/templates/text-measurer.d.ts +10 -0
  134. package/types/lib/templates/thumbnail.d.ts +134 -0
  135. package/types/lib/templates/types.d.ts +95 -0
  136. package/types/lib/templates/vocabulary.d.ts +50 -0
  137. package/types/lib/units/units.d.ts +23 -0
  138. package/types/packages/kit/src/index.d.ts +59 -0
  139. package/types/packages/runtime/src/expressions.d.ts +41 -0
  140. package/types/templates/src/app/shared.d.ts +29 -0
  141. package/types/templates/src/audio/beat-loop.d.ts +9 -0
  142. package/types/templates/src/audio/media.d.ts +42 -0
  143. package/types/templates/src/audio/music-synth.d.ts +57 -0
  144. package/types/templates/src/audio/music-worlds.d.ts +8 -0
  145. package/types/templates/src/audio/music.d.ts +19 -0
  146. package/types/templates/src/audio/studio/deck.d.ts +340 -0
  147. package/types/templates/src/audio/studio/dsp.d.ts +151 -0
  148. package/types/templates/src/audio/studio/fx.d.ts +96 -0
  149. package/types/templates/src/audio/studio/mix.d.ts +84 -0
  150. package/types/templates/src/audio/studio/voices.d.ts +120 -0
  151. package/types/templates/src/data/geometry.d.ts +16 -0
  152. package/types/templates/src/effects/shared.d.ts +17 -0
  153. package/types/templates/src/kit.d.ts +582 -0
  154. package/types/templates/src/motion3d/devices.d.ts +42 -0
  155. package/types/templates/src/motion3d/ui.d.ts +48 -0
  156. package/types/templates/src/saas/video-shared.d.ts +114 -0
  157. package/types/templates/src/saas/web-shared.d.ts +74 -0
  158. package/types/templates/src/shared/beat.d.ts +24 -0
  159. package/types/templates/src/shared/captions.d.ts +24 -0
  160. package/types/templates/src/shared/devices.d.ts +188 -0
  161. package/types/templates/src/shared/draw.d.ts +43 -0
  162. package/types/templates/src/shared/fit.d.ts +73 -0
  163. package/types/templates/src/shared/marks.d.ts +51 -0
  164. package/types/templates/src/shared/motion.d.ts +15 -0
  165. package/types/templates/src/shared/overlays.d.ts +80 -0
  166. package/types/templates/src/shared/pointer.d.ts +46 -0
  167. package/types/templates/src/shared/texture.d.ts +41 -0
  168. package/types/templates/src/shared/type.d.ts +6 -0
  169. package/types/templates/src/shared/window.d.ts +50 -0
  170. package/types/templates/src/social/shared.d.ts +66 -0
  171. package/types/templates/src/web/shared.d.ts +64 -0
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@popcraft/kit",
3
+ "version": "0.1.0",
4
+ "description": "The PopCraft design kit: the library PopCraft templates and design scripts are written with — brand roles, text styles, layout, components, motion and music — with its helpers, design checks, a sandboxed script runner and .popcraft output.",
5
+ "license": "MIT",
6
+ "homepage": "https://popcraft.app/docs/api/design-reference",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/getpopcraft/popcraft-app.git",
10
+ "directory": "packages/kit"
11
+ },
12
+ "type": "module",
13
+ "main": "dist/index.js",
14
+ "types": "types/packages/kit/src/index.d.ts",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./types/packages/kit/src/index.d.ts",
18
+ "default": "./dist/index.js"
19
+ },
20
+ "./design-script": {
21
+ "types": "./types/design-script.d.ts"
22
+ }
23
+ },
24
+ "files": [
25
+ "dist",
26
+ "types",
27
+ "README.md",
28
+ "CHANGELOG.md",
29
+ "LICENSE"
30
+ ],
31
+ "engines": {
32
+ "node": ">=24"
33
+ },
34
+ "devDependencies": {
35
+ "esbuild": "0.28.2"
36
+ },
37
+ "scripts": {
38
+ "build": "node build.mjs"
39
+ }
40
+ }
@@ -0,0 +1,39 @@
1
+ // What a PopCraft design script can use. Reference it from your script for completion and checking:
2
+ // /// <reference path="node_modules/@popcraft/kit/types/design-script.d.ts" />
3
+ // Values the kit returns are references in a running script: pass them on, do not do arithmetic on them.
4
+ import type { Kit } from './templates/src/kit.js'
5
+
6
+ declare global {
7
+ /** The kit, building into \`k.sheet\`. */
8
+ const k: Kit
9
+ /** The design's size and name. */
10
+ const W: number
11
+ const H: number
12
+ const NAME: string
13
+ /** Every shipped music track's tempo, as plain numbers. */
14
+ const TRACKS: Record<string, { bpm: number; beatMs: number; durationMs: number }>
15
+ const ease: typeof import('./lib/motion/author.js').ease
16
+ const hex: typeof import('./templates/src/kit.js').hex
17
+ const preset: typeof import('./templates/src/kit.js').preset
18
+ const web: typeof import('./templates/src/web/shared.js')
19
+ const beat: typeof import('./templates/src/shared/beat.js')
20
+ const draw: typeof import('./templates/src/shared/draw.js')
21
+ const marks: typeof import('./templates/src/shared/marks.js')
22
+ const texture: typeof import('./templates/src/shared/texture.js')
23
+ const captions: typeof import('./templates/src/shared/captions.js')
24
+ const pointer: typeof import('./templates/src/shared/pointer.js')
25
+ const motion: typeof import('./templates/src/shared/motion.js')
26
+ const fit: typeof import('./templates/src/shared/fit.js')
27
+ const overlays: typeof import('./templates/src/shared/overlays.js')
28
+ /** App and browser windows: productWindow, chrome, screenshotSlot (not the DOM's window). */
29
+ const windows: typeof import('./templates/src/shared/window.js')
30
+ const devices: typeof import('./templates/src/shared/devices.js')
31
+ const type: typeof import('./templates/src/shared/type.js')
32
+ const social: typeof import('./templates/src/social/shared.js')
33
+ const video: typeof import('./templates/src/saas/video-shared.js')
34
+ const site: typeof import('./templates/src/saas/web-shared.js')
35
+ const effects: typeof import('./templates/src/effects/shared.js')
36
+ /** Report a line (run_script and design scripts). */
37
+ function print(...values: unknown[]): void
38
+ }
39
+ export {}
@@ -0,0 +1,35 @@
1
+ import type { Document, DesignScriptSource } from '../../document/types.js';
2
+ import type { PagePreset } from '../../presets/page-presets.js';
3
+ import type { Template } from '../../templates/types.js';
4
+ import { type Recording } from './recorder.js';
5
+ import { type ReplayError } from './replay.js';
6
+ /** What runs the recorder: the sandbox in the browser, a `vm` context in node. */
7
+ export type Recorder = (source: string, namespaces: readonly string[], globals: Record<string, unknown>) => Promise<Recording> | Recording;
8
+ /** The names a script can call into, beside the plain values W, H, NAME and TRACKS. */
9
+ export declare const DESIGN_NAMESPACES: readonly ["k", "ease", "hex", "preset", "draw", "marks", "fit", "motion", "captions", "overlays", "texture", "pointer", "windows", "devices", "type", "beat", "web", "social", "video", "site", "effects"];
10
+ /** The page preset a script builds at: a preset id, or a custom size. */
11
+ export declare function sizePreset(size: DesignScriptSource['size']): Promise<PagePreset>;
12
+ export interface BuiltDesign {
13
+ /** The Kit's document: the frames the script made, on their own page(s). Absent when nothing could be built. */
14
+ doc?: Document;
15
+ error?: ReplayError;
16
+ /** How many kit calls ran. */
17
+ calls: number;
18
+ }
19
+ /** Record `source` and replay it onto a fresh Kit. A script that fails part-way still builds what came before the failure. */
20
+ export declare function buildDesign(source: string, size: DesignScriptSource['size'], name: string, record: Recorder): Promise<BuiltDesign>;
21
+ /** A stable fingerprint of what the subtrees at `roots` say, to notice hand edits between builds. */
22
+ export declare function hashRoots(doc: Document, roots: readonly string[]): string;
23
+ export interface Placement {
24
+ pageId: string;
25
+ /** Rebuild this design (the frame carrying `designScript`): its roots are replaced where they stand. */
26
+ replace?: string;
27
+ }
28
+ /** Put a built design into `doc`. Returns the new document, the inserted roots and the master frame's id. */
29
+ export declare function placeDesign(doc: Document, built: Document, source: string, size: DesignScriptSource['size'], name: string, at: Placement): {
30
+ document: Document;
31
+ roots: string[];
32
+ master: string;
33
+ };
34
+ /** The template a built design reads as: what fonts and media a use must load first (lib/templates/use.ts). */
35
+ export declare const templateOfBuild: (built: Document, name: string) => Template;
@@ -0,0 +1,11 @@
1
+ import type { Document } from '../../document/types.js';
2
+ export interface DesignIssue {
3
+ /** The frame (size) it was found in, as "1080×1920". */
4
+ size: string;
5
+ kind: 'contrast' | 'kit-contrast' | 'small-text' | 'off-frame' | 'unsafe' | 'overlap' | 'seam' | 'empty-band' | 'too-tall' | 'broken-instance';
6
+ layer: string;
7
+ message: string;
8
+ }
9
+ /** The largest texture a graphics card is sure to take: a frame bigger than this cannot be pictured whole. */
10
+ export declare const MAX_FRAME_PX = 8192;
11
+ export declare function checkDesign(doc: Document, roots: readonly string[]): DesignIssue[];
@@ -0,0 +1 @@
1
+ export declare const HELPER_NAMES: readonly ["draw", "marks", "fit", "motion", "captions", "overlays", "texture", "pointer", "windows", "devices", "type", "beat", "web", "social", "video", "site", "effects"];
@@ -0,0 +1,43 @@
1
+ /** The helper modules, by the name a script (or an importer) uses for each. */
2
+ export declare function loadKitModules(): Promise<{
3
+ Kit: typeof import("../../../templates/src/kit.js").Kit;
4
+ hex: (h: string, a?: number) => import("../../document/types.js").Color;
5
+ preset: (id: string) => import("../../presets/page-presets.js").PagePreset;
6
+ ease: {
7
+ linear: import("../../document/types.js").Interp;
8
+ hold: import("../../document/types.js").Interp;
9
+ named: (family: import("../../document/types.js").EaseFamily, dir?: "in" | "out" | "in-out") => import("../../document/types.js").Interp;
10
+ in: (family?: import("../../document/types.js").EaseFamily) => import("../../document/types.js").Interp;
11
+ out: (family?: import("../../document/types.js").EaseFamily) => import("../../document/types.js").Interp;
12
+ inOut: (family?: import("../../document/types.js").EaseFamily) => import("../../document/types.js").Interp;
13
+ back: (c?: number, dir?: "in" | "out" | "in-out") => import("../../document/types.js").Interp;
14
+ bezier: (x1: number, y1: number, x2: number, y2: number) => import("../../document/types.js").Interp;
15
+ spring: (stiffness?: number, damping?: number, mass?: number) => import("../../document/types.js").Interp;
16
+ };
17
+ TRACKS: Record<string, {
18
+ bpm: number;
19
+ beatMs: number;
20
+ durationMs: number;
21
+ }>;
22
+ helpers: {
23
+ draw: typeof import("../../../templates/src/shared/draw.js");
24
+ marks: typeof import("../../../templates/src/shared/marks.js");
25
+ fit: typeof import("../../../templates/src/shared/fit.js");
26
+ motion: typeof import("../../../templates/src/shared/motion.js");
27
+ captions: typeof import("../../../templates/src/shared/captions.js");
28
+ overlays: typeof import("../../../templates/src/shared/overlays.js");
29
+ texture: typeof import("../../../templates/src/shared/texture.js");
30
+ pointer: typeof import("../../../templates/src/shared/pointer.js");
31
+ windows: typeof import("../../../templates/src/shared/window.js");
32
+ devices: typeof import("../../../templates/src/shared/devices.js");
33
+ type: typeof import("../../../templates/src/shared/type.js");
34
+ beat: typeof import("../../../templates/src/shared/beat.js");
35
+ web: typeof import("../../../templates/src/web/shared.js");
36
+ social: typeof import("../../../templates/src/social/shared.js");
37
+ video: typeof import("../../../templates/src/saas/video-shared.js");
38
+ site: typeof import("../../../templates/src/saas/web-shared.js");
39
+ effects: typeof import("../../../templates/src/effects/shared.js");
40
+ };
41
+ }>;
42
+ /** The helper namespaces' names, in the order scripts see them. */
43
+ export { HELPER_NAMES } from './helper-names.js';
@@ -0,0 +1,52 @@
1
+ /** A reference to something the script cannot see: a namespace, an earlier call's result, or a callback's parameter. */
2
+ export type RefBase = {
3
+ $ns: string;
4
+ } | {
5
+ $r: number;
6
+ } | {
7
+ $p: [number, number];
8
+ };
9
+ /** A value as it crosses the sandbox: plain data, with references and callbacks encoded. */
10
+ export type Encoded = null | boolean | number | string | Encoded[] | {
11
+ [key: string]: Encoded;
12
+ } | EncodedRef | EncodedFn;
13
+ export interface EncodedRef {
14
+ $ref: RefBase;
15
+ path: string[];
16
+ }
17
+ export interface EncodedFn {
18
+ $fn: number;
19
+ ops: Op[];
20
+ ret: Encoded;
21
+ }
22
+ /** One call (or a property read, when `args` is absent) the script made. */
23
+ export interface Op {
24
+ id: number;
25
+ target: EncodedRef;
26
+ args?: Encoded[];
27
+ line?: number;
28
+ }
29
+ export interface Recording {
30
+ ops: Op[];
31
+ /** What the script returned (a top-level \`return\`), references included: replay resolves them. */
32
+ returned?: Encoded;
33
+ /** What it printed with print() or console.log(), in order. */
34
+ logs?: string[];
35
+ /** Why the script stopped, with the line it stopped on (1-based, in the script as written). */
36
+ error?: {
37
+ message: string;
38
+ line?: number;
39
+ };
40
+ }
41
+ /** Limits a script runs under, so a mistake (an endless loop) cannot hang the editor. */
42
+ export declare const RECORD_LIMITS: {
43
+ readonly maxOps: 60000;
44
+ readonly maxDepth: 40;
45
+ readonly timeoutMs: 4000;
46
+ readonly maxSourceChars: 120000;
47
+ };
48
+ /**
49
+ * `record(source, namespaces, globals)` → Recording. `namespaces` are the names the script may call into (k, ease…);
50
+ * `globals` are plain data it may read (W, H, a snapshot of the document). Evaluated as a string in the sandbox.
51
+ */
52
+ export declare const RECORDER_SOURCE: string;
@@ -0,0 +1,13 @@
1
+ import type { Recording } from './recorder.js';
2
+ export interface ReplayError {
3
+ message: string;
4
+ line?: number;
5
+ }
6
+ /**
7
+ * Replay `rec` against `namespaces`, in order (a call that returns a promise is awaited before the next). Stops at the
8
+ * first failing call, naming its line. `value` is what the script returned, with its references resolved.
9
+ */
10
+ export declare function replay(rec: Recording, namespaces: Record<string, unknown>): Promise<{
11
+ error?: ReplayError;
12
+ value?: unknown;
13
+ }>;
@@ -0,0 +1,2 @@
1
+ import { type Recording } from './recorder.js';
2
+ export declare function recordInNode(source: string, namespaces: readonly string[], globals: Record<string, unknown>): Recording;
@@ -0,0 +1,66 @@
1
+ export type AudioUse = 'music' | 'sfx' | 'voice';
2
+ export declare const AUDIO_USES: readonly ["music", "sfx", "voice"];
3
+ export interface AudioModel {
4
+ use: AudioUse;
5
+ /** The Hypery model id (a Replicate `owner/name` for predictions). */
6
+ id: string;
7
+ label: string;
8
+ /** How Hypery serves it. */
9
+ route: 'prediction' | 'speech';
10
+ provider: string;
11
+ /** Longest clip it makes (s); voice-over is as long as its script. */
12
+ maxSeconds: number;
13
+ defaultSeconds: number;
14
+ description: string;
15
+ }
16
+ export declare const AUDIO_MODELS: Record<AudioUse, AudioModel>;
17
+ /**
18
+ * Other models a request may name (`model`), per use: the presentation-audio module's quality tiers
19
+ * (lib/audio/presentation). Each is a real model Hypery serves on the same route as its use's default — music and
20
+ * sound effects as Replicate predictions, speech on /audio/speech (Hypery prices tts-1, tts-1-hd and gpt-4o-mini-tts).
21
+ */
22
+ export declare const AUDIO_MODEL_OPTIONS: Record<AudioUse, readonly AudioModel[]>;
23
+ /** The model `id` names for `use` (its default when unset); null for a model this app does not offer for that use. */
24
+ export declare function audioModelFor(use: AudioUse, id?: string): AudioModel | null;
25
+ /** The presentation module's tiers, by model id (lib/audio/presentation/prompts.ts). */
26
+ export declare const SPEECH_MODEL_IDS: {
27
+ readonly natural: "gpt-4o-mini-tts";
28
+ readonly hd: "tts-1-hd";
29
+ readonly standard: "tts-1";
30
+ };
31
+ export declare const MUSIC_MODEL_IDS: {
32
+ readonly hq: "stability-ai/stable-audio-2.5";
33
+ readonly standard: "meta/musicgen";
34
+ };
35
+ export declare const SFX_MODEL_IDS: {
36
+ readonly hq: "stability-ai/stable-audio-2.5";
37
+ readonly standard: "sepal/audiogen";
38
+ };
39
+ /**
40
+ * List prices (USD) for the estimate the presentation-audio panel shows — Hypery bills credits at its own rates, so
41
+ * these are what the provider lists: speech per 1 000 characters (Hypery's table), a prediction per run.
42
+ */
43
+ export declare const AUDIO_LIST_PRICES: {
44
+ speechPer1kChars: Record<string, number>;
45
+ perRun: Record<string, number>;
46
+ };
47
+ /** Speech output formats the route may ask for: mp3 (the default) or lossless wav. */
48
+ export declare const SPEECH_FORMATS: readonly ["mp3", "wav"];
49
+ export type SpeechFormat = (typeof SPEECH_FORMATS)[number];
50
+ /** The text-to-speech voices Hypery's /audio/speech accepts. */
51
+ export declare const VOICES: readonly ["alloy", "ash", "ballad", "coral", "echo", "fable", "nova", "onyx", "sage", "shimmer", "verse"];
52
+ export type Voice = (typeof VOICES)[number];
53
+ export declare const AUDIO_LIMITS: {
54
+ /** A music or sound-effect description. */
55
+ maxPromptChars: number;
56
+ /** A voice-over script (Hypery's /audio/speech limit). */
57
+ maxScriptChars: number;
58
+ /** Result bytes downloaded from the provider. */
59
+ maxResultBytes: number;
60
+ /** Upper bound for one generation (the route aborts the upstream request after this). */
61
+ timeoutMs: number;
62
+ };
63
+ /** Whether this build asks Hypery for `ai:audio` (so voice-over can run). */
64
+ export declare const voiceEnabled: () => boolean;
65
+ /** Why a use cannot run in this build, or null when it can. */
66
+ export declare function audioUseBlocked(use: AudioUse): string | null;
@@ -0,0 +1,27 @@
1
+ import type { Document, TextNode, TextSegment } from '../document/types.js';
2
+ export interface TextTarget {
3
+ id: string;
4
+ name: string;
5
+ /** Heuristic role: heading, body, button, label, caption, price, email, date, … */
6
+ role: string;
7
+ current: string;
8
+ /** Soft character budget the replacement should stay near. */
9
+ maxChars: number;
10
+ /** Ancestor names, outermost first (e.g. "Pricing / Pro card"). */
11
+ path: string;
12
+ }
13
+ /** Text layers in (or under) the selection, in document order, skipping hidden/locked and library nodes. */
14
+ export declare function collectTextTargets(doc: Document, selection: string[], limit?: number): TextTarget[];
15
+ export declare function describeTextTarget(doc: Document, n: TextNode): TextTarget;
16
+ export declare function inferTextRole(n: TextNode, ancestorNames?: string[]): string;
17
+ /** Keep styled runs valid after the characters change: drop runs past the end, clamp the rest. */
18
+ export declare function clampSegments(segments: TextSegment[] | undefined, length: number): TextSegment[] | undefined;
19
+ /**
20
+ * Apply `{ id, text }` replacements to the targets. Unknown ids are ignored, text is clamped to a little over
21
+ * each target's budget, and empty replacements keep the original. Returns the same document when nothing
22
+ * changed.
23
+ */
24
+ export declare function applyContent(doc: Document, targets: TextTarget[], items: unknown): {
25
+ doc: Document;
26
+ changed: number;
27
+ };
@@ -0,0 +1,42 @@
1
+ export declare const AI_LIMITS: {
2
+ /** Request bodies larger than this are rejected before parsing. */
3
+ readonly maxBodyBytes: 256000;
4
+ readonly maxPromptChars: 2000;
5
+ readonly maxStyleHintChars: 400;
6
+ readonly maxFrames: 6;
7
+ readonly maxNodesPerFrame: 150;
8
+ readonly maxTotalNodes: 480;
9
+ readonly maxDepth: 8;
10
+ readonly minSize: 1;
11
+ readonly maxSize: 4000;
12
+ readonly maxTextChars: 1200;
13
+ readonly maxNameChars: 80;
14
+ readonly minFontSize: 6;
15
+ readonly maxFontSize: 160;
16
+ readonly maxSpacing: 400;
17
+ readonly maxRadius: 1000;
18
+ readonly maxStrokeWidth: 40;
19
+ readonly maxTextTargets: 80;
20
+ readonly maxContextChars: 1500;
21
+ readonly maxLayoutChildren: 60;
22
+ readonly maxEmbedValues: 128;
23
+ readonly maxEmbedChars: 1000;
24
+ readonly maxSearchItems: 2000;
25
+ /** Source image for an image action, as a data URL (platform request bodies are capped at ~4.5 MB). */
26
+ readonly maxSourceImageChars: number;
27
+ /** Selection layers sent as reference images with a prompt. */
28
+ readonly maxReferenceImages: 4;
29
+ /** Longest edge each reference is rendered at, in px. */
30
+ readonly maxReferenceEdgePx: 1024;
31
+ readonly maxReferenceImageChars: 1200000;
32
+ /** All references together, leaving room for the prompt and the edit source in one ~4.5 MB body. */
33
+ readonly maxReferenceTotalChars: number;
34
+ /** Compact document slices sent as context. */
35
+ readonly maxSliceNodes: 120;
36
+ readonly maxSliceDepth: 6;
37
+ };
38
+ export declare const clamp: (v: number, min: number, max: number) => number;
39
+ /** A finite number clamped to [min, max], or `fallback` for anything that isn't one. */
40
+ export declare function num(v: unknown, min: number, max: number, fallback: number): number;
41
+ /** A trimmed string cut to `max` characters (control characters other than newline/tab removed). */
42
+ export declare function str(v: unknown, max: number, fallback?: string): string;
@@ -0,0 +1,80 @@
1
+ /** dB → linear factor. */
2
+ export declare const dbToGain: (db: number) => number;
3
+ /** Linear factor → dB (−Infinity for 0). */
4
+ export declare const gainToDb: (g: number) => number;
5
+ interface Biquad {
6
+ b0: number;
7
+ b1: number;
8
+ b2: number;
9
+ a1: number;
10
+ a2: number;
11
+ }
12
+ /** BS.1770's K-weighting at `rate`: the head-related high shelf, then the RLB high-pass (libebur128's design). */
13
+ export declare function kWeighting(rate: number): [Biquad, Biquad];
14
+ /** Integrated loudness (LUFS) with BS.1770-4 gating; −Infinity for silence or a signal shorter than one block. */
15
+ export declare function integratedLoudness(channels: readonly Float32Array[], rate: number): number;
16
+ /** The highest |sample| (dBFS). */
17
+ export declare function samplePeak(channels: readonly Float32Array[]): number;
18
+ /**
19
+ * Per sample, the largest |value| the continuous signal reaches between sample i−1 and i (over every channel): the
20
+ * sample itself and the three oversampled points before it. What the limiter and `truePeak` read.
21
+ *
22
+ * `floor`: points that provably cannot exceed it (the largest sample under the taps × Σ|h| is at most `floor`) skip
23
+ * the interpolation and read their sample alone. Callers only care above a level — the limiter above its ceiling,
24
+ * the meter above the sample peak — and most of any real signal sits well under it, so this is what makes a
25
+ * five-minute narration measure in a fraction of a second.
26
+ */
27
+ export declare function truePeakEnvelope(channels: readonly Float32Array[], floor?: number): Float32Array;
28
+ /** True peak (dBTP): the peak of the 4× oversampled signal. */
29
+ export declare function truePeak(channels: readonly Float32Array[]): number;
30
+ export interface LimiterOptions {
31
+ /** dBTP the output never crosses. */
32
+ ceiling: number;
33
+ /** How far ahead gain starts to fall, ms. */
34
+ lookaheadMs?: number;
35
+ /** How long gain takes to recover, ms (time constant). */
36
+ releaseMs?: number;
37
+ }
38
+ /**
39
+ * `channels` limited so their true peak stays under `ceiling`: the gain each sample needs (ceiling ÷ its true-peak
40
+ * envelope), the minimum over ± the look-ahead, averaged over the look-ahead so it glides (a peak is still covered:
41
+ * every value averaged is at most its need), then released slowly. Returns the new channels and the deepest
42
+ * reduction (dB, ≥ 0).
43
+ */
44
+ export declare function limitTruePeak(channels: readonly Float32Array[], rate: number, o: LimiterOptions): {
45
+ channels: Float32Array[];
46
+ reductionDb: number;
47
+ };
48
+ export interface LoudnessReport {
49
+ /** Integrated loudness, LUFS. */
50
+ lufs: number;
51
+ /** True peak, dBTP. */
52
+ truePeak: number;
53
+ }
54
+ export declare const measure: (channels: readonly Float32Array[], rate: number) => LoudnessReport;
55
+ /**
56
+ * `channels` brought to `target` LUFS with their true peak under `ceiling` dBTP: gain, then the limiter, then — since
57
+ * limiting takes a little loudness away — gain and limiter again, until the loudness is within 0.3 LU or three passes
58
+ * are done (a peaky signal that cannot reach the target under the ceiling stays as close as it can). Silence and
59
+ * signals too short to measure come back with only the limiter applied.
60
+ */
61
+ export declare function normalize(channels: readonly Float32Array[], rate: number, o: {
62
+ target: number;
63
+ ceiling: number;
64
+ }): {
65
+ channels: Float32Array[];
66
+ before: LoudnessReport;
67
+ after: LoudnessReport;
68
+ gainDb: number;
69
+ reductionDb: number;
70
+ };
71
+ /**
72
+ * The trim (dB ≤ 0) that brings a mix measured at `m` within its target and ceiling: down by what it is over the
73
+ * target (the voice is normalised to it, so a mix over it is the bed and stingers piling on) and by what its true peak
74
+ * crosses the ceiling. Never up — a quiet mix is the settings' choice (a low bed), not a fault.
75
+ */
76
+ export declare function trimFor(m: LoudnessReport, s: {
77
+ loudness: number;
78
+ truePeak: number;
79
+ }): number;
80
+ export {};
@@ -0,0 +1,112 @@
1
+ import type { Voice } from '../../ai/audio-models.js';
2
+ /** Where a presentation sound came from. `fallback` is the code-synth stand-in made offline (lib/audio/presentation/fallback.ts). */
3
+ export type PresentationAudioSource = 'generated' | 'imported' | 'plugin' | 'fallback';
4
+ /** A sound file the soundtrack uses, as stored in the media store (48 kHz stereo WAV, loudness-normalised). */
5
+ export interface PresentationAsset {
6
+ mediaHash: string;
7
+ name: string;
8
+ /** ms. */
9
+ durationMs: number;
10
+ source: PresentationAudioSource;
11
+ /** The model that made it (a Hypery model id), for generated sounds; the plugin id for a plugin's. */
12
+ model?: string;
13
+ /** Measured after normalisation (lib/audio/presentation/loudness.ts): integrated LUFS and true peak dBTP. */
14
+ loudness?: {
15
+ lufs: number;
16
+ truePeak: number;
17
+ };
18
+ }
19
+ /** A slide's narration. */
20
+ export interface PresentationSlideAudio {
21
+ voice?: PresentationAsset;
22
+ /** A digest of the notes the narration was read from (`notesKey`): differs once the notes are edited. */
23
+ notesKey?: string;
24
+ /** A fixed length for the slide (ms), instead of following its narration. */
25
+ holdMs?: number;
26
+ }
27
+ /** The music bed, and what onset detection found in it. */
28
+ export interface PresentationMusic extends PresentationAsset {
29
+ /** Onsets in the file (file ms, sorted), for beat-aligned slide changes. */
30
+ beats?: number[];
31
+ bpm?: number | null;
32
+ }
33
+ /** The transition stinger, and where its hit is. */
34
+ export interface PresentationStinger extends PresentationAsset {
35
+ /** File ms of the loudest moment: the part that lands on the slide change. */
36
+ hitMs: number;
37
+ }
38
+ export declare const VOICE_MODELS: readonly ["natural", "hd", "standard"];
39
+ /** natural: gpt-4o-mini-tts · hd: tts-1-hd · standard: tts-1 (lib/ai/audio-models.ts SPEECH_MODELS). */
40
+ export type VoiceModelTier = (typeof VOICE_MODELS)[number];
41
+ export declare const MUSIC_MODELS: readonly ["hq", "standard"];
42
+ /** hq: Stable Audio 2.5 (44.1 kHz stereo, up to 190 s) · standard: MusicGen stereo (up to 30 s, looped). */
43
+ export type MusicModelTier = (typeof MUSIC_MODELS)[number];
44
+ export declare const PRESENTATION_STYLES: readonly ["conversational", "corporate", "energetic", "calm", "documentary"];
45
+ export type PresentationStyle = (typeof PRESENTATION_STYLES)[number];
46
+ export declare const MUSIC_MOODS: readonly ["uplifting", "ambient", "cinematic", "lofi", "electronic", "acoustic", "none"];
47
+ export type MusicMood = (typeof MUSIC_MOODS)[number];
48
+ /** Integrated loudness targets (LUFS) the panel offers. −16 is the web / presentation norm. */
49
+ export declare const LOUDNESS_TARGETS: readonly [-14, -16, -19, -23];
50
+ export interface PresentationAudioSettings {
51
+ voice: Voice;
52
+ voiceModel: VoiceModelTier;
53
+ /** Reading speed, 0.5–2 (1 normal); the style scales it. */
54
+ speed: number;
55
+ style: PresentationStyle;
56
+ mood: MusicMood;
57
+ musicModel: MusicModelTier;
58
+ stingers: boolean;
59
+ /** Integrated loudness target of the mix, LUFS. */
60
+ loudness: number;
61
+ /** True-peak ceiling, dBTP. */
62
+ truePeak: number;
63
+ /** Slide changes land on the music's beats (onset detection, lib/motion/audio-onsets.ts). */
64
+ beatAlign: boolean;
65
+ /**
66
+ * Present moves on from each slide when its narration (and tail) is done, as the soundtrack is timed — for slides
67
+ * with no advance of their own (lib/motion/present.ts `nextAutoStep`). Off: the show waits for clicks as usual.
68
+ */
69
+ autoAdvance: boolean;
70
+ /** The bed's level with nobody speaking, dB relative to the target (0 = as loud as the voice). */
71
+ musicDb: number;
72
+ /** How far the bed ducks under the voice, dB. */
73
+ duckDb: number;
74
+ /** Stingers' level, dB relative to the target. */
75
+ stingerDb: number;
76
+ /** Before a slide's narration starts (after its transition), ms; the first slide waits `introMs` instead. */
77
+ leadInMs: number;
78
+ introMs: number;
79
+ /** After it ends, before the slide moves on, ms. */
80
+ tailMs: number;
81
+ /** No slide is shorter than this, ms (a slide without notes lasts exactly this). */
82
+ minSlideMs: number;
83
+ }
84
+ /** The record on a composition that makes it a deck's soundtrack. */
85
+ export interface PresentationSoundtrack {
86
+ /** The page whose slides this narrates. */
87
+ pageId: string;
88
+ settings: PresentationAudioSettings;
89
+ /** Per slide frame id. */
90
+ slides: Record<string, PresentationSlideAudio>;
91
+ music?: PresentationMusic;
92
+ stinger?: PresentationStinger;
93
+ /** Level trim over every managed clip so the mix meets its target and ceiling (dB, ≤ 0); set by a mix measurement. */
94
+ trimDb?: number;
95
+ }
96
+ export declare const DEFAULT_SETTINGS: PresentationAudioSettings;
97
+ /** The lanes a soundtrack's clips sit on (the Animate strip shows them top to bottom). */
98
+ export declare const LANES: {
99
+ readonly voice: 0;
100
+ readonly musicA: 1;
101
+ readonly musicB: 2;
102
+ readonly stinger: 3;
103
+ };
104
+ /** Managed clip ids: the ones a re-time rewrites. Clips with any other id are the user's own and are left alone. */
105
+ export declare const CLIP_ID: {
106
+ voice: (frameId: string) => string;
107
+ music: (n: number) => string;
108
+ stinger: (n: number) => string;
109
+ };
110
+ export declare const isManagedClip: (id: string) => boolean;
111
+ /** What a generation run makes. */
112
+ export type GenerateWhat = 'all' | 'voice' | 'music' | 'stingers';
@@ -0,0 +1,25 @@
1
+ import type { Color, Document, Variable, VariableCollection } from '../document/types.js';
2
+ import type { BrandSlot } from '../templates/types.js';
3
+ import { BRAND_COLOR_ROLES, type BrandKit } from './types.js';
4
+ /**
5
+ * Template roles that are a kit role under another name. Templates call the page ground `paper` and body ink
6
+ * `ink`; a kit calls them `background` and `text`. Without this a dark kit recoloured the text and left the
7
+ * page white under it — the brand-kit QA suite (tests/templates-brand-qa.test.ts) caught it.
8
+ */
9
+ export declare const KIT_ROLE_ALIASES: Record<string, (typeof BRAND_COLOR_ROLES)[number]>;
10
+ /** Color for a role: by name, then by the kit role it aliases, then by the conventional order of the kit's colors. */
11
+ export declare function kitColor(kit: BrandKit, role: string): Color | undefined;
12
+ export declare function applyBrandKit(doc: Document, kit: BrandKit): Document;
13
+ /**
14
+ * Brand slots a document exposes: its `brand/*` variables, `{{brand.*}}` tokens, logo layers, and the heading
15
+ * and body font a kit's pair lands on (the same heading-or-body split `applyBrandKit` makes).
16
+ */
17
+ export declare function detectBrandSlots(doc: Pick<Document, 'nodes' | 'variables'> & {
18
+ styles?: Document['styles'];
19
+ }): BrandSlot[];
20
+ /** The kit as a variable collection (colors and fields) to merge into a document or publish as a library. */
21
+ export declare function brandKitToVariables(kit: BrandKit): {
22
+ collection: VariableCollection;
23
+ variables: Variable[];
24
+ };
25
+ export declare function createBrandKit(props?: Partial<BrandKit>): BrandKit;
@@ -0,0 +1,10 @@
1
+ import type { BrandKit } from './types.js';
2
+ /** A deep blue brand on white. */
3
+ export declare const LIGHT_REVIEW_KIT: BrandKit;
4
+ /** A near-black ground, light ink, a pale primary. */
5
+ export declare const DARK_REVIEW_KIT: BrandKit;
6
+ export declare const REVIEW_KITS: {
7
+ readonly light: BrandKit;
8
+ readonly dark: BrandKit;
9
+ };
10
+ export type ReviewKit = keyof typeof REVIEW_KITS;
@@ -0,0 +1,20 @@
1
+ import type { Color } from '../document/types.js';
2
+ /** A brand: named colors, a heading/body font pair, logos (media refs) and text fields (name, tagline…). */
3
+ export interface BrandKit {
4
+ id: string;
5
+ name: string;
6
+ colors: {
7
+ name: string;
8
+ color: Color;
9
+ }[];
10
+ fonts: {
11
+ heading: string;
12
+ body: string;
13
+ };
14
+ logos: string[];
15
+ fields: Record<string, string>;
16
+ createdAt: number;
17
+ updatedAt: number;
18
+ }
19
+ export declare const BRAND_COLOR_ROLES: readonly ["primary", "secondary", "accent", "background", "text"];
20
+ export declare const BRAND_FIELDS: readonly ["name", "tagline", "website", "email", "phone", "address"];
@@ -0,0 +1,2 @@
1
+ /** A short stable name for a string (djb2): keys of what was built from it. */
2
+ export declare function hashOf(text: string): string;