@softure-ai/marketing-kit 0.1.7 → 0.1.8

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 (107) hide show
  1. package/README.md +79 -11
  2. package/dist/cli/main.js +84 -29
  3. package/dist/cli/main.js.map +1 -1
  4. package/dist/cli/og.d.ts +4 -1
  5. package/dist/cli/og.d.ts.map +1 -1
  6. package/dist/cli/og.js +15 -7
  7. package/dist/cli/og.js.map +1 -1
  8. package/dist/cli/options.d.ts +26 -2
  9. package/dist/cli/options.d.ts.map +1 -1
  10. package/dist/cli/options.js +97 -9
  11. package/dist/cli/options.js.map +1 -1
  12. package/dist/cli/voice.d.ts +14 -0
  13. package/dist/cli/voice.d.ts.map +1 -1
  14. package/dist/cli/voice.js +13 -0
  15. package/dist/cli/voice.js.map +1 -1
  16. package/dist/config/actions-schema.d.ts +14 -14
  17. package/dist/config/config.d.ts +2 -0
  18. package/dist/config/config.d.ts.map +1 -1
  19. package/dist/config/config.js +1 -1
  20. package/dist/config/config.js.map +1 -1
  21. package/dist/config/og-image-names.d.ts +7 -0
  22. package/dist/config/og-image-names.d.ts.map +1 -0
  23. package/dist/config/og-image-names.js +9 -0
  24. package/dist/config/og-image-names.js.map +1 -0
  25. package/dist/config/schema.d.ts +103 -15
  26. package/dist/config/schema.d.ts.map +1 -1
  27. package/dist/config/schema.js +64 -7
  28. package/dist/config/schema.js.map +1 -1
  29. package/dist/index.d.ts +5 -3
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +5 -3
  32. package/dist/index.js.map +1 -1
  33. package/dist/og/index.d.ts +3 -3
  34. package/dist/og/index.d.ts.map +1 -1
  35. package/dist/og/index.js +3 -2
  36. package/dist/og/index.js.map +1 -1
  37. package/dist/og/render.d.ts +13 -0
  38. package/dist/og/render.d.ts.map +1 -1
  39. package/dist/og/render.js +31 -6
  40. package/dist/og/render.js.map +1 -1
  41. package/dist/og/templates/big-number.d.ts +7 -0
  42. package/dist/og/templates/big-number.d.ts.map +1 -0
  43. package/dist/og/templates/big-number.js +41 -0
  44. package/dist/og/templates/big-number.js.map +1 -0
  45. package/dist/og/templates/carousel.d.ts +5 -0
  46. package/dist/og/templates/carousel.d.ts.map +1 -0
  47. package/dist/og/templates/carousel.js +26 -0
  48. package/dist/og/templates/carousel.js.map +1 -0
  49. package/dist/og/templates/context.d.ts +11 -3
  50. package/dist/og/templates/context.d.ts.map +1 -1
  51. package/dist/og/templates/context.js +6 -0
  52. package/dist/og/templates/context.js.map +1 -1
  53. package/dist/og/templates/frame.d.ts +2 -2
  54. package/dist/og/templates/frame.d.ts.map +1 -1
  55. package/dist/og/templates/frame.js +2 -2
  56. package/dist/og/templates/frame.js.map +1 -1
  57. package/dist/og/templates/index.d.ts +8 -3
  58. package/dist/og/templates/index.d.ts.map +1 -1
  59. package/dist/og/templates/index.js +18 -5
  60. package/dist/og/templates/index.js.map +1 -1
  61. package/dist/og/templates/portrait.d.ts +22 -0
  62. package/dist/og/templates/portrait.d.ts.map +1 -0
  63. package/dist/og/templates/portrait.js +75 -0
  64. package/dist/og/templates/portrait.js.map +1 -0
  65. package/dist/og/templates/schemas.d.ts +28 -0
  66. package/dist/og/templates/schemas.d.ts.map +1 -1
  67. package/dist/og/templates/schemas.js +26 -0
  68. package/dist/og/templates/schemas.js.map +1 -1
  69. package/dist/screenshot/gates.d.ts +6 -3
  70. package/dist/screenshot/gates.d.ts.map +1 -1
  71. package/dist/screenshot/gates.js +12 -3
  72. package/dist/screenshot/gates.js.map +1 -1
  73. package/dist/screenshot/screenshot.d.ts +17 -0
  74. package/dist/screenshot/screenshot.d.ts.map +1 -1
  75. package/dist/screenshot/screenshot.js +37 -6
  76. package/dist/screenshot/screenshot.js.map +1 -1
  77. package/dist/screenshot/storage-state.d.ts +9 -0
  78. package/dist/screenshot/storage-state.d.ts.map +1 -0
  79. package/dist/screenshot/storage-state.js +25 -0
  80. package/dist/screenshot/storage-state.js.map +1 -0
  81. package/dist/voice/placeholder.d.ts +35 -0
  82. package/dist/voice/placeholder.d.ts.map +1 -0
  83. package/dist/voice/placeholder.js +53 -0
  84. package/dist/voice/placeholder.js.map +1 -0
  85. package/package.json +1 -1
  86. package/schema/marketing.schema.json +343 -37
  87. package/src/cli/main.ts +80 -27
  88. package/src/cli/og.ts +14 -6
  89. package/src/cli/options.ts +109 -10
  90. package/src/cli/voice.ts +20 -0
  91. package/src/config/config.ts +3 -2
  92. package/src/config/og-image-names.ts +7 -0
  93. package/src/config/schema.ts +72 -8
  94. package/src/index.ts +7 -1
  95. package/src/og/index.ts +16 -2
  96. package/src/og/render.ts +36 -6
  97. package/src/og/templates/big-number.ts +44 -0
  98. package/src/og/templates/carousel.ts +27 -0
  99. package/src/og/templates/context.ts +16 -3
  100. package/src/og/templates/frame.ts +2 -2
  101. package/src/og/templates/index.ts +31 -9
  102. package/src/og/templates/portrait.ts +126 -0
  103. package/src/og/templates/schemas.ts +35 -0
  104. package/src/screenshot/gates.ts +13 -3
  105. package/src/screenshot/screenshot.ts +51 -11
  106. package/src/screenshot/storage-state.ts +24 -0
  107. package/src/voice/placeholder.ts +83 -0
