@salesforce/vite-plugin-ui-bundle 11.42.1 → 11.43.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.js +21 -4
- package/dist/utils.d.ts +8 -5
- package/dist/utils.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import fs, { readdirSync } from "node:fs";
|
|
1
|
+
import fs, { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
2
2
|
import { loadManifest, getOrgInfo } from "@salesforce/ui-bundle/app";
|
|
3
3
|
import { createProxyHandler, injectLivePreviewScript } from "@salesforce/ui-bundle/proxy";
|
|
4
4
|
import { getRuntimeScriptContent } from "@salesforce/ui-design-mode/runtime";
|
|
5
5
|
import reactDesignTimeLocatorBabelPlugin from "@salesforce/ui-design-mode/source-locator/react";
|
|
6
|
-
import { basename } from "node:path";
|
|
6
|
+
import { dirname, join, basename } from "node:path";
|
|
7
7
|
const DEFAULT_PORT = 5173;
|
|
8
8
|
const DEFAULT_API_VERSION = "65.0";
|
|
9
9
|
const DEFAULT_NAMESPACE = "c";
|
|
@@ -18,7 +18,24 @@ function getAppName(rootPath) {
|
|
|
18
18
|
}
|
|
19
19
|
return basename(rootPath);
|
|
20
20
|
}
|
|
21
|
-
function getNamespace() {
|
|
21
|
+
function getNamespace(startDir) {
|
|
22
|
+
let dir = startDir;
|
|
23
|
+
for (let parent = dirname(dir); ; dir = parent, parent = dirname(dir)) {
|
|
24
|
+
const sfdxProjectPath = join(dir, "sfdx-project.json");
|
|
25
|
+
if (existsSync(sfdxProjectPath)) {
|
|
26
|
+
try {
|
|
27
|
+
const namespace = JSON.parse(readFileSync(sfdxProjectPath, "utf-8")).namespace;
|
|
28
|
+
if (typeof namespace === "string" && namespace.trim()) {
|
|
29
|
+
return namespace.trim();
|
|
30
|
+
}
|
|
31
|
+
} catch {
|
|
32
|
+
}
|
|
33
|
+
return DEFAULT_NAMESPACE;
|
|
34
|
+
}
|
|
35
|
+
if (parent === dir) {
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
22
39
|
return DEFAULT_NAMESPACE;
|
|
23
40
|
}
|
|
24
41
|
function getCodeBuilderBasePath(proxyUri, port) {
|
|
@@ -93,7 +110,7 @@ function uiBundlePlugin(options = {}) {
|
|
|
93
110
|
try {
|
|
94
111
|
const rootPath = config.root ?? process.cwd();
|
|
95
112
|
if (environment) {
|
|
96
|
-
environment.namespace = getNamespace();
|
|
113
|
+
environment.namespace = getNamespace(rootPath);
|
|
97
114
|
environment.appName = getAppName(rootPath);
|
|
98
115
|
}
|
|
99
116
|
manifest = await loadManifest(`${rootPath}/ui-bundle.json`);
|
package/dist/utils.d.ts
CHANGED
|
@@ -15,13 +15,16 @@ export declare const DEFAULT_NAMESPACE = "c";
|
|
|
15
15
|
*/
|
|
16
16
|
export declare function getAppName(rootPath: string): string;
|
|
17
17
|
/**
|
|
18
|
-
* Get the namespace for the app
|
|
19
|
-
*
|
|
20
|
-
* UI Bundle directory (where vite.config lives), not the sfdx project root.
|
|
18
|
+
* Get the registered namespace for the app by traversing up from the given
|
|
19
|
+
* directory to locate an sfdx-project.json and reading its `namespace` field.
|
|
21
20
|
*
|
|
22
|
-
*
|
|
21
|
+
* Falls back to the default namespace ("c") when no sfdx-project.json is found,
|
|
22
|
+
* when it declares no (or an empty) namespace, or when it cannot be read/parsed.
|
|
23
|
+
*
|
|
24
|
+
* @param startDir - The directory to start searching from (the UI Bundle root)
|
|
25
|
+
* @returns The registered namespace, or "c" when none is found
|
|
23
26
|
*/
|
|
24
|
-
export declare function getNamespace(): string;
|
|
27
|
+
export declare function getNamespace(startDir: string): string;
|
|
25
28
|
/**
|
|
26
29
|
* Calculate the code builder base path from the proxy URI (CODE_BUILDER_FRAMEWORK_PROXY_URI) and dev server port
|
|
27
30
|
* @param proxyUri - The full proxy URI (e.g., https://name.iad.001.sf.code-builder.platform.salesforce.com/absproxy/{{port}})
|
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;AAKH,eAAO,MAAM,YAAY,OAAO,CAAC;AACjC,eAAO,MAAM,mBAAmB,SAAS,CAAC;AAC1C,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAYnD;AAED
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,eAAO,MAAM,YAAY,OAAO,CAAC;AACjC,eAAO,MAAM,mBAAmB,SAAS,CAAC;AAC1C,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAYnD;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAwBrD;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ7E;AAED,wBAAgB,kBAAkB,CAAC,mBAAmB,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,UAMvF;AAED,wBAAgB,OAAO,WAEtB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/vite-plugin-ui-bundle",
|
|
3
3
|
"description": "Vite plugin for Salesforce UI Bundles",
|
|
4
|
-
"version": "11.
|
|
4
|
+
"version": "11.43.0",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@babel/core": "^7.29.6",
|
|
30
|
-
"@salesforce/ui-bundle": "^11.
|
|
31
|
-
"@salesforce/ui-design-mode": "11.
|
|
30
|
+
"@salesforce/ui-bundle": "^11.43.0",
|
|
31
|
+
"@salesforce/ui-design-mode": "11.43.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/babel__core": "^7.20.5",
|