@salesforce/ui-design-mode 12.8.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.
- package/dist/authoring/core/DesignPropertyPanelRoot.d.cts +7 -1
- package/dist/authoring/core/DesignPropertyPanelRoot.d.ts +7 -1
- package/dist/authoring/core/DesignPropertyPanelRoot.d.ts.map +1 -1
- package/dist/authoring/core/editors/ImageEditor.d.cts +3 -5
- package/dist/authoring/core/editors/ImageEditor.d.ts +3 -5
- package/dist/authoring/core/editors/ImageEditor.d.ts.map +1 -1
- package/dist/authoring/core/labels/labels.d.cts +0 -9
- package/dist/authoring/core/labels/labels.d.ts +0 -9
- package/dist/authoring/core/labels/labels.d.ts.map +1 -1
- package/dist/authoring/core/utils/backgroundImageEdit.d.cts +22 -0
- package/dist/authoring/core/utils/backgroundImageEdit.d.ts +22 -0
- package/dist/authoring/core/utils/backgroundImageEdit.d.ts.map +1 -0
- package/dist/authoring/host/index.cjs +36 -18
- package/dist/authoring/host/index.d.cts +46 -36
- package/dist/authoring/host/index.d.ts +46 -36
- package/dist/authoring/host/index.d.ts.map +1 -1
- package/dist/authoring/host/index.js +36 -18
- package/dist/authoring/react/index.js +4 -4
- package/dist/authoring/web-component/index.js +21 -21
- package/dist/protocol/messageTypes.d.cts +11 -7
- package/dist/protocol/messageTypes.d.ts +11 -7
- package/dist/protocol/messageTypes.d.ts.map +1 -1
- package/dist/protocol/version.cjs +1 -1
- package/dist/protocol/version.js +1 -1
- package/dist/runtime/design-mode-interactions.js +44 -18
- package/dist/runtime/interactions/communicationManager.d.cts +10 -8
- package/dist/runtime/interactions/communicationManager.d.ts +10 -8
- package/dist/runtime/interactions/communicationManager.d.ts.map +1 -1
- package/dist/runtime/interactions/interactionsController.d.cts +1 -2
- package/dist/runtime/interactions/interactionsController.d.ts +1 -2
- package/dist/runtime/interactions/interactionsController.d.ts.map +1 -1
- package/dist/shared/cssUrlLayers.cjs +4 -0
- package/dist/shared/cssUrlLayers.d.cts +40 -0
- package/dist/shared/cssUrlLayers.d.ts +40 -0
- package/dist/shared/cssUrlLayers.d.ts.map +1 -0
- package/dist/shared/cssUrlLayers.js +4 -0
- package/package.json +1 -1
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
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
|
|
5
|
-
"image/png": "
|
|
6
|
-
"image/jpeg": "
|
|
7
|
-
"image/gif": "
|
|
8
|
-
"image/webp": "
|
|
9
|
-
"image/
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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(
|
|
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
|
};
|