@@ -482,6 +482,28 @@
482
482
  "description": "The paid voiceover cache (<key>.mp3 and <key>.json), relative to the folder of marketing.json; commit it.",
483
483
  "type": "string",
484
484
  "minLength": 1
485
+ },
486
+ "placeholder": {
487
+ "description": "The free placeholder voiceover of --placeholder (a quiet tone, words at a fixed pace), to record and render a film before paying for its voiceover.",
488
+ "default": {},
489
+ "type": "object",
490
+ "properties": {
491
+ "wordsPerSecond": {
492
+ "default": 2.5,
493
+ "description": "Words per second of the placeholder voiceover (0.5-6, default 2.5); match the real voice to rehearse the film's length.",
494
+ "type": "number",
495
+ "minimum": 0.5,
496
+ "maximum": 6
497
+ },
498
+ "sentencePauseSeconds": {
499
+ "default": 0.5,
500
+ "description": "Silence after every sentence of the placeholder voiceover but the last (0-3 s, default 0.5).",
501
+ "type": "number",
502
+ "minimum": 0,
503
+ "maximum": 3
504
+ }
505
+ },
506
+ "additionalProperties": false
485
507
  }
486
508
  },
487
509
  "required": [
@@ -2644,6 +2666,24 @@
2644
2666
  "dark"
2645
2667
  ]
2646
2668
  }
2669
+ },
2670
+ "scrollTo": {
2671
+ "description": "Capture one viewport frame scrolled to this many CSS pixels from the top (e.g. to check scroll-driven motion, with motion: \"no-preference\"); refused when the page cannot scroll that far. Not with full.",
2672
+ "type": "integer",
2673
+ "minimum": 0,
2674
+ "maximum": 9007199254740991
2675
+ },
2676
+ "waitMs": {
2677
+ "default": 0,
2678
+ "description": "Milliseconds to wait after the page loaded (and scrolled) before the phrase gate reads it, for animations to settle (0-60000, default 0).",
2679
+ "type": "integer",
2680
+ "minimum": 0,
2681
+ "maximum": 60000
2682
+ },
2683
+ "storageState": {
2684
+ "description": "A Playwright storage state (cookies and localStorage as JSON), relative to the folder of marketing.json, to capture a signed-in screen. It holds a session: keep it out of git.",
2685
+ "type": "string",
2686
+ "minLength": 1
2647
2687
  }
2648
2688
  },
2649
2689
  "required": [
@@ -2657,7 +2697,6 @@
2657
2697
  }
2658
2698
  },
