@salesforce/ui-design-mode 12.9.0 → 12.10.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 (37) hide show
  1. package/dist/authoring/core/DesignPropertyPanelRoot.d.cts +7 -1
  2. package/dist/authoring/core/DesignPropertyPanelRoot.d.ts +7 -1
  3. package/dist/authoring/core/DesignPropertyPanelRoot.d.ts.map +1 -1
  4. package/dist/authoring/core/editors/ImageEditor.d.cts +3 -5
  5. package/dist/authoring/core/editors/ImageEditor.d.ts +3 -5
  6. package/dist/authoring/core/editors/ImageEditor.d.ts.map +1 -1
  7. package/dist/authoring/core/labels/labels.d.cts +0 -9
  8. package/dist/authoring/core/labels/labels.d.ts +0 -9
  9. package/dist/authoring/core/labels/labels.d.ts.map +1 -1
  10. package/dist/authoring/core/utils/backgroundImageEdit.d.cts +22 -0
  11. package/dist/authoring/core/utils/backgroundImageEdit.d.ts +22 -0
  12. package/dist/authoring/core/utils/backgroundImageEdit.d.ts.map +1 -0
  13. package/dist/authoring/host/index.cjs +36 -18
  14. package/dist/authoring/host/index.d.cts +46 -36
  15. package/dist/authoring/host/index.d.ts +46 -36
  16. package/dist/authoring/host/index.d.ts.map +1 -1
  17. package/dist/authoring/host/index.js +36 -18
  18. package/dist/authoring/react/index.js +4 -4
  19. package/dist/authoring/web-component/index.js +21 -21
  20. package/dist/protocol/messageTypes.d.cts +11 -7
  21. package/dist/protocol/messageTypes.d.ts +11 -7
  22. package/dist/protocol/messageTypes.d.ts.map +1 -1
  23. package/dist/protocol/version.cjs +1 -1
  24. package/dist/protocol/version.js +1 -1
  25. package/dist/runtime/design-mode-interactions.js +44 -18
  26. package/dist/runtime/interactions/communicationManager.d.cts +10 -8
  27. package/dist/runtime/interactions/communicationManager.d.ts +10 -8
  28. package/dist/runtime/interactions/communicationManager.d.ts.map +1 -1
  29. package/dist/runtime/interactions/interactionsController.d.cts +1 -2
  30. package/dist/runtime/interactions/interactionsController.d.ts +1 -2
  31. package/dist/runtime/interactions/interactionsController.d.ts.map +1 -1
  32. package/dist/shared/cssUrlLayers.cjs +4 -0
  33. package/dist/shared/cssUrlLayers.d.cts +40 -0
  34. package/dist/shared/cssUrlLayers.d.ts +40 -0
  35. package/dist/shared/cssUrlLayers.d.ts.map +1 -0
  36. package/dist/shared/cssUrlLayers.js +4 -0
  37. package/package.json +1 -1
@@ -1,21 +1,23 @@
1
- const ASSETS_DIR = "src/assets/images";
2
- const DEV_URL_PREFIX = "/src/assets/images";
1
+ import { CSS_URL_TOKEN_SOURCE } from "../../shared/cssUrlLayers.js";
2
+ const ASSETS_ROOT = "src/assets";
3
+ const IMAGE_SUBDIR = "images";
4
+ const ASSETS_DIR = `${ASSETS_ROOT}/${IMAGE_SUBDIR}`;
5
+ const DEV_URL_PREFIX = `/${ASSETS_DIR}`;
3
6
  const MAX_FILENAME_COLLISIONS = 1e3;
