@softure-ai/marketing-kit 0.1.11 → 0.1.12

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.
@@ -3,7 +3,7 @@ import { getLocator } from "../record/locator.js";
3
3
  * Steps of the sign-in and of a screenshot entry, done in order on the page. A step that cannot be done (its
4
4
  * element never appears, matches several, is not an input, is not a `<details>`) is the page's or the config's
5
5
  * fault, so it comes back as a message naming the step; the message never carries a `fill` value, which may be a
6
- * password. `open` and `hide` act on every match of their target; the others need exactly one.
6
+ * password. `open`, `hide` and `flatten` act on every match of their target; the others need exactly one.
7
7
  */
8
8
  /** Long enough for a client-side page to render the element, short enough that a typo does not hang the run. */
9
9
  export const STEP_TIMEOUT_MS = 10_000;
@@ -25,6 +25,8 @@ async function runStep(page, step) {
25
25
  return openEvery(getLocator(page, step.target));
26
26
  case "hide":
27
27
  return hideAllButLast(getLocator(page, step.target), step.keepLast);
28
+ case "flatten":
29
+ return flattenEvery(getLocator(page, step.target));
28
30
  }
29
31
  }
30
32
  /** Waits for the first match like the other steps do; a step on every match needs at least one. */
@@ -66,6 +68,18 @@ async function hideAllButLast(locator, keepLast) {
66
68
  if (total <= keepLast)
67
69
  throw new Error(`matches ${total} elements, not more than keepLast ${keepLast}, so nothing would be hidden`);
68
70
  }
71
+ /** Drops the top border and top margin of every match, with `!important` like `hide`. */
72
+ async function flattenEvery(locator) {
73
+ await waitForMatches(locator);
74
+ await locator.evaluateAll((nodes) => {
75
+ for (const node of nodes) {
76
+ if (!(node instanceof HTMLElement || node instanceof SVGElement))
77
+ continue;
78
+ node.style.setProperty("border-top", "none", "important");
79
+ node.style.setProperty("margin-top", "0", "important");
80
+ }
81
+ });
82
+ }
69
83
  /** Null when every step was done; otherwise which one failed (`<where>[<index>] (<do>)`) and why. */