2659
2699
  "ogImages": {
2660
- "default": [],
2661
2700
  "description": "Open Graph images rendered by softure-marketing og.",
2662
2701
  "type": "array",
2663
2702
  "items": {
@@ -2668,30 +2707,39 @@
2668
2707
  "id": {
2669
2708
  "type": "string",
2670
2709
  "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$",
2671
- "description": "The image's id: the file <output.dir>/og/<id>.png."
2710
+ "description": "The image's id: the file <output.dir>/og/<id>.png (a carousel writes <id>-1.png, <id>-2.png and so on)."
2672
2711
  },
2673
2712
  "size": {
2674
- "default": [
2675
- 1200,
2676
- 630
2677
- ],
2678
- "description": "The image size in pixels, [width, height].",
2679
- "type": "array",
2680
- "prefixItems": [
2713
+ "description": "The image size: \"landscape\" (1200×630), \"portrait\" (1080×1350), \"square\" (1080×1080), \"story\" (1080×1920) or [width, height] in pixels; \"landscape\" by default.",
2714
+ "anyOf": [
2681
2715
  {
2682
- "type": "integer",
2683
- "minimum": 1,
2684
- "maximum": 4000
2716
+ "type": "array",
2717
+ "prefixItems": [
2718
+ {
2719
+ "type": "integer",
2720
+ "minimum": 1,
2721
+ "maximum": 4000
2722
+ },
2723
+ {
2724
+ "type": "integer",
2725
+ "minimum": 1,
2726
+ "maximum": 4000
2727
+ }
2728
+ ],
2729
+ "items": false,
2730
+ "minItems": 2,
2731
+ "maxItems": 2
2685
2732
  },
2686
2733
  {
2687
- "type": "integer",
2688
- "minimum": 1,
2689
- "maximum": 4000
2734
+ "type": "string",
2735
+ "enum": [
2736
+ "landscape",
2737
+ "portrait",
2738
+ "square",
2739
+ "story"
2740
+ ]
2690
2741
  }
2691
- ],
2692
- "items": false,
2693
- "minItems": 2,
2694
- "maxItems": 2
2742
+ ]
2695
2743
  },
2696
2744
  "template": {
2697
2745
  "type": "string",
@@ -2763,30 +2811,39 @@
2763
2811
  "id": {
2764
2812
  "type": "string",
2765
2813
  "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$",
2766
- "description": "The image's id: the file <output.dir>/og/<id>.png."
2814
+ "description": "The image's id: the file <output.dir>/og/<id>.png (a carousel writes <id>-1.png, <id>-2.png and so on)."
2767
2815
  },
2768
2816
  "size": {
2769
- "default": [
2770
- 1200,
2771
- 630
2772
- ],
2773
- "description": "The image size in pixels, [width, height].",
2774
- "type": "array",
2775
- "prefixItems": [
2817
+ "description": "The image size: \"landscape\" (1200×630), \"portrait\" (1080×1350), \"square\" (1080×1080), \"story\" (1080×1920) or [width, height] in pixels; \"landscape\" by default.",
2818
+ "anyOf": [
2776
2819
  {
2777
- "type": "integer",
2778
- "minimum": 1,
2779
- "maximum": 4000
2820
+ "type": "array",
2821
+ "prefixItems": [
2822
+ {
2823
+ "type": "integer",
2824
+ "minimum": 1,
2825
+ "maximum": 4000
2826
+ },
2827
+ {
2828
+ "type": "integer",
2829
+ "minimum": 1,
2830
+ "maximum": 4000
2831
+ }
2832
+ ],
2833
+ "items": false,
2834
+ "minItems": 2,
2835
+ "maxItems": 2
2780
2836
  },
2781
2837
  {
2782
- "type": "integer",
2783
- "minimum": 1,
2784
- "maximum": 4000
2838
+ "type": "string",
2839
+ "enum": [
2840
+ "landscape",
2841
+ "portrait",
2842
+ "square",
2843
+ "story"
2844
+ ]
2785
2845
  }
2786
- ],
2787
- "items": false,
2788
- "minItems": 2,
2789
- "maxItems": 2
2846
+ ]
2790
2847
  },
2791
2848
  "template": {
2792
2849
  "type": "string",
@@ -2918,6 +2975,255 @@
2918
2975
  "data"
2919
2976
  ],
2920
2977
  "additionalProperties": false
2978
+ },
2979
+ {
2980
+ "type": "object",
2981
+ "properties": {
2982
+ "id": {
2983
+ "type": "string",
2984
+ "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$",
2985
+ "description": "The image's id: the file <output.dir>/og/<id>.png (a carousel writes <id>-1.png, <id>-2.png and so on)."
2986
+ },
2987
+ "size": {
2988
+ "description": "The image size: \"landscape\" (1200×630), \"portrait\" (1080×1350), \"square\" (1080×1080), \"story\" (1080×1920) or [width, height] in pixels; \"portrait\" by default.",
2989
+ "anyOf": [
2990
+ {
2991
+ "type": "array",
2992
+ "prefixItems": [
2993
+ {
2994
+ "type": "integer",
2995
+ "minimum": 1,
2996
+ "maximum": 4000
2997
+ },
2998
+ {
2999
+ "type": "integer",
3000
+ "minimum": 1,
3001
+ "maximum": 4000
3002
+ }
3003
+ ],
3004
+ "items": false,
3005
+ "minItems": 2,
3006
+ "maxItems": 2
3007
+ },
3008
+ {
3009
+ "type": "string",
3010
+ "enum": [
3011
+ "landscape",
3012
+ "portrait",
3013
+ "square",
3014
+ "story"
3015
+ ]
3016
+ }
3017
+ ]
3018
+ },
3019
+ "template": {
3020
+ "type": "string",
3021
+ "const": "big-number",
3022
+ "description": "A portrait post whose number fills the frame, with the sentence that explains it, tiles, a call to action and a source line."
3023
+ },
3024
+ "data": {
3025
+ "type": "object",
3026
+ "properties": {
3027
+ "eyebrow": {
3028
+ "description": "A short line above the headline, at most 40 characters.",
3029
+ "type": "string",
3030
+ "maxLength": 40
3031
+ },
3032
+ "number": {
3033
+ "type": "string",
3034
+ "maxLength": 12,
3035
+ "description": "The figure that fills the post, unit included, e.g. \"898 PLN\"; at most 12 characters. Shorter numbers get bigger type."
3036
+ },
3037
+ "caption": {
3038
+ "type": "string",
3039
+ "maxLength": 90,
3040
+ "description": "The sentence that says what the number is, under it; at most 90 characters."
3041
+ },
3042
+ "tiles": {
3043
+ "default": [],
3044
+ "description": "Up to two label and value tiles under the caption, e.g. a second figure.",
3045
+ "maxItems": 2,
3046
+ "type": "array",
3047
+ "items": {
3048
+ "type": "object",
3049
+ "properties": {
3050
+ "label": {
3051
+ "type": "string",
3052
+ "maxLength": 24,
3053
+ "description": "The tile's caption, at most 24 characters."
3054
+ },
3055
+ "value": {
3056
+ "type": "string",
3057
+ "maxLength": 16,
3058
+ "description": "The tile's value, at most 16 characters."
3059
+ }
3060
+ },
3061
+ "required": [
3062
+ "label",
3063
+ "value"
3064
+ ],
3065
+ "additionalProperties": false
3066
+ }
3067
+ },
3068
+ "cta": {
3069
+ "description": "A call to action, drawn as a pill in the cta colours at the bottom; at most 32 characters.",
3070
+ "type": "string",
3071
+ "maxLength": 32
3072
+ },
3073
+ "source": {
3074
+ "description": "Where the figures come from, drawn small at the bottom, e.g. \"Source: ZUS, 2026\"; at most 80 characters.",
3075
+ "type": "string",
3076
+ "maxLength": 80
3077
+ }
3078
+ },
3079
+ "required": [
3080
+ "number",
3081
+ "caption"
3082
+ ],
3083
+ "additionalProperties": false,
3084
+ "description": "The big-number template's input."
3085
+ }
3086
+ },
3087
+ "required": [
3088
+ "id",
3089
+ "template",
3090
+ "data"
3091
+ ],
3092
+ "additionalProperties": false
3093
+ },
3094
+ {
3095
+ "type": "object",
3096
+ "properties": {
3097
+ "id": {
3098
+ "type": "string",
3099
+ "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$",
3100
+ "description": "The image's id: the file <output.dir>/og/<id>.png (a carousel writes <id>-1.png, <id>-2.png and so on)."
3101
+ },
3102
+ "size": {
3103
+ "description": "The image size: \"landscape\" (1200×630), \"portrait\" (1080×1350), \"square\" (1080×1080), \"story\" (1080×1920) or [width, height] in pixels; \"portrait\" by default.",
3104
+ "anyOf": [
3105
+ {
3106
+ "type": "array",
3107
+ "prefixItems": [
3108
+ {
3109
+ "type": "integer",
3110
+ "minimum": 1,
3111
+ "maximum": 4000
3112
+ },
3113
+ {
3114
+ "type": "integer",
3115
+ "minimum": 1,
3116
+ "maximum": 4000
3117
+ }
3118
+ ],
3119
+ "items": false,
3120
+ "minItems": 2,
3121
+ "maxItems": 2
3122
+ },
3123
+ {
3124
+ "type": "string",
3125
+ "enum": [
3126
+ "landscape",
3127
+ "portrait",
3128
+ "square",
3129
+ "story"
3130
+ ]
3131
+ }
3132
+ ]
3133
+ },
3134
+ "template": {
3135
+ "type": "string",
3136
+ "const": "carousel",
3137
+ "description": "A numbered run of portrait slides sharing one look; each slide is its own file <id>-<n>.png."
3138
+ },
3139
+ "data": {
3140
+ "type": "object",
3141
+ "properties": {
3142
+ "slides": {
3143
+ "minItems": 2,
3144
+ "maxItems": 10,
3145
+ "type": "array",
3146
+ "items": {
3147
+ "type": "object",
3148
+ "properties": {
3149
+ "eyebrow": {
3150
+ "description": "A short line above the headline, at most 40 characters.",
3151
+ "type": "string",
3152
+ "maxLength": 40
3153
+ },
3154
+ "headline": {
3155
+ "type": "string",
3156
+ "maxLength": 90,
3157
+ "description": "The slide's headline, at most 90 characters."
3158
+ },
3159
+ "body": {
3160
+ "description": "A paragraph under the headline, at most 200 characters.",
3161
+ "type": "string",
3162
+ "maxLength": 200
3163
+ },
3164
+ "tiles": {
3165
+ "default": [],
3166
+ "description": "Up to two label and value tiles side by side.",
3167
+ "maxItems": 2,
3168
+ "type": "array",
3169
+ "items": {
3170
+ "type": "object",
3171
+ "properties": {
3172
+ "label": {
3173
+ "type": "string",
3174
+ "maxLength": 24,
3175
+ "description": "The tile's caption, at most 24 characters."
3176
+ },
3177
+ "value": {
3178
+ "type": "string",
3179
+ "maxLength": 16,
3180
+ "description": "The tile's value, at most 16 characters."
3181
+ }
3182
+ },
3183
+ "required": [
3184
+ "label",
3185
+ "value"
3186
+ ],
3187
+ "additionalProperties": false
3188
+ }
3189
+ },
3190
+ "cta": {
3191
+ "description": "A call to action, drawn as a pill in the cta colours at the bottom; at most 32 characters.",
3192
+ "type": "string",
3193
+ "maxLength": 32
3194
+ },
3195
+ "source": {
3196
+ "description": "Where the figures come from, drawn small at the bottom, e.g. \"Source: ZUS, 2026\"; at most 80 characters.",
3197
+ "type": "string",
3198
+ "maxLength": 80
3199
+ }
3200
+ },
3201
+ "required": [
3202
+ "headline"
3203
+ ],
3204
+ "additionalProperties": false
3205
+ },
3206
+ "description": "The slides in order, two to ten; each renders to its own file <id>-<n>.png."
3207
+ },
3208
+ "counter": {
3209
+ "default": true,
3210
+ "description": "Draws \"n/N\" in the top corner of every slide.",
3211
+ "type": "boolean"
3212
+ }
3213
+ },
3214
+ "required": [
3215
+ "slides"
3216
+ ],
3217
+ "additionalProperties": false,
3218
+ "description": "The carousel template's input."
3219
+ }
3220
+ },
3221
+ "required": [
3222
+ "id",
3223
+ "template",
3224
+ "data"
3225
+ ],
3226
+ "additionalProperties": false
2921
3227
  }
2922
3228
  ]
2923
3229
  }