4
- const EXT_BY_MIME = {
5
- "image/png": ".png",
6
- "image/jpeg": ".jpg",
7
- "image/gif": ".gif",
8
- "image/webp": ".webp",
9
- "image/svg+xml": ".svg"
10
- };
11
- const MIME_BY_EXT = {
12
- png: "image/png",
13
- jpg: "image/jpeg",
14
- jpeg: "image/jpeg",
15
- gif: "image/gif",
16
- webp: "image/webp",
17
- svg: "image/svg+xml"
18
- };
7
+ const IMAGE_FORMATS = [
8
+ { mime: "image/png", ext: "png" },
9
+ { mime: "image/jpeg", ext: "jpg", aliases: ["jpeg"] },
10
+ { mime: "image/gif", ext: "gif" },
11
+ { mime: "image/webp", ext: "webp" },
12
+ { mime: "image/avif", ext: "avif" },
13
+ { mime: "image/svg+xml", ext: "svg" }
14
+ ];
15
+ const EXT_BY_MIME = Object.fromEntries(
16
+ IMAGE_FORMATS.map((f) => [f.mime, `.${f.ext}`])
17
+ );
18
+ const MIME_BY_EXT = Object.fromEntries(
19
+ IMAGE_FORMATS.flatMap((f) => [f.ext, ...f.aliases ?? []].map((ext) => [ext, f.mime]))
20
+ );
19
21
  const normalizeSeparators = (p) => p.replace(/\\/g, "/");
20
22
  const dirname = (p) => {
21
23
  const normalized = normalizeSeparators(p).replace(/\/+$/, "");
@@ -34,6 +36,19 @@ const extname = (filename) => {
34
36
  return idx <= 0 ? "" : base.slice(idx);
35
37
  };
36
38
  const joinPath = (...segments) => segments.map((s) => normalizeSeparators(s)).join("/").replace(/\/{2,}/g, "/");
39
+ const TRACEABLE_ASSET_EXTENSIONS = new Set(Object.keys(MIME_BY_EXT));
40
+ const KNOWN_EXT_PATTERN = new RegExp(`\\.(${[...TRACEABLE_ASSET_EXTENSIONS].join("|")})$`, "i");
41
+ const resolveAssetRef = (raw) => {
42
+ if (typeof raw !== "string" || raw.length === 0) return null;
43
+ if (raw.startsWith("//") || /^[a-z][a-z0-9+.-]*:/i.test(raw)) return null;
44
+ const withoutQueryHash = raw.split(/[?#]/)[0] ?? "";
45
+ const normalized = normalizeSeparators(withoutQueryHash).replace(/^\/+/, "");
46
+ if (!normalized.startsWith(`${ASSETS_ROOT}/`)) return null;
47
+ if (normalized.split("/").includes("..")) return null;
48
+ const ext = extname(normalized).slice(1).toLowerCase();
49
+ if (!TRACEABLE_ASSET_EXTENSIONS.has(ext)) return null;
50
+ return { assetPath: normalized };
51
+ };
37
52
  const mimeTypeForFilename = (filename) => {
38
53
  const ext = extname(filename).slice(1).toLowerCase();
39
54
  return MIME_BY_EXT[ext] ?? "image/png";
@@ -41,7 +56,7 @@ const mimeTypeForFilename = (filename) => {
41
56
  const sanitizeFilename = (name, contentType) => {
42
57
  const ext = EXT_BY_MIME[contentType] || ".png";
43
58
  const baseOnly = name.split(/[/\\]/).pop() ?? name;
44
- const withoutExt = baseOnly.replace(/\.(png|jpe?g|gif|webp|svg)$/i, "");
59
+ const withoutExt = baseOnly.replace(KNOWN_EXT_PATTERN, "");
45
60
  const safe = withoutExt.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
46
61
  return (safe || "image") + ext;
47
62
  };
@@ -101,11 +116,14 @@ const saveImageToAssets = async (appRoot, filename, bytes, fs) => {
101
116
  const assetDevUrl = (filename) => `${DEV_URL_PREFIX}/${filename}`;
102
117
  export {
103
118
  ASSETS_DIR,
119
+ ASSETS_ROOT,
120
+ CSS_URL_TOKEN_SOURCE,
104
121
  DEV_URL_PREFIX,
105
122
  assetDevUrl,
106
123
  dataUriForImage,
107
124
  findAppRoot,
108
125
  mimeTypeForFilename,
126
+ resolveAssetRef,
109
127
  sanitizeFilename,
110
128
  saveImageToAssets
111
129
  };