70
84
  export async function runShotSteps(page, steps, where) {
71
85
  for (const [index, step] of steps.entries()) {
@@ -1 +1 @@
1
- {"version":3,"file":"steps.js","sourceRoot":"","sources":["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,8BAA8B,CAAC,CAAC;AACtI,CAAC;AAED,yFAAyF;AACzF,KAAK,UAAU,YAAY,CAAC,OAAgB;IAC1C,MAAM,cAAc,CAAC,OAAO,CAAC,CAAC;IAC9B,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC,KAAK,EAAE,EAAE;QAClC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC,CAAC,IAAI,YAAY,WAAW,IAAI,IAAI,YAAY,UAAU,CAAC;gBAAE,SAAS;YAC3E,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;YAC1D,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,YAAY,EAAE,GAAG,EAAE,WAAW,CAAC,CAAC;QACzD,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,qGAAqG;AACrG,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAU,EAAE,KAA0B,EAAE,KAAa;IACtF,KAAK,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;QAC5C,IAAI,CAAC;YACH,MAAM,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC5B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,yGAAyG;YACzG,OAAO,GAAG,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC,EAAE,MAAM,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;QACpE,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softure-ai/marketing-kit",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "SOFTURE AI marketing kit: a CLI that turns a project's real app into a vertical film (cached voiceover, frame-by-frame recording, HTML composition, hyperframes render) plus per-platform post copy and OG images.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -3998,6 +3998,252 @@
3998
3998
  "target"
3999
3999
  ],
4000
4000
  "additionalProperties": false
4001
+ },
4002
+ {
4003
+ "type": "object",
4004
+ "properties": {
4005
+ "do": {
4006
+ "type": "string",
4007
+ "const": "flatten",
4008
+ "description": "Removes the top border and top margin of every match, e.g. the line above the first row a print state still shows."
4009
+ },
4010
+ "target": {
4011
+ "description": "The elements, as a locator descriptor with exactly one of role, text, label, testId, css; every match is flattened.",
4012
+ "type": "object",
4013
+ "properties": {
4014
+ "role": {
4015
+ "description": "Find by ARIA role (Playwright getByRole), e.g. button; narrow it with name.",
4016
+ "type": "string",
4017
+ "enum": [
4018
+ "alert",
4019
+ "alertdialog",
4020
+ "application",
4021
+ "article",
4022
+ "banner",
4023
+ "blockquote",
4024
+ "button",
4025
+ "caption",
4026
+ "cell",
4027
+ "checkbox",
4028
+ "code",
4029
+ "columnheader",
4030
+ "combobox",
4031
+ "complementary",
4032
+ "contentinfo",
4033
+ "definition",
4034
+ "deletion",
4035
+ "dialog",
4036
+ "directory",
4037
+ "document",
4038
+ "emphasis",
4039
+ "feed",
4040
+ "figure",
4041
+ "form",
4042
+ "generic",
4043
+ "grid",
4044
+ "gridcell",
4045
+ "group",
4046
+ "heading",
4047
+ "img",
4048
+ "insertion",
4049
+ "link",
4050
+ "list",
4051
+ "listbox",
4052
+ "listitem",
4053
+ "log",
4054
+ "main",
4055
+ "marquee",
4056
+ "math",
4057
+ "meter",
4058
+ "menu",
4059
+ "menubar",
4060
+ "menuitem",
4061
+ "menuitemcheckbox",
4062
+ "menuitemradio",
4063
+ "navigation",
4064
+ "none",
4065
+ "note",
4066
+ "option",
4067
+ "paragraph",
4068
+ "presentation",
4069
+ "progressbar",
4070
+ "radio",
4071
+ "radiogroup",
4072
+ "region",
4073
+ "row",
4074
+ "rowgroup",
4075
+ "rowheader",
4076
+ "scrollbar",
4077
+ "search",
4078
+ "searchbox",
4079
+ "separator",
4080
+ "slider",
4081
+ "spinbutton",
4082
+ "status",
4083
+ "strong",
4084
+ "subscript",
4085
+ "superscript",
4086
+ "switch",
4087
+ "tab",
4088
+ "table",
4089
+ "tablist",
4090
+ "tabpanel",
4091
+ "term",
4092
+ "textbox",
4093
+ "time",
4094
+ "timer",
4095
+ "toolbar",
4096
+ "tooltip",
4097
+ "tree",
4098
+ "treegrid",
4099
+ "treeitem"
4100
+ ]
4101
+ },
4102
+ "name": {
4103
+ "description": "The accessible name, with role: a string or { regex, flags }.",
4104
+ "anyOf": [
4105
+ {
4106
+ "type": "string",
4107
+ "minLength": 1
4108
+ },
4109
+ {
4110
+ "type": "object",
4111
+ "properties": {
4112
+ "regex": {
4113
+ "type": "string",
4114
+ "minLength": 1,
4115
+ "description": "A JavaScript regular expression source, without slashes."
4116
+ },
4117
+ "flags": {
4118
+ "default": "",
4119
+ "description": "Any of i, m, s, u, each at most once.",
4120
+ "type": "string",
4121
+ "pattern": "^(?!.*(.).*\\1)[imsu]*$"
4122
+ }
4123
+ },
4124
+ "required": [
4125
+ "regex"
4126
+ ],
4127
+ "additionalProperties": false
4128
+ }
4129
+ ]
4130
+ },
4131
+ "text": {
4132
+ "description": "Find by visible text (Playwright getByText): a substring, or { regex, flags }.",
4133
+ "anyOf": [
4134
+ {
4135
+ "type": "string",
4136
+ "minLength": 1
4137
+ },
4138
+ {
4139
+ "type": "object",
4140
+ "properties": {
4141
+ "regex": {
4142
+ "type": "string",
4143
+ "minLength": 1,
4144
+ "description": "A JavaScript regular expression source, without slashes."
4145
+ },
4146
+ "flags": {
4147
+ "default": "",
4148
+ "description": "Any of i, m, s, u, each at most once.",
4149
+ "type": "string",
4150
+ "pattern": "^(?!.*(.).*\\1)[imsu]*$"
4151
+ }
4152
+ },
4153
+ "required": [
4154
+ "regex"
4155
+ ],
4156
+ "additionalProperties": false
4157
+ }
4158
+ ]
4159
+ },
4160
+ "label": {
4161
+ "description": "Find a form control by its label (Playwright getByLabel): a substring, or { regex, flags }.",
4162
+ "anyOf": [
4163
+ {
4164
+ "type": "string",
4165
+ "minLength": 1
4166
+ },
4167
+ {
4168
+ "type": "object",
4169
+ "properties": {
4170
+ "regex": {
4171
+ "type": "string",
4172
+ "minLength": 1,
4173
+ "description": "A JavaScript regular expression source, without slashes."
4174
+ },
4175
+ "flags": {
4176
+ "default": "",
4177
+ "description": "Any of i, m, s, u, each at most once.",
4178
+ "type": "string",
4179
+ "pattern": "^(?!.*(.).*\\1)[imsu]*$"
4180
+ }
4181
+ },
4182
+ "required": [
4183
+ "regex"
4184
+ ],
4185
+ "additionalProperties": false
4186
+ }
4187
+ ]
4188
+ },
4189
+ "testId": {
4190
+ "description": "Find by data-testid (Playwright getByTestId).",
4191
+ "type": "string",
4192
+ "minLength": 1
4193
+ },
4194
+ "css": {
4195
+ "description": "Find by CSS selector; narrow it with hasText.",
4196
+ "type": "string",
4197
+ "minLength": 1
4198
+ },
4199
+ "hasText": {
4200
+ "description": "Only elements containing this text, with css.",
4201
+ "anyOf": [
4202
+ {
4203
+ "type": "string",
4204
+ "minLength": 1
4205
+ },
4206
+ {
4207
+ "type": "object",
4208
+ "properties": {
4209
+ "regex": {
4210
+ "type": "string",
4211
+ "minLength": 1,
4212
+ "description": "A JavaScript regular expression source, without slashes."
4213
+ },
4214
+ "flags": {
4215
+ "default": "",
4216
+ "description": "Any of i, m, s, u, each at most once.",
4217
+ "type": "string",
4218
+ "pattern": "^(?!.*(.).*\\1)[imsu]*$"
4219
+ }
4220
+ },
4221
+ "required": [
4222
+ "regex"
4223
+ ],
4224
+ "additionalProperties": false
4225
+ }
4226
+ ]
4227
+ },
4228
+ "exact": {
4229
+ "description": "Whole and case-sensitive match of a string name, text or label (default false).",
4230
+ "type": "boolean"
4231
+ },
4232
+ "nth": {
4233
+ "description": "The n-th match (0 = the first); without it, a locator that matches several elements fails.",
4234
+ "type": "integer",
4235
+ "minimum": 0,
4236
+ "maximum": 9007199254740991
4237
+ }
4238
+ },
4239
+ "additionalProperties": false
4240
+ }
4241
+ },
4242
+ "required": [
4243
+ "do",
4244
+ "target"
4245
+ ],
4246
+ "additionalProperties": false
4001
4247
  }
4002
4248
  ]
4003
4249
  }