package/src/cli/main.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { existsSync, mkdirSync, writeFileSync } from "node:fs";
3
- import { join } from "node:path";
3
+ import { join, resolve } from "node:path";
4
4
 
5
5
  import { findMissingFiles, formatConfigIssues, loadMarketingConfig, type MarketingConfig } from "../config/config.js";
6
6
  import { getGeometry, getLayoutName } from "../compose/timeline.js";
@@ -11,19 +11,21 @@ import { recordFilm, ScreenGuardError, type RecordingLog } from "../record/recor
11
11
  import { findMachineProblem } from "../render/preflight.js";
12
12
  import { runHyperframes } from "../render/hyperframes.js";
13
13
  import { renderFilm } from "../render/render.js";
14
- import { takeScreenshots, type ScreenshotEntry } from "../screenshot/screenshot.js";
14
+ import { takePageScreenshot, takeScreenshots, type ScreenshotBrowser, type ScreenshotEntry, type ScreenshotResult } from "../screenshot/screenshot.js";
15
+ import { findStorageStateProblem } from "../screenshot/storage-state.js";
16
+ import { isPlaceholderKey } from "../voice/placeholder.js";
15
17
  import { splitIntoBeats } from "../voice/voiceover.js";
16
18
  import { CliFailure, fail } from "./failure.js";
