@thinkingos/vsl-sdk 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +45 -2
- package/dist/index.d.ts +45 -2
- package/dist/index.js +51 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -48,7 +48,13 @@ var CSS_PROPERTIES = [
|
|
|
48
48
|
["opacity", "opacity"],
|
|
49
49
|
["pointerEvents", "pointer-events"],
|
|
50
50
|
["overflow", "overflow"],
|
|
51
|
-
["height", "height"]
|
|
51
|
+
["height", "height"],
|
|
52
|
+
["backgroundColor", "background-color"],
|
|
53
|
+
["color", "color"],
|
|
54
|
+
["border", "border"],
|
|
55
|
+
["borderRadius", "border-radius"],
|
|
56
|
+
["boxShadow", "box-shadow"],
|
|
57
|
+
["fontFamily", "font-family"]
|
|
52
58
|
];
|
|
53
59
|
function captureCss(el) {
|
|
54
60
|
const view = viewOf(el);
|
|
@@ -258,14 +264,16 @@ function isAriaHidden(attributes) {
|
|
|
258
264
|
}
|
|
259
265
|
function segmentOne(el) {
|
|
260
266
|
const { attributes } = el;
|
|
267
|
+
const isFileInput = el.tag === "input" && attributes["type"] === "file";
|
|
261
268
|
return {
|
|
262
269
|
tag: el.tag,
|
|
263
270
|
indexPath: el.indexPath,
|
|
264
271
|
rect: el.rect,
|
|
265
272
|
attributes,
|
|
266
|
-
t: resolveLevel1Type(el.tag) ?? resolveAriaRoleType(attributes["role"]) ?? resolveLevel3Type(el.css, attributes),
|
|
273
|
+
t: isFileInput ? "file_input" : resolveLevel1Type(el.tag) ?? resolveAriaRoleType(attributes["role"]) ?? resolveLevel3Type(el.css, attributes),
|
|
267
274
|
txt: attributes["aria-label"] ?? el.text,
|
|
268
275
|
st: resolveSt(attributes),
|
|
276
|
+
css: el.css,
|
|
269
277
|
ch: []
|
|
270
278
|
};
|
|
271
279
|
}
|
|
@@ -318,6 +326,8 @@ function defaultActions(t, st, attributes) {
|
|
|
318
326
|
return ["click", "select"];
|
|
319
327
|
case "textarea":
|
|
320
328
|
return ["click", "type", "clear"];
|
|
329
|
+
case "file_input":
|
|
330
|
+
return ["click", "upload"];
|
|
321
331
|
default:
|
|
322
332
|
return void 0;
|
|
323
333
|
}
|
|
@@ -330,6 +340,39 @@ function baseSemanticScore(el) {
|
|
|
330
340
|
if (el.txt) score += 1;
|
|
331
341
|
return score;
|
|
332
342
|
}
|
|
343
|
+
function extractVisualStyles(css) {
|
|
344
|
+
if (!css) return void 0;
|
|
345
|
+
const style = {};
|
|
346
|
+
let hasContent = false;
|
|
347
|
+
if (css.backgroundColor && css.backgroundColor !== "transparent" && !css.backgroundColor.includes("rgba(0, 0, 0, 0)")) {
|
|
348
|
+
style.bg = css.backgroundColor;
|
|
349
|
+
hasContent = true;
|
|
350
|
+
}
|
|
351
|
+
if (css.color && css.color !== "rgb(0, 0, 0)") {
|
|
352
|
+
style.fg = css.color;
|
|
353
|
+
hasContent = true;
|
|
354
|
+
}
|
|
355
|
+
if (css.border && css.border !== "none" && !css.border.startsWith("0px")) {
|
|
356
|
+
style.border = css.border;
|
|
357
|
+
hasContent = true;
|
|
358
|
+
}
|
|
359
|
+
if (css.borderRadius && css.borderRadius !== "0px") {
|
|
360
|
+
style.radius = css.borderRadius;
|
|
361
|
+
hasContent = true;
|
|
362
|
+
}
|
|
363
|
+
if (css.boxShadow && css.boxShadow !== "none") {
|
|
364
|
+
style.shadow = css.boxShadow;
|
|
365
|
+
hasContent = true;
|
|
366
|
+
}
|
|
367
|
+
if (css.fontFamily || css.fontSize || css.fontWeight) {
|
|
368
|
+
style.font = {};
|
|
369
|
+
if (css.fontFamily) style.font.family = css.fontFamily;
|
|
370
|
+
if (css.fontSize) style.font.size = css.fontSize;
|
|
371
|
+
if (css.fontWeight) style.font.weight = css.fontWeight;
|
|
372
|
+
hasContent = true;
|
|
373
|
+
}
|
|
374
|
+
return hasContent ? style : void 0;
|
|
375
|
+
}
|
|
333
376
|
function toVslObject(el, viewport, includedChildren, textBlocks, counter) {
|
|
334
377
|
const t = el.t ?? "container";
|
|
335
378
|
const object = {
|
|
@@ -356,6 +399,12 @@ function toVslObject(el, viewport, includedChildren, textBlocks, counter) {
|
|
|
356
399
|
if (includedChildren.length > 0) object.ch = includedChildren;
|
|
357
400
|
if (el.vf !== void 0) object.vf = el.vf;
|
|
358
401
|
if (el.vf_meta !== void 0) object.vf_meta = el.vf_meta;
|
|
402
|
+
const sty = extractVisualStyles(el.css);
|
|
403
|
+
if (sty !== void 0) object.sty = sty;
|
|
404
|
+
if (t === "file_input") {
|
|
405
|
+
if (el.attributes["accept"] !== void 0) object.accept = el.attributes["accept"];
|
|
406
|
+
if (el.attributes["multiple"] !== void 0) object.multiple = true;
|
|
407
|
+
}
|
|
359
408
|
return object;
|
|
360
409
|
}
|
|
361
410
|
function convert(el, viewport, textBlocks, counter) {
|