@salesforce/angular-plugin-ui-bundle 11.60.0 → 11.62.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/middleware/html.d.ts.map +1 -1
- package/dist/middleware/html.js +22 -4
- package/dist/utils.d.ts +22 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +62 -0
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../src/middleware/html.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAkBH,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../src/middleware/html.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAkBH,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AA4FjE,wBAAsB,oBAAoB,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,UAAU,CAAC,CA+E/F"}
|
package/dist/middleware/html.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
import { getOrgInfo } from "@salesforce/ui-bundle/app";
|
|
19
19
|
import { injectLivePreviewScript } from "@salesforce/ui-bundle/proxy";
|
|
20
20
|
import { DESIGN_MODE_HYDRATE_PATH, DESIGN_MODE_SCRIPT_PATH } from "./proxy.js";
|
|
21
|
-
import { getCodeBuilderBasePath, getPort } from "../utils.js";
|
|
21
|
+
import { getAppName, getCodeBuilderBasePath, getNamespace, getPort } from "../utils.js";
|
|
22
22
|
/**
|
|
23
23
|
* Builds a pure HTML transform bound to the current env (basePath resolved once
|
|
24
24
|
* from CODE_BUILDER_FRAMEWORK_PROXY_URI or "/"). Only the ng serve middleware
|
|
@@ -30,6 +30,12 @@ async function createIndexHtmlTransformer(options = {}) {
|
|
|
30
30
|
const isCodeBuilder = !!codeBuilderProxyUrl;
|
|
31
31
|
const basePath = isCodeBuilder ? getCodeBuilderBasePath(codeBuilderProxyUrl, port) : "/";
|
|
32
32
|
const apiPath = basePath;
|
|
33
|
+
// App identity for SFDC_ENV (namespace + appName). Resolved from the app root
|
|
34
|
+
// (cwd — where ng serve runs), matching the server injector so local dev sees
|
|
35
|
+
// the same values a deployed bundle would.
|
|
36
|
+
const rootPath = process.cwd();
|
|
37
|
+
const namespace = getNamespace(rootPath);
|
|
38
|
+
const appName = getAppName(rootPath);
|
|
33
39
|
const designMode = process.env.SF_DESIGN_MODE === "true";
|
|
34
40
|
// Org URL for SFDC_ENV (Lightning Out, etc.)
|
|
35
41
|
let orgUrl;
|
|
@@ -55,9 +61,21 @@ async function createIndexHtmlTransformer(options = {}) {
|
|
|
55
61
|
else if (/<head(\s[^>]*)?>/i.test(html)) {
|
|
56
62
|
html = html.replace(/<head(\s[^>]*)?>/i, (match) => `${match}\n <base href="${baseHref}">`);
|
|
57
63
|
}
|
|
58
|
-
// 3. SFDC_ENV global (basePath + apiPath + orgUrl)
|
|
59
|
-
|
|
60
|
-
|
|
64
|
+
// 3. SFDC_ENV global (basePath + apiPath + orgUrl + app identity).
|
|
65
|
+
// JSON.stringify escapes quotes/backslashes in every value (e.g. an
|
|
66
|
+
// appName derived from a dir name), so no single field can break the
|
|
67
|
+
// emitted SFDC_ENV object. It does NOT escape `<`, so we also escape it
|
|
68
|
+
// to `<` to prevent a `</script>` in a value from closing this
|
|
69
|
+
// inline <script> element early.
|
|
70
|
+
const sfdcEnv = { basePath, apiPath };
|
|
71
|
+
if (orgUrl)
|
|
72
|
+
sfdcEnv.orgUrl = orgUrl;
|
|
73
|
+
if (namespace)
|
|
74
|
+
sfdcEnv.namespace = namespace;
|
|
75
|
+
if (appName)
|
|
76
|
+
sfdcEnv.appName = appName;
|
|
77
|
+
const sfdcEnvLiteral = JSON.stringify(sfdcEnv).replace(/</g, "\\u003c");
|
|
78
|
+
const sfdcEnvScript = `<script>(function() { globalThis.SFDC_ENV = ${sfdcEnvLiteral}; })();</script>`;
|
|
61
79
|
if (html.includes("</head>")) {
|
|
62
80
|
html = html.replace("</head>", ` ${sfdcEnvScript}\n</head>`);
|
|
63
81
|
}
|
package/dist/utils.d.ts
CHANGED
|
@@ -5,7 +5,29 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export declare const DEFAULT_API_VERSION = "65.0";
|
|
7
7
|
export declare const DEFAULT_PORT = 5173;
|
|
8
|
+
export declare const DEFAULT_NAMESPACE = "c";
|
|
8
9
|
export declare function getPort(): number;
|
|
9
10
|
/** Extract path from Code Builder proxy URI. Same logic as vite-plugin-ui-bundle. */
|
|
10
11
|
export declare function getCodeBuilderBasePath(proxyUri: string, port: number): string;
|
|
12
|
+
/**
|
|
13
|
+
* Get the app name from a *.uibundle-meta.xml file in the root path.
|
|
14
|
+
* Falls back to the directory name if no matching file is found.
|
|
15
|
+
* Same logic as vite-plugin-ui-bundle.
|
|
16
|
+
*
|
|
17
|
+
* @param rootPath - The root directory to search for the uibundle-meta.xml file
|
|
18
|
+
* @returns The app name
|
|
19
|
+
*/
|
|
20
|
+
export declare function getAppName(rootPath: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Get the registered namespace for the app by traversing up from the given
|
|
23
|
+
* directory to locate an sfdx-project.json and reading its `namespace` field.
|
|
24
|
+
* Same logic as vite-plugin-ui-bundle.
|
|
25
|
+
*
|
|
26
|
+
* Falls back to the default namespace ("c") when no sfdx-project.json is found,
|
|
27
|
+
* when it declares no (or an empty) namespace, or when it cannot be read/parsed.
|
|
28
|
+
*
|
|
29
|
+
* @param startDir - The directory to start searching from (the UI Bundle root)
|
|
30
|
+
* @returns The registered namespace, or "c" when none is found
|
|
31
|
+
*/
|
|
32
|
+
export declare function getNamespace(startDir: string): string;
|
|
11
33
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,eAAO,MAAM,mBAAmB,SAAS,CAAC;AAE1C,eAAO,MAAM,YAAY,OAAO,CAAC;AAEjC,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC,wBAAgB,OAAO,IAAI,MAAM,CAEhC;AAED,qFAAqF;AACrF,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ7E;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAYnD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAwBrD"}
|
package/dist/utils.js
CHANGED
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
* For full license text, see the LICENSE.txt file
|
|
5
5
|
*/
|
|
6
|
+
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
7
|
+
import { basename, dirname, join } from "node:path";
|
|
6
8
|
export const DEFAULT_API_VERSION = "65.0";
|
|
7
9
|
export const DEFAULT_PORT = 5173;
|
|
10
|
+
export const DEFAULT_NAMESPACE = "c";
|
|
8
11
|
export function getPort() {
|
|
9
12
|
return parseInt(process.env.SF_UIBUNDLE_PORT || DEFAULT_PORT.toString(), 10);
|
|
10
13
|
}
|
|
@@ -19,3 +22,62 @@ export function getCodeBuilderBasePath(proxyUri, port) {
|
|
|
19
22
|
return `/absproxy/${port}`;
|
|
20
23
|
}
|
|
21
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Get the app name from a *.uibundle-meta.xml file in the root path.
|
|
27
|
+
* Falls back to the directory name if no matching file is found.
|
|
28
|
+
* Same logic as vite-plugin-ui-bundle.
|
|
29
|
+
*
|
|
30
|
+
* @param rootPath - The root directory to search for the uibundle-meta.xml file
|
|
31
|
+
* @returns The app name
|
|
32
|
+
*/
|
|
33
|
+
export function getAppName(rootPath) {
|
|
34
|
+
try {
|
|
35
|
+
const files = readdirSync(rootPath);
|
|
36
|
+
const metaFile = files.find((f) => f.endsWith(".uibundle-meta.xml"));
|
|
37
|
+
if (metaFile) {
|
|
38
|
+
// Extract name from "myapp.uibundle-meta.xml" -> "myapp"
|
|
39
|
+
return metaFile.replace(".uibundle-meta.xml", "");
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
// Fall through to directory name
|
|
44
|
+
}
|
|
45
|
+
return basename(rootPath);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get the registered namespace for the app by traversing up from the given
|
|
49
|
+
* directory to locate an sfdx-project.json and reading its `namespace` field.
|
|
50
|
+
* Same logic as vite-plugin-ui-bundle.
|
|
51
|
+
*
|
|
52
|
+
* Falls back to the default namespace ("c") when no sfdx-project.json is found,
|
|
53
|
+
* when it declares no (or an empty) namespace, or when it cannot be read/parsed.
|
|
54
|
+
*
|
|
55
|
+
* @param startDir - The directory to start searching from (the UI Bundle root)
|
|
56
|
+
* @returns The registered namespace, or "c" when none is found
|
|
57
|
+
*/
|
|
58
|
+
export function getNamespace(startDir) {
|
|
59
|
+
let dir = startDir;
|
|
60
|
+
// Walk up until dirname stops changing (the filesystem root).
|
|
61
|
+
for (let parent = dirname(dir);; dir = parent, parent = dirname(dir)) {
|
|
62
|
+
const sfdxProjectPath = join(dir, "sfdx-project.json");
|
|
63
|
+
// The nearest sfdx-project.json is authoritative: once found, resolve from
|
|
64
|
+
// it (or fall back to the default) rather than inheriting an ancestor's
|
|
65
|
+
// namespace.
|
|
66
|
+
if (existsSync(sfdxProjectPath)) {
|
|
67
|
+
try {
|
|
68
|
+
const namespace = JSON.parse(readFileSync(sfdxProjectPath, "utf-8")).namespace;
|
|
69
|
+
if (typeof namespace === "string" && namespace.trim()) {
|
|
70
|
+
return namespace.trim();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
// Unreadable or invalid JSON: fall through to the default.
|
|
75
|
+
}
|
|
76
|
+
return DEFAULT_NAMESPACE;
|
|
77
|
+
}
|
|
78
|
+
if (parent === dir) {
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return DEFAULT_NAMESPACE;
|
|
83
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/angular-plugin-ui-bundle",
|
|
3
3
|
"description": "Angular CLI plugin for Salesforce UI Bundles",
|
|
4
|
-
"version": "11.
|
|
4
|
+
"version": "11.62.0",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"test:coverage": "vitest run --coverage"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@salesforce/ui-bundle": "^11.
|
|
33
|
-
"@salesforce/ui-design-mode": "^11.
|
|
32
|
+
"@salesforce/ui-bundle": "^11.62.0",
|
|
33
|
+
"@salesforce/ui-design-mode": "^11.62.0",
|
|
34
34
|
"chokidar": "^4.0.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|