17
19
  import { loadFilm, type LoadedFilm } from "./films.js";
18
20
  import { writeOgImages } from "./og.js";
19
- import { getRecordingDay, readOptions, type FilmOptions, type ShotsOptions } from "./options.js";
21
+ import { getRecordingDay, readOptions, type EntryShotsOptions, type FilmOptions, type PageShotsOptions } from "./options.js";
20
22
  import { ensureServer } from "./server.js";
21
- import { getVoiceoverPaths, produceVoiceover, produceVoiceovers, readJson, requireVoiceover } from "./voice.js";
23
+ import { getFilmVoiceover, produceVoiceover, produceVoiceovers, readJson } from "./voice.js";
22
24
 
23
25
  /**
24
26
  * `softure-marketing`: the only way into the films.
25
27
  *
26
- * all <film> voiceover from the cache -> recording -> render -> post copy
28
+ * all <film> [--placeholder] voiceover from the cache (or the free placeholder) -> recording -> render -> post copy
27
29
  * voice <film>... [--commit] voiceovers in order (paid only with --commit), spaced and stopped at the first error
28
30
  * record <film> [--today=YYYY-MM-DD] [--url=...] (--today overrides the video's today)
29
31
  * render <film> [--quality=draft|standard|high]
@@ -31,6 +33,7 @@ import { getVoiceoverPaths, produceVoiceover, produceVoiceovers, readJson, requi
31
33
  * posts <film>
32
34
  * og [image]
33
35
  * shots [<id>] [--url=...]
36
+ * shots --page=<url> --out=<file.png> --expect=<phrase> [...]
34
37
  */
