@awsless/cli 0.1.15 → 0.1.16

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.
@@ -14050,7 +14050,7 @@ var require_svgstore = __commonJS((exports, module) => {
14050
14050
  import { getObject, putObject } from "@awsless/s3";
14051
14051
  import { getRouteEnv, internalInvoke } from "awsless";
14052
14052
 
14053
- // ../../node_modules/.pnpm/svgo@4.0.1/node_modules/svgo/dist/svgo.browser.js
14053
+ // ../../node_modules/.pnpm/svgo@4.0.2/node_modules/svgo/dist/svgo.browser.js
14054
14054
  var visitSkip = Symbol();
14055
14055
  var visit = (node, visitor, parentNode) => {
14056
14056
  const callbacks = visitor[node.type];
@@ -28717,13 +28717,14 @@ var hasScripts = (node2) => {
28717
28717
  if (node2.name === "script" && node2.children.length !== 0)
28718
28718
  return true;
28719
28719
  if (node2.name === "a") {
28720
- const hasJsLinks = Object.entries(node2.attributes).some(([attrKey, attrValue]) => (attrKey === "href" || attrKey.endsWith(":href")) && attrValue != null && attrValue.trimStart().startsWith("javascript:"));
28720
+ const hasJsLinks = Object.entries(node2.attributes).some(([attrKey, attrValue]) => (attrKey === "href" || attrKey.endsWith(":href")) && attrValue != null && attrValue.trimStart().toLowerCase().startsWith("javascript:"));
28721
28721
  if (hasJsLinks)
28722
28722
  return true;
28723
28723
  }
28724
28724
  return hasScriptsEventAttrs.some((attr) => node2.attributes[attr] != null);
28725
28725
  };
28726
28726
  var includesUrlReference = (body) => new RegExp(regReferencesUrl).test(body);
28727
+ var includesCssVarReference = (body) => /var\s*\(\s*--/.test(body);
28727
28728
  var findReferences = (attribute, value2) => {
28728
28729
  const results = [];
28729
28730
  if (referencesProps.has(attribute)) {
@@ -28991,7 +28992,7 @@ var fn$D = (_root, params) => {
28991
28992
  val = convertRgbToHex(numbers);
28992
28993
  }
28993
28994
  }
28994
- convertCase && !includesUrlReference(val) && val !== "currentColor" && (convertCase === "lower" ? val = val.toLowerCase() : convertCase === "upper" && (val = val.toUpperCase()));
28995
+ !convertCase || includesUrlReference(val) || includesCssVarReference(val) || val === "currentColor" || (convertCase === "lower" ? val = val.toLowerCase() : convertCase === "upper" && (val = val.toUpperCase()));
28995
28996
  if (shorthex) {
28996
28997
  const match = regHEX.exec(val);
28997
28998
  match != null && (val = "#" + match[0][1] + match[0][3] + match[0][5]);
@@ -29294,8 +29295,7 @@ var parsePathData = (string) => {
29294
29295
  let number2 = null;
29295
29296
  if (command === "A" || command === "a") {
29296
29297
  const position = args.length;
29297
- position !== 0 && position !== 1 || c !== "+" && c !== "-" && ([newCursor, number2] = readNumber(string, i));
29298
- position !== 2 && position !== 5 && position !== 6 || ([newCursor, number2] = readNumber(string, i));
29298
+ position !== 0 && position !== 1 && position !== 2 && position !== 5 && position !== 6 || ([newCursor, number2] = readNumber(string, i));
29299
29299
  if (position === 3 || position === 4) {
29300
29300
  c === "0" && (number2 = 0);
29301
29301
  c === "1" && (number2 = 1);
@@ -29309,6 +29309,10 @@ var parsePathData = (string) => {
29309
29309
  hadComma = false;
29310
29310
  i = newCursor;
29311
29311
  if (args.length === argsCount) {
29312
+ if (command === "A" || command === "a") {
29313
+ args[0] = Math.abs(args[0]);
29314
+ args[1] = Math.abs(args[1]);
29315
+ }
29312
29316
  pathData.push({ command, args });
29313
29317
  command === "M" && (command = "L");
29314
29318
  command === "m" && (command = "l");
@@ -30634,13 +30638,17 @@ var fn$r = (root, params) => {
30634
30638
  const hasMarkerMid = computedStyle["marker-mid"] != null;
30635
30639
  const maybeHasStroke = computedStyle.stroke && (computedStyle.stroke.type === "dynamic" || computedStyle.stroke.value !== "none");
30636
30640
  const maybeHasLinecap = computedStyle["stroke-linecap"] && (computedStyle["stroke-linecap"].type === "dynamic" || computedStyle["stroke-linecap"].value !== "butt");
30637
- const maybeHasStrokeAndLinecap = maybeHasStroke && maybeHasLinecap;
30638
30641
  const isSafeToUseZ = !maybeHasStroke || computedStyle["stroke-linecap"]?.type === "static" && computedStyle["stroke-linecap"].value === "round" && computedStyle["stroke-linejoin"]?.type === "static" && computedStyle["stroke-linejoin"].value === "round";
30642
+ const isSafeToRemove = (isFirstDraw, safeIfNotFirstDraw) => {
30643
+ if (!maybeHasStroke)
30644
+ return true;
30645
+ return isFirstDraw ? !maybeHasLinecap : safeIfNotFirstDraw;
30646
+ };
30639
30647
  let data = path2js(node2);
30640
30648
  if (data.length) {
30641
30649
  const includesVertices = data.some((item) => item.command !== "m" && item.command !== "M");
30642
30650
  convertToRelative(data);
30643
- data = filters(data, newParams, { isSafeToUseZ, maybeHasStrokeAndLinecap, hasMarkerMid });
30651
+ data = filters(data, newParams, { isSafeToUseZ, isSafeToRemove, hasMarkerMid });
30644
30652
  utilizeAbsolute && (data = convertToMixed(data, newParams));
30645
30653
  const hasMarker = node2.attributes["marker-start"] != null || node2.attributes["marker-end"] != null;
30646
30654
  const isMarkersOnlyPath = hasMarker && includesVertices && data.every((item) => item.command === "m" || item.command === "M");
@@ -30756,7 +30764,7 @@ var convertToRelative = (pathData) => {
30756
30764
  }
30757
30765
  return pathData;
30758
30766
  };
30759
- function filters(path, params, { isSafeToUseZ, maybeHasStrokeAndLinecap, hasMarkerMid }) {
30767
+ function filters(path, params, { isSafeToUseZ, isSafeToRemove, hasMarkerMid }) {
30760
30768
  const stringify = data2Path.bind(null, params);
30761
30769
  const relSubpoint = [0, 0];
30762
30770
  const pathBase = [0, 0];
@@ -30892,11 +30900,12 @@ function filters(path, params, { isSafeToUseZ, maybeHasStrokeAndLinecap, hasMark
30892
30900
  next && next.command == "s" && makeLonghand(next, data);
30893
30901
  command = "l";
30894
30902
  data = data.slice(-2);
30895
- } else if (command === "q" && isCurveStraightLine(data)) {
30896
- next && next.command == "t" && makeLonghand(next, data);
30897
- command = "l";
30898
- data = data.slice(-2);
30899
- } else if (command === "t" && prev.command !== "q" && prev.command !== "t") {
30903
+ } else if (command === "q" && isCurveStraightLine(data) || command === "t" && prev.command !== "q" && prev.command !== "t") {
30904
+ command == "q" && next && next.command == "t" && makeLonghand(next, data);
30905
+ if (command == "t" && next && next.command == "t") {
30906
+ next.command = "q";
30907
+ next.args.unshift(2 * item.coords[0] - item.base[0] - item.coords[0], 2 * item.coords[1] - item.base[1] - item.coords[1]);
30908
+ }
30900
30909
  command = "l";
30901
30910
  data = data.slice(-2);
30902
30911
  } else if (command === "a" && (data[0] === 0 || data[1] === 0 || sagitta !== undefined && sagitta < error)) {
@@ -30966,7 +30975,7 @@ function filters(path, params, { isSafeToUseZ, maybeHasStrokeAndLinecap, hasMark
30966
30975
  }
30967
30976
  }
30968
30977
  }
30969
- if (params.removeUseless && !maybeHasStrokeAndLinecap) {
30978
+ if (params.removeUseless && isSafeToRemove(prev.command == "m" || prev.command == "M", true)) {
30970
30979
  if ((command === "l" || command === "h" || command === "v" || command === "q" || command === "t" || command === "c" || command === "s") && data.every(function(i) {
30971
30980
  return i === 0;
30972
30981
  })) {
@@ -30990,7 +30999,7 @@ function filters(path, params, { isSafeToUseZ, maybeHasStrokeAndLinecap, hasMark
30990
30999
  if (prev.command === "Z" || prev.command === "z")
30991
31000
  return false;
30992
31001
  }
30993
- if ((command === "Z" || command === "z") && params.removeUseless && isSafeToUseZ && Math.abs(item.base[0] - item.coords[0]) < error / 10 && Math.abs(item.base[1] - item.coords[1]) < error / 10)
31002
+ if ((command === "Z" || command === "z") && params.removeUseless && isSafeToRemove(prev.command == "m" || prev.command == "M", isSafeToUseZ) && Math.abs(item.base[0] - item.coords[0]) < error / 10 && Math.abs(item.base[1] - item.coords[1]) < error / 10)
30994
31003
  return false;
30995
31004
  prevQControlPoint = command === "q" ? [data[0] + item.base[0], data[1] + item.base[1]] : command === "t" ? qControlPoint ? reflectPoint(qControlPoint, item.base) : item.coords : undefined;
30996
31005
  prev = item;
@@ -31275,7 +31284,7 @@ var fn$n = (root, params) => {
31275
31284
  return { element: { enter: (node2) => {
31276
31285
  if (node2.children.length <= 1)
31277
31286
  return;
31278
- const elementsToRemove = [];
31287
+ const elementsToRemove = new Set;
31279
31288
  let prevChild = node2.children[0];
31280
31289
  let prevPathData = null;
31281
31290
  const updatePreviousPath = (child, pathData) => {
@@ -31317,7 +31326,7 @@ var fn$n = (root, params) => {
31317
31326
  prevPathData = prevPathData ?? path2js(prevChild);
31318
31327
  if (force || !intersects(prevPathData, currentPathData)) {
31319
31328
  prevPathData.push(...currentPathData);
31320
- elementsToRemove.push(child);
31329
+ elementsToRemove.add(child);
31321
31330
  continue;
31322
31331
  }
31323
31332
  hasPrevPath && updatePreviousPath(prevChild, prevPathData);
@@ -31325,7 +31334,7 @@ var fn$n = (root, params) => {
31325
31334
  prevPathData = null;
31326
31335
  }
31327
31336
  prevPathData && prevChild.type === "element" && updatePreviousPath(prevChild, prevPathData);
31328
- node2.children = node2.children.filter((child) => !elementsToRemove.includes(child));
31337
+ node2.children = node2.children.filter((child) => !elementsToRemove.has(child));
31329
31338
  } } };
31330
31339
  };
31331
31340
  var mergePaths = Object.freeze({ __proto__: null, description: description$n, fn: fn$n, name: name$n });
@@ -31798,7 +31807,14 @@ var fn$d = (_root, params, info) => {
31798
31807
  var prefixIds = Object.freeze({ __proto__: null, description: description$d, fn: fn$d, name: name$d });
31799
31808
  var name$c = "removeAttributesBySelector";
31800
31809
  var description$c = "removes attributes of elements that match a css selector";
31810
+ var ENOATTRS$1 = `Warning: The plugin "removeAttributesBySelector" is missing parameters.
31811
+ It should have a list of "selectors", or one "selector" and one "attributes".
31812
+ Without either, the plugin is a noop.`;
31801
31813
  var fn$c = (root, params) => {
31814
+ if (!Array.isArray(params.selectors) && (!params.selector || !params.attributes)) {
31815
+ console.warn(ENOATTRS$1);
31816
+ return null;
31817
+ }
31802
31818
  const selectors = Array.isArray(params.selectors) ? params.selectors : [params];
31803
31819
  for (const { selector: selector2, attributes: attributes2 } of selectors) {
31804
31820
  const nodes = querySelectorAll(root, selector2);
@@ -31937,25 +31953,54 @@ var removeRasterImages = Object.freeze({ __proto__: null, description: descripti
31937
31953
  var name$6 = "removeScripts";
31938
31954
  var description$6 = "removes scripts";
31939
31955
  var eventAttrs = [...attrsGroups.animationEvent, ...attrsGroups.documentEvent, ...attrsGroups.documentElementEvent, ...attrsGroups.globalEvent, ...attrsGroups.graphicalEvent];
31940
- var fn$6 = () => ({ element: { enter: (node2, parentNode) => {
31941
- if (node2.name === "script") {
31942
- detachNodeFromParent(node2, parentNode);
31943
- return;
31956
+ var SCRIPT_NAMESPACES = ["http://www.w3.org/2000/svg", "http://www.w3.org/1999/xhtml"];
31957
+ function isNamespaceAwareElem(elem, targetElem, prefixes, targetNamespaces) {
31958
+ if (elem === targetElem)
31959
+ return true;
31960
+ if (elem.includes(":")) {
31961
+ const [prefix, effectiveTag] = elem.split(":", 2);
31962
+ if (targetElem === effectiveTag) {
31963
+ const namespaces = prefixes.get(prefix);
31964
+ const namespace = namespaces[namespaces.length - 1];
31965
+ return targetNamespaces.includes(namespace);
31966
+ }
31944
31967
  }
31945
- for (const attr of eventAttrs)
31946
- node2.attributes[attr] != null && delete node2.attributes[attr];
31947
- }, exit: (node2, parentNode) => {
31948
- if (node2.name !== "a")
31949
- return;
31950
- for (const attr of Object.keys(node2.attributes))
31951
- if (attr === "href" || attr.endsWith(":href")) {
31952
- if (node2.attributes[attr] == null || !node2.attributes[attr].trimStart().startsWith("javascript:"))
31968
+ return false;
31969
+ }
31970
+ var fn$6 = () => {
31971
+ const prefixes = new Map;
31972
+ return { element: { enter: (node2, parentNode) => {
31973
+ for (const [k, v] of Object.entries(node2.attributes)) {
31974
+ if (!k.startsWith("xmlns:"))
31953
31975
  continue;
31954
- const index = parentNode.children.indexOf(node2);
31955
- const usefulChildren = node2.children.filter((child) => child.type !== "text");
31956
- parentNode.children.splice(index, 1, ...usefulChildren);
31976
+ const prefix = k.slice(6);
31977
+ prefixes.has(prefix) ? prefixes.get(prefix).push(v) : prefixes.set(prefix, [v]);
31957
31978
  }
31958
- } } });
31979
+ if (isNamespaceAwareElem(node2.name, "script", prefixes, SCRIPT_NAMESPACES)) {
31980
+ detachNodeFromParent(node2, parentNode);
31981
+ return;
31982
+ }
31983
+ for (const attr of eventAttrs)
31984
+ node2.attributes[attr] != null && delete node2.attributes[attr];
31985
+ }, exit: (node2, parentNode) => {
31986
+ for (const k of Object.keys(node2.attributes)) {
31987
+ if (!k.startsWith("xmlns:"))
31988
+ continue;
31989
+ const prefix = k.slice(6);
31990
+ prefixes.get(prefix).pop();
31991
+ }
31992
+ if (node2.name !== "a")
31993
+ return;
31994
+ for (const attr of Object.keys(node2.attributes))
31995
+ if (attr === "href" || attr.endsWith(":href")) {
31996
+ if (node2.attributes[attr] == null || !node2.attributes[attr].trimStart().toLowerCase().startsWith("javascript:"))
31997
+ continue;
31998
+ const index = parentNode.children.indexOf(node2);
31999
+ const usefulChildren = node2.children.filter((child) => child.type !== "text");
32000
+ parentNode.children.splice(index, 1, ...usefulChildren);
32001
+ }
32002
+ } } };
32003
+ };
31959
32004
  var removeScripts = Object.freeze({ __proto__: null, description: description$6, fn: fn$6, name: name$6 });
31960
32005
  var name$5 = "removeStyleElement";
31961
32006
  var description$5 = "removes <style> element";