@@ -4479,6 +4725,11 @@
4479
4725
  "type": "integer",
4480
4726
  "minimum": 0,
4481
4727
  "maximum": 200
4728
+ },
4729
+ "fill": {
4730
+ "default": false,
4731
+ "description": "Stretches a target shorter than the frame down to the frame's bottom edge and centres its content vertically, so no page shows below it (default false). Not with top.",
4732
+ "type": "boolean"
4482
4733
  }
4483
4734
  },
4484
4735
  "required": [
@@ -5792,6 +6043,252 @@
5792
6043
  "target"
5793
6044
  ],
5794
6045
  "additionalProperties": false
6046
+ },
6047
+ {
6048
+ "type": "object",
6049
+ "properties": {
6050
+ "do": {
6051
+ "type": "string",
6052
+ "const": "flatten",
6053
+ "description": "Removes the top border and top margin of every match, e.g. the line above the first row a print state still shows."
6054
+ },
6055
+ "target": {
6056
+ "description": "The elements, as a locator descriptor with exactly one of role, text, label, testId, css; every match is flattened.",
6057
+ "type": "object",
6058
+ "properties": {
6059
+ "role": {
6060
+ "description": "Find by ARIA role (Playwright getByRole), e.g. button; narrow it with name.",
6061
+ "type": "string",
6062
+ "enum": [
6063
+ "alert",
6064
+ "alertdialog",
6065
+ "application",
6066
+ "article",
6067
+ "banner",
6068
+ "blockquote",
6069
+ "button",
6070
+ "caption",
6071
+ "cell",
6072
+ "checkbox",
6073
+ "code",
6074
+ "columnheader",
6075
+ "combobox",
6076
+ "complementary",
6077
+ "contentinfo",
6078
+ "definition",
6079
+ "deletion",
6080
+ "dialog",
6081
+ "directory",
6082
+ "document",
6083
+ "emphasis",
6084
+ "feed",
6085
+ "figure",
6086
+ "form",
6087
+ "generic",
6088
+ "grid",
6089
+ "gridcell",
6090
+ "group",
6091
+ "heading",
6092
+ "img",
6093
+ "insertion",
6094
+ "link",
6095
+ "list",
6096
+ "listbox",
6097
+ "listitem",
6098
+ "log",
6099
+ "main",
6100
+ "marquee",
6101
+ "math",
6102
+ "meter",
6103
+ "menu",
6104
+ "menubar",
6105
+ "menuitem",
6106
+ "menuitemcheckbox",
6107
+ "menuitemradio",
6108
+ "navigation",
6109
+ "none",
6110
+ "note",
6111
+ "option",
6112
+ "paragraph",
6113
+ "presentation",
6114
+ "progressbar",
6115
+ "radio",
6116
+ "radiogroup",
6117
+ "region",
6118
+ "row",
6119
+ "rowgroup",
6120
+ "rowheader",
6121
+ "scrollbar",
6122
+ "search",
6123
+ "searchbox",
6124
+ "separator",
6125
+ "slider",
6126
+ "spinbutton",
6127
+ "status",
6128
+ "strong",
6129
+ "subscript",
6130
+ "superscript",
6131
+ "switch",
6132
+ "tab",
6133
+ "table",
6134
+ "tablist",
6135
+ "tabpanel",
6136
+ "term",
6137
+ "textbox",
6138
+ "time",
6139
+ "timer",
6140
+ "toolbar",
6141
+ "tooltip",
6142
+ "tree",
6143
+ "treegrid",
6144
+ "treeitem"
6145
+ ]
6146
+ },
6147
+ "name": {
6148
+ "description": "The accessible name, with role: a string or { regex, flags }.",
6149
+ "anyOf": [
6150
+ {
6151
+ "type": "string",
6152
+ "minLength": 1
6153
+ },
6154
+ {
6155
+ "type": "object",
6156
+ "properties": {
6157
+ "regex": {
6158
+ "type": "string",
6159
+ "minLength": 1,
6160
+ "description": "A JavaScript regular expression source, without slashes."
6161
+ },
6162
+ "flags": {
6163
+ "default": "",
6164
+ "description": "Any of i, m, s, u, each at most once.",
6165
+ "type": "string",
6166
+ "pattern": "^(?!.*(.).*\\1)[imsu]*$"
6167
+ }
6168
+ },
6169
+ "required": [
6170
+ "regex"
6171
+ ],
6172
+ "additionalProperties": false
6173
+ }
6174
+ ]
6175
+ },
6176
+ "text": {
6177
+ "description": "Find by visible text (Playwright getByText): a substring, or { regex, flags }.",
6178
+ "anyOf": [
6179
+ {
6180
+ "type": "string",
6181
+ "minLength": 1
6182
+ },
6183
+ {
6184
+ "type": "object",
6185
+ "properties": {
6186
+ "regex": {
6187
+ "type": "string",
6188
+ "minLength": 1,
6189
+ "description": "A JavaScript regular expression source, without slashes."
6190
+ },
6191
+ "flags": {
6192
+ "default": "",
6193
+ "description": "Any of i, m, s, u, each at most once.",
6194
+ "type": "string",
6195
+ "pattern": "^(?!.*(.).*\\1)[imsu]*$"
6196
+ }
6197
+ },
6198
+ "required": [
6199
+ "regex"
6200
+ ],
6201
+ "additionalProperties": false
6202
+ }
6203
+ ]
6204
+ },
6205
+ "label": {
6206
+ "description": "Find a form control by its label (Playwright getByLabel): a substring, or { regex, flags }.",
6207
+ "anyOf": [
6208
+ {
6209
+ "type": "string",
6210
+ "minLength": 1
6211
+ },
6212
+ {
6213
+ "type": "object",
6214
+ "properties": {
6215
+ "regex": {
6216
+ "type": "string",
6217
+ "minLength": 1,
6218
+ "description": "A JavaScript regular expression source, without slashes."
6219
+ },
6220
+ "flags": {
6221
+ "default": "",
6222
+ "description": "Any of i, m, s, u, each at most once.",
6223
+ "type": "string",
6224
+ "pattern": "^(?!.*(.).*\\1)[imsu]*$"
6225
+ }
6226
+ },
6227
+ "required": [
6228
+ "regex"
6229
+ ],
6230
+ "additionalProperties": false
6231
+ }
6232
+ ]
6233
+ },
6234
+ "testId": {
6235
+ "description": "Find by data-testid (Playwright getByTestId).",
6236
+ "type": "string",
6237
+ "minLength": 1
6238
+ },
6239
+ "css": {
6240
+ "description": "Find by CSS selector; narrow it with hasText.",
6241
+ "type": "string",
6242
+ "minLength": 1
6243
+ },
6244
+ "hasText": {
6245
+ "description": "Only elements containing this text, with css.",
6246
+ "anyOf": [
6247
+ {
6248
+ "type": "string",
6249
+ "minLength": 1
6250
+ },
6251
+ {
6252
+ "type": "object",
6253
+ "properties": {
6254
+ "regex": {
6255
+ "type": "string",
6256
+ "minLength": 1,
6257
+ "description": "A JavaScript regular expression source, without slashes."
6258
+ },
6259
+ "flags": {
6260
+ "default": "",
6261
+ "description": "Any of i, m, s, u, each at most once.",
6262
+ "type": "string",
6263
+ "pattern": "^(?!.*(.).*\\1)[imsu]*$"
6264
+ }
6265
+ },
6266
+ "required": [
6267
+ "regex"
6268
+ ],
6269
+ "additionalProperties": false
6270
+ }
6271
+ ]
6272
+ },
6273
+ "exact": {
6274
+ "description": "Whole and case-sensitive match of a string name, text or label (default false).",
6275
+ "type": "boolean"
6276
+ },
6277
+ "nth": {
6278
+ "description": "The n-th match (0 = the first); without it, a locator that matches several elements fails.",
6279
+ "type": "integer",
6280
+ "minimum": 0,
6281
+ "maximum": 9007199254740991
6282
+ }
6283
+ },
6284
+ "additionalProperties": false
6285
+ }
6286
+ },
6287
+ "required": [
6288
+ "do",
6289
+ "target"
6290
+ ],
6291
+ "additionalProperties": false
5795
6292
  }