35
38
 
36
39
  const getBuildDir = (config: MarketingConfig, film: LoadedFilm) => join(config.output.buildDir, film.id);
@@ -44,7 +47,8 @@ function preflight(config: MarketingConfig, film: LoadedFilm, needsRender: boole
44
47
  }
45
48
 
46
49
  async function record(config: MarketingConfig, film: LoadedFilm, options: FilmOptions): Promise<RecordingLog> {
47
- const voiceover = requireVoiceover(config, film);
50
+ const { voiceover, key, isPlaceholder } = getFilmVoiceover(config, film, { isPlaceholder: options.isPlaceholder, buildDir: getBuildDir(config, film) });
51
+ if (isPlaceholder) console.log(`voiceover: the placeholder (a tone, ${config.voice.placeholder.wordsPerSecond} words a second); nothing paid, render it with --placeholder.`);
48
52
  const voices = splitIntoBeats(voiceover.words, film.beats, film.voice.tempo);
49
53
  const server = await ensureServer(config, film, options.url);
50
54
  mkdirSync(getBuildDir(config, film), { recursive: true });
@@ -57,7 +61,7 @@ async function record(config: MarketingConfig, film: LoadedFilm, options: FilmOp
57
61
  url: server.url,
58
62
  outDir: getBuildDir(config, film),
59
63
  voices,
60
- voiceoverKey: getVoiceoverPaths(config, film).key,
64
+ voiceoverKey: key,
61
65
  today: recordingDay.day ?? undefined,
62
66
  filmPath: film.scenePath,
63
67
  executablePath: process.env.PLAYWRIGHT_CHROMIUM_PATH || undefined,
@@ -103,14 +107,21 @@ function render(config: MarketingConfig, film: LoadedFilm, options: FilmOptions)
103
107
  if (!existsSync(logPath)) fail(`no recording: run softure-marketing record ${film.id} first.`);
104
108
  // Our own file, written by `recordFilm`; the two fields that tie it to the script are checked below.
105
109
  const log = readJson(logPath) as RecordingLog;
106
- const voiceover = requireVoiceover(config, film);
110
+ // A recording follows the timings of the voiceover it was made on, so a placeholder recording never renders
111
+ // with the paid voiceover, nor the reverse.
112
+ if (isPlaceholderKey(log.voiceoverKey) !== options.isPlaceholder) {
113
+ if (options.isPlaceholder) fail(`the recording was made on the paid voiceover: run softure-marketing record ${film.id} --placeholder, or render without --placeholder.`);
114
+ fail(`the recording was made on the placeholder voiceover: run softure-marketing record ${film.id} for the paid one, or render with --placeholder.`);
115
+ }
116
+ const { voiceover, key } = getFilmVoiceover(config, film, { isPlaceholder: options.isPlaceholder, buildDir: dir });
107
117
  // The recording must match the script; otherwise the action times belong to another voiceover or
108
118
  // other sentences, and the film would come out silently out of sync.
109
119
  const beatIds = sceneBeats(film).map((beat) => beat.id);
110
- if (log.voiceoverKey !== getVoiceoverPaths(config, film).key || log.beatIds?.join(",") !== beatIds.join(",")) {
111
- fail(`the recording does not match the current script (the sentences or the voiceover changed): run softure-marketing record ${film.id}.`);
120
+ if (log.voiceoverKey !== key || log.beatIds?.join(",") !== beatIds.join(",")) {
121
+ fail(`the recording does not match the current script (the sentences or the voiceover changed): run softure-marketing record ${film.id}${options.isPlaceholder ? " --placeholder" : ""}.`);
112
122
  }
113
- const output = join(getOutDir(config, film), `${film.id}.mp4`);
123
+ // A rehearsal never takes the place of the real film.
124
+ const output = join(getOutDir(config, film), options.isPlaceholder ? `${film.id}.placeholder.mp4` : `${film.id}.mp4`);
114
125
  const seconds = renderFilm({
115
126
  film,
116
127
  log,
@@ -146,8 +157,57 @@ function selectScreenshots(config: MarketingConfig, shotId: string | undefined):
146
157
  fail(`no screenshot "${shotId}" in ${config.file}; known: ${config.screenshots.map((entry) => entry.id).join(", ") || "none"}.`);
147
158
  }
148
159
 
149
- async function shots(config: MarketingConfig, options: ShotsOptions): Promise<void> {
150
- const entries = selectScreenshots(config, options.shotId);
160
+ /** The entries with their storage state as an absolute path, each checked before the browser starts. */
161
+ function resolveStorageStates(config: MarketingConfig, entries: [ScreenshotEntry, ...ScreenshotEntry[]]): [ScreenshotEntry, ...ScreenshotEntry[]] {
162
+ const [first, ...rest] = entries.map((entry) => {
163
+ if (entry.storageState === undefined) return entry;
164
+ const path = resolve(config.root, entry.storageState);
165
+ const problem = findStorageStateProblem(path);
166
+ if (problem !== null) fail(`screenshot "${entry.id}": ${problem}.`);
167
+ return { ...entry, storageState: path };
168
+ });
169
+ // The map keeps the length of a non-empty tuple.
170
+ return [first as ScreenshotEntry, ...rest];
171
+ }
172
+
173
+ function getScreenshotBrowser(config: MarketingConfig): ScreenshotBrowser {
174
+ return { colorScheme: config.app.colorScheme, locale: config.brand.locale, timezone: config.brand.timezone, hideSelectors: config.app.hideSelectors };
175
+ }
176
+
177
+ /** Prints each result and fails when any shot was refused. */
178
+ function reportScreenshots(results: ScreenshotResult[]): void {
179
+ for (const result of results) {
180
+ if (result.ok) console.log(`✓ ${result.file} (${(result.bytes / 1000).toFixed(0)} kB)`);
181
+ else console.error(`✗ ${result.name}: ${result.message}`);
182
+ }
183
+ const failed = results.filter((result) => !result.ok).length;
184
+ if (failed > 0) fail(`${failed} of ${results.length} screenshots failed their gates; see above.`);
185
+ }
186
+
187
+ /** `shots --page`: one page anywhere; the app is not started, and the storage state resolves from the current directory. */
188
+ async function pageShot(config: MarketingConfig, options: PageShotsOptions): Promise<void> {
189
+ let { entry } = options;
190
+ if (entry.storageState !== undefined) {
191
+ const path = resolve(entry.storageState);
192
+ const problem = findStorageStateProblem(path);
193
+ if (problem !== null) fail(`--auth: ${problem}.`);
194
+ entry = { ...entry, storageState: path };
195
+ }
196
+ const file = resolve(options.out);
197
+ console.log(`screenshot: ${options.page}.`);
198
+ const result = await takePageScreenshot({
199
+ entry,
200
+ url: options.page,
201
+ file,
202
+ scheme: options.scheme,
203
+ browser: getScreenshotBrowser(config),
204
+ executablePath: process.env.PLAYWRIGHT_CHROMIUM_PATH || undefined,
205
+ });
206
+ reportScreenshots([result]);
207
+ }
208
+
209
+ async function shots(config: MarketingConfig, options: EntryShotsOptions): Promise<void> {
210
+ const entries = resolveStorageStates(config, selectScreenshots(config, options.shotId));
151
211
  const [first] = entries;
152
212
  const target = { url: new URL(first.path, config.app.baseUrl).href, ownUrl: `http://localhost:${config.app.port}${first.path}` };
153
213
  const server = await ensureServer(config, target, options.url === undefined ? undefined : new URL(first.path, options.url).href);
@@ -160,22 +220,12 @@ async function shots(config: MarketingConfig, options: ShotsOptions): Promise<vo
160
220
  baseUrl: server.url,
161
221
  outDir,
162
222
  executablePath: process.env.PLAYWRIGHT_CHROMIUM_PATH || undefined,
163
- browser: {
164
- colorScheme: config.app.colorScheme,
165
- locale: config.brand.locale,
166
- timezone: config.brand.timezone,
167
- hideSelectors: config.app.hideSelectors,
168
- },
223
+ browser: getScreenshotBrowser(config),
169
224
  });
170
225
  } finally {
171
226
  server.stop();
172
227
  }
173
- for (const result of results) {
174
- if (result.ok) console.log(`✓ ${result.file} (${(result.bytes / 1000).toFixed(0)} kB)`);
175
- else console.error(`✗ ${result.name}: ${result.message}`);
176
- }
177
- const failed = results.filter((result) => !result.ok).length;
178
- if (failed > 0) fail(`${failed} of ${results.length} screenshots failed their gates; see above.`);
228
+ reportScreenshots(results);
179
229
  }
180
230
 
181
231
  async function main(argv: string[]): Promise<void> {
@@ -190,7 +240,8 @@ async function main(argv: string[]): Promise<void> {
190
240
  return;
191
241
  }
192
242
  if (options.command === "shots") {
193
- await shots(config, options);
243
+ if (options.mode === "page") await pageShot(config, options);
244
+ else await shots(config, options);
194
245
  return;
195
246
  }
196
247
  if (options.command === "voice") {
@@ -223,7 +274,9 @@ async function main(argv: string[]): Promise<void> {
223
274
  }
224
275
  case "all": {
225
276
  preflight(config, film, true);
226
- if ((await produceVoiceover(config, film, false)) === null) fail("no voiceover; see the message above.");
277
+ if (!options.isPlaceholder && (await produceVoiceover(config, film, false)) === null) {
278
+ fail(`no voiceover; see the message above. To rehearse the film for free: softure-marketing all ${film.id} --placeholder.`);
279
+ }
227
280
  await record(config, film, options);
228
281
  render(config, film, options);
229
282
  return;
package/src/cli/og.ts CHANGED
@@ -2,10 +2,14 @@ import { mkdirSync, writeFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
3
 
4
4
  import type { MarketingConfig } from "../config/config.js";
5
+ import { getOgImageNames } from "../config/og-image-names.js";
5
6
  import { renderConfiguredOgImage } from "../og/render.js";
6
7
  import { fail } from "./failure.js";
7
8
 
8
- /** `og [image]`: writes `<output.dir>/og/<id>.png` for every `ogImages` entry, or for the one named. */
9
+ /**
10
+ * `og [image]`: writes `<output.dir>/og/<id>.png` for every `ogImages` entry, or for the one named; a carousel
11
+ * writes one file per slide, `<id>-1.png`…`<id>-<n>.png`.
12
+ */
9
13
  export async function writeOgImages(config: MarketingConfig, imageId: string | null): Promise<void> {
10
14
  const entries = imageId === null ? config.ogImages : config.ogImages.filter((image) => image.id === imageId);
11
15
  if (config.ogImages.length === 0) fail(`no OG images: add entries to ogImages in ${config.file}.`);
@@ -15,10 +19,14 @@ export async function writeOgImages(config: MarketingConfig, imageId: string | n
15
19
  const dir = join(config.output.dir, "og");
16
20
  mkdirSync(dir, { recursive: true });
17
21
  for (const entry of entries) {
18
- const png = await renderConfiguredOgImage({ config, id: entry.id });
19
- if (!png.ok) fail(png.error);
20
- const path = join(dir, `${entry.id}.png`);
21
- writeFileSync(path, png.value);
22
- console.log(`✓ ${path} (${entry.size[0]}×${entry.size[1]}, ${entry.template})`);
22
+ const names = getOgImageNames(entry);
23
+ for (const [index, name] of names.entries()) {
24
+ const png = await renderConfiguredOgImage({ config, id: entry.id, slide: index + 1 });
25
+ if (!png.ok) fail(png.error);
26
+ const path = join(dir, `${name}.png`);
27
+ writeFileSync(path, png.value);
28
+ const slide = names.length > 1 ? `, slide ${String(index + 1)}/${String(names.length)}` : "";
29
+ console.log(`✓ ${path} (${String(entry.size[0])}×${String(entry.size[1])}, ${entry.template}${slide})`);
30
+ }
23
31
  }
24
32
  }