5796
6293
  ]
5797
6294
  },
@@ -512,6 +512,9 @@ export const screenshotSchema = z.strictObject({
512
512
  context.addIssue({ code: "custom", path: ["scrollTo"], message: "is one viewport frame at a scroll position; a full-page shot has none, so drop full or scrollTo" });
513
513
  }
514
514
  if (entry.crop !== undefined && entry.full) context.addIssue({ code: "custom", path: ["crop"], message: "frames one element; a full-page shot has no element to frame, so drop full or crop" });
515
+ if (entry.crop?.fill === true && entry.crop.top !== undefined) {
516
+ context.addIssue({ code: "custom", path: ["crop", "fill"], message: "centres the target's content in the frame; crop.top would start the frame inside it, so drop one of them" });
517
+ }
515
518
  if (entry.crop !== undefined && entry.scrollTo !== undefined) {
516
519
  context.addIssue({ code: "custom", path: ["crop"], message: "places the frame on its element; scrollTo would place it too, so drop one of them" });
517
520
  }
@@ -6,7 +6,7 @@ import { locatorSchema } from "./actions-schema.js";
6
6
  * What a screenshot does on the page before it is judged: the sign-in form (`signIn.steps`) and an entry's own
7
7
  * `steps` (open collapsed sections, hide what a still image should not show). Plain Playwright calls on a locator,
8
8
  * with no camera and no timing: a screenshot records nothing in between. `crop` frames one element at a fixed aspect
9
- * ratio instead of the viewport, optionally from the top edge of another one.
9
+ * ratio instead of the viewport, optionally from the top edge of another one, or stretched to the frame (`fill`).
10
10
  */
11
11
 
12
12
  /** A Playwright key name, modifiers joined with `+`; Playwright itself refuses a name it does not know. */
@@ -51,6 +51,10 @@ export const shotStepSchema = z.discriminatedUnion("do", [
51
51
  .default(0)
52
52
  .describe(`How many of the last matches stay shown (0-${MAX_KEEP_LAST}, default 0); the step fails when there are not more matches than this.`),
53
53
  }),
54
+ z.strictObject({
55
+ do: z.literal("flatten").describe("Removes the top border and top margin of every match, e.g. the line above the first row a print state still shows."),
56
+ target: locatorSchema.describe("The elements, as a locator descriptor with exactly one of role, text, label, testId, css; every match is flattened."),
57
+ }),
54
58
  ]);
55
59
 
56
60
  export type ShotStep = z.output<typeof shotStepSchema>;
@@ -74,6 +78,10 @@ export const cropSchema = z.strictObject({
74
78
  })
75
79
  .describe("The frame's width to height, e.g. 4:3: as wide as the element (plus padding), from its top edge down."),
76
80
  padding: z.number().int().min(0).max(200).default(0).describe("CSS pixels of the page around the element on the left, right and top (0-200, default 0)."),
81
+ fill: z
82
+ .boolean()
83
+ .default(false)
84
+ .describe("Stretches a target shorter than the frame down to the frame's bottom edge and centres its content vertically, so no page shows below it (default false). Not with top."),
77
85
  });
78
86
 
79
87
  export type Crop = z.output<typeof cropSchema>;