@salesforce/vite-plugin-lwc-ui-bundle 10.2.0 → 10.2.2
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.
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
* For full license text, see the LICENSE.txt file
|
|
5
5
|
*/
|
|
6
|
+
export declare function getApiShape(): Promise<boolean>;
|
|
6
7
|
export declare function getLabel(key: string, fallback: string): string;
|
|
7
8
|
export declare function groupByNamespace(keys: string[]): Map<string, string[]>;
|
|
8
9
|
interface GraphqlEndpoint {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/providers/labels-graphql/runtime.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/providers/labels-graphql/runtime.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAyCH,wBAAgB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,CAK9C;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAM9D;AA8CD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAWtE;AAED,UAAU,eAAe;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,MAAM;QACf,2BAA2B,CAAC,EAAE,CAC7B,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC9B,OAAO,CAAC,OAAO,CAAC,CAAC;QACtB,uBAAuB,CAAC,EAAE,eAAe,CAAC;QAC1C,MAAM,CAAC,EAAE;YAAE,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;SAAE,CAAC;KAChF;CACD;AAED,wBAAsB,YAAY,CACjC,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,OAAO,CAAC,OAAO,CAAC,CA2BlB;AAED,qDAAqD;AACrD,wBAAgB,cAAc,IAAI,IAAI,CAKrC"}
|
|
@@ -1,6 +1,41 @@
|
|
|
1
1
|
const labelCache = /* @__PURE__ */ new Map();
|
|
2
2
|
const pendingKeys = /* @__PURE__ */ new Set();
|
|
3
3
|
let fetchScheduled = false;
|
|
4
|
+
let probePromise = null;
|
|
5
|
+
const QUERY_264 = `query Labels($namespace: String, $names: [String!]) {
|
|
6
|
+
uiapi {
|
|
7
|
+
platform {
|
|
8
|
+
labels(namespace: $namespace, names: $names) {
|
|
9
|
+
namespace
|
|
10
|
+
name
|
|
11
|
+
value
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}`;
|
|
16
|
+
const QUERY_262 = `query Labels($namespace: String, $names: [String!]) {
|
|
17
|
+
uiapi {
|
|
18
|
+
labels(namespace: $namespace, names: $names) {
|
|
19
|
+
namespace
|
|
20
|
+
name
|
|
21
|
+
value
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}`;
|
|
25
|
+
async function detectPlatformPath() {
|
|
26
|
+
try {
|
|
27
|
+
const response = await graphqlFetch(`{ uiapi { platform { __typename } } }`, {});
|
|
28
|
+
return !!response?.data?.uiapi?.platform;
|
|
29
|
+
} catch {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function getApiShape() {
|
|
34
|
+
if (!probePromise) {
|
|
35
|
+
probePromise = detectPlatformPath();
|
|
36
|
+
}
|
|
37
|
+
return probePromise;
|
|
38
|
+
}
|
|
4
39
|
function getLabel(key, fallback) {
|
|
5
40
|
if (labelCache.has(key)) return labelCache.get(key);
|
|
6
41
|
labelCache.set(key, fallback);
|
|
@@ -20,22 +55,16 @@ function scheduleFetch() {
|
|
|
20
55
|
});
|
|
21
56
|
}
|
|
22
57
|
async function fetchLabelsFromOrg(keys) {
|
|
58
|
+
const isPlatform = await getApiShape();
|
|
59
|
+
const query = isPlatform ? QUERY_264 : QUERY_262;
|
|
23
60
|
const grouped = groupByNamespace(keys);
|
|
24
61
|
for (const [namespace, names] of grouped) {
|
|
25
62
|
for (let i = 0; i < names.length; i += 100) {
|
|
26
63
|
const batch = names.slice(i, i + 100);
|
|
27
64
|
try {
|
|
28
|
-
const query = `query Labels($namespace: String, $names: [String!]) {
|
|
29
|
-
uiapi {
|
|
30
|
-
labels(namespace: $namespace, names: $names) {
|
|
31
|
-
namespace
|
|
32
|
-
name
|
|
33
|
-
value
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}`;
|
|
37
65
|
const response = await graphqlFetch(query, { namespace, names: batch });
|
|
38
|
-
const
|
|
66
|
+
const responseTyped = response;
|
|
67
|
+
const labels = isPlatform ? responseTyped?.data?.uiapi?.platform?.labels ?? [] : responseTyped?.data?.uiapi?.labels ?? [];
|
|
39
68
|
for (const item of labels) {
|
|
40
69
|
const ns = item.namespace ?? namespace;
|
|
41
70
|
labelCache.set(ns + "." + item.name, item.value);
|
|
@@ -90,9 +119,11 @@ function __resetForTest() {
|
|
|
90
119
|
labelCache.clear();
|
|
91
120
|
pendingKeys.clear();
|
|
92
121
|
fetchScheduled = false;
|
|
122
|
+
probePromise = null;
|
|
93
123
|
}
|
|
94
124
|
export {
|
|
95
125
|
__resetForTest,
|
|
126
|
+
getApiShape,
|
|
96
127
|
getLabel,
|
|
97
128
|
graphqlFetch,
|
|
98
129
|
groupByNamespace
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sources":["../../../src/providers/labels-graphql/runtime.ts"],"sourcesContent":["/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\n\nconst labelCache = new Map<string, string>();\nconst pendingKeys = new Set<string>();\nlet fetchScheduled = false;\n\nexport function getLabel(key: string, fallback: string): string {\n\tif (labelCache.has(key)) return labelCache.get(key)!;\n\tlabelCache.set(key, fallback);\n\tpendingKeys.add(key);\n\tscheduleFetch();\n\treturn fallback;\n}\n\nfunction scheduleFetch(): void {\n\tif (fetchScheduled) return;\n\tfetchScheduled = true;\n\tPromise.resolve().then(() => {\n\t\tfetchScheduled = false;\n\t\tif (pendingKeys.size === 0) return;\n\t\tconst keys = [...pendingKeys];\n\t\tpendingKeys.clear();\n\t\tfetchLabelsFromOrg(keys);\n\t});\n}\n\nasync function fetchLabelsFromOrg(keys: string[]): Promise<void> {\n\tconst grouped = groupByNamespace(keys);\n\tfor (const [namespace, names] of grouped) {\n\t\tfor (let i = 0; i < names.length; i += 100) {\n\t\t\tconst batch = names.slice(i, i + 100);\n\t\t\ttry {\n\t\t\t\tconst
|
|
1
|
+
{"version":3,"file":"runtime.js","sources":["../../../src/providers/labels-graphql/runtime.ts"],"sourcesContent":["/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\n\nconst labelCache = new Map<string, string>();\nconst pendingKeys = new Set<string>();\nlet fetchScheduled = false;\nlet probePromise: Promise<boolean> | null = null;\n\nconst QUERY_264 = `query Labels($namespace: String, $names: [String!]) {\n uiapi {\n platform {\n labels(namespace: $namespace, names: $names) {\n namespace\n name\n value\n }\n }\n }\n}`;\n\nconst QUERY_262 = `query Labels($namespace: String, $names: [String!]) {\n uiapi {\n labels(namespace: $namespace, names: $names) {\n namespace\n name\n value\n }\n }\n}`;\n\nasync function detectPlatformPath(): Promise<boolean> {\n\ttry {\n\t\tconst response = (await graphqlFetch(`{ uiapi { platform { __typename } } }`, {})) as {\n\t\t\tdata?: { uiapi?: { platform?: unknown } };\n\t\t\terrors?: unknown[];\n\t\t};\n\t\treturn !!response?.data?.uiapi?.platform;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport function getApiShape(): Promise<boolean> {\n\tif (!probePromise) {\n\t\tprobePromise = detectPlatformPath();\n\t}\n\treturn probePromise;\n}\n\nexport function getLabel(key: string, fallback: string): string {\n\tif (labelCache.has(key)) return labelCache.get(key)!;\n\tlabelCache.set(key, fallback);\n\tpendingKeys.add(key);\n\tscheduleFetch();\n\treturn fallback;\n}\n\nfunction scheduleFetch(): void {\n\tif (fetchScheduled) return;\n\tfetchScheduled = true;\n\tPromise.resolve().then(() => {\n\t\tfetchScheduled = false;\n\t\tif (pendingKeys.size === 0) return;\n\t\tconst keys = [...pendingKeys];\n\t\tpendingKeys.clear();\n\t\tfetchLabelsFromOrg(keys);\n\t});\n}\n\nasync function fetchLabelsFromOrg(keys: string[]): Promise<void> {\n\tconst isPlatform = await getApiShape();\n\tconst query = isPlatform ? QUERY_264 : QUERY_262;\n\tconst grouped = groupByNamespace(keys);\n\tfor (const [namespace, names] of grouped) {\n\t\tfor (let i = 0; i < names.length; i += 100) {\n\t\t\tconst batch = names.slice(i, i + 100);\n\t\t\ttry {\n\t\t\t\tconst response = await graphqlFetch(query, { namespace, names: batch });\n\t\t\t\tconst responseTyped = response as {\n\t\t\t\t\tdata?: { uiapi?: { platform?: { labels?: LabelRecord[] }; labels?: LabelRecord[] } };\n\t\t\t\t};\n\t\t\t\tconst labels = isPlatform\n\t\t\t\t\t? (responseTyped?.data?.uiapi?.platform?.labels ?? [])\n\t\t\t\t\t: (responseTyped?.data?.uiapi?.labels ?? []);\n\t\t\t\tfor (const item of labels) {\n\t\t\t\t\tconst ns = item.namespace ?? namespace;\n\t\t\t\t\tlabelCache.set(ns + \".\" + item.name, item.value);\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tconsole.warn(\"[labels-graphql] Runtime fetch failed:\", e);\n\t\t\t}\n\t\t}\n\t}\n}\n\ninterface LabelRecord {\n\tnamespace?: string;\n\tname: string;\n\tvalue: string;\n}\n\nexport function groupByNamespace(keys: string[]): Map<string, string[]> {\n\tconst grouped = new Map<string, string[]>();\n\tfor (const key of keys) {\n\t\tconst dot = key.indexOf(\".\");\n\t\tconst namespace = dot === -1 ? \"c\" : key.slice(0, dot);\n\t\tconst name = dot === -1 ? key : key.slice(dot + 1);\n\t\tif (name.includes(\".\")) continue;\n\t\tif (!grouped.has(namespace)) grouped.set(namespace, []);\n\t\tgrouped.get(namespace)!.push(name);\n\t}\n\treturn grouped;\n}\n\ninterface GraphqlEndpoint {\n\turl: string;\n\theaders?: Record<string, string>;\n}\n\ndeclare global {\n\tinterface Window {\n\t\t__SF_LABELS_GRAPHQL_FETCH__?: (\n\t\t\tquery: string,\n\t\t\tvariables: Record<string, unknown>,\n\t\t) => Promise<unknown>;\n\t\t__SF_GRAPHQL_ENDPOINT__?: GraphqlEndpoint;\n\t\topenai?: { callTool?: (toolName: string, params: unknown) => Promise<unknown> };\n\t}\n}\n\nexport async function graphqlFetch(\n\tquery: string,\n\tvariables: Record<string, unknown>,\n): Promise<unknown> {\n\tif (typeof window !== \"undefined\" && window.__SF_LABELS_GRAPHQL_FETCH__) {\n\t\treturn window.__SF_LABELS_GRAPHQL_FETCH__(query, variables);\n\t}\n\tif (typeof window !== \"undefined\" && window.openai) {\n\t\tconst sdk = window.openai;\n\t\tif (typeof sdk.callTool === \"function\") {\n\t\t\treturn sdk.callTool(\"graphqlQuery\", { query, variables });\n\t\t}\n\t}\n\tconst endpoint = typeof window !== \"undefined\" ? window.__SF_GRAPHQL_ENDPOINT__ : undefined;\n\tif (!endpoint) {\n\t\tconsole.warn(\n\t\t\t\"[labels-graphql] No GraphQL endpoint configured. Labels will use fallback values.\",\n\t\t);\n\t\treturn {};\n\t}\n\tconst res = await fetch(endpoint.url, {\n\t\tmethod: \"POST\",\n\t\theaders: {\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t...(endpoint.headers || {}),\n\t\t},\n\t\tbody: JSON.stringify({ query, variables }),\n\t});\n\tif (!res.ok) throw new Error(\"GraphQL fetch failed: \" + res.status);\n\treturn res.json();\n}\n\n/** Reset internal state — exposed for tests only. */\nexport function __resetForTest(): void {\n\tlabelCache.clear();\n\tpendingKeys.clear();\n\tfetchScheduled = false;\n\tprobePromise = null;\n}\n"],"names":[],"mappings":"AAMA,MAAM,iCAAiB,IAAA;AACvB,MAAM,kCAAkB,IAAA;AACxB,IAAI,iBAAiB;AACrB,IAAI,eAAwC;AAE5C,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYlB,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUlB,eAAe,qBAAuC;AACrD,MAAI;AACH,UAAM,WAAY,MAAM,aAAa,yCAAyC,CAAA,CAAE;AAIhF,WAAO,CAAC,CAAC,UAAU,MAAM,OAAO;AAAA,EACjC,QAAQ;AACP,WAAO;AAAA,EACR;AACD;AAEO,SAAS,cAAgC;AAC/C,MAAI,CAAC,cAAc;AAClB,mBAAe,mBAAA;AAAA,EAChB;AACA,SAAO;AACR;AAEO,SAAS,SAAS,KAAa,UAA0B;AAC/D,MAAI,WAAW,IAAI,GAAG,EAAG,QAAO,WAAW,IAAI,GAAG;AAClD,aAAW,IAAI,KAAK,QAAQ;AAC5B,cAAY,IAAI,GAAG;AACnB,gBAAA;AACA,SAAO;AACR;AAEA,SAAS,gBAAsB;AAC9B,MAAI,eAAgB;AACpB,mBAAiB;AACjB,UAAQ,UAAU,KAAK,MAAM;AAC5B,qBAAiB;AACjB,QAAI,YAAY,SAAS,EAAG;AAC5B,UAAM,OAAO,CAAC,GAAG,WAAW;AAC5B,gBAAY,MAAA;AACZ,uBAAmB,IAAI;AAAA,EACxB,CAAC;AACF;AAEA,eAAe,mBAAmB,MAA+B;AAChE,QAAM,aAAa,MAAM,YAAA;AACzB,QAAM,QAAQ,aAAa,Y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Aa,YAAY;AACvC,aAAO,IAAI,SAAS,gBAAgB,EAAE,OAAO,WAAW;AAAA,IACzD;AAAA,EACD;AACA,QAAM,WAAW,OAAO,WAAW,cAAc,OAAO,0BAA0B;AAClF,MAAI,CAAC,UAAU;AACd,YAAQ;AAAA,MACP;AAAA,IAAA;AAED,WAAO,CAAA;AAAA,EACR;AACA,QAAM,MAAM,MAAM,MAAM,SAAS,KAAK;AAAA,IACrC,QAAQ;AAAA,IACR,SAAS;AAAA,MACR,gBAAgB;AAAA,MAChB,GAAI,SAAS,WAAW,CAAA;AAAA,IAAC;AAAA,IAE1B,MAAM,KAAK,UAAU,EAAE,OAAO,WAAW;AAAA,EAAA,CACzC;AACD,MAAI,CAAC,IAAI,GAAI,OAAM,IAAI,MAAM,2BAA2B,IAAI,MAAM;AAClE,SAAO,IAAI,KAAA;AACZ;AAGO,SAAS,iBAAuB;AACtC,aAAW,MAAA;AACX,cAAY,MAAA;AACZ,mBAAiB;AACjB,iBAAe;AAChB;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/vite-plugin-lwc-ui-bundle",
|
|
3
|
-
"version": "10.2.
|
|
3
|
+
"version": "10.2.2",
|
|
4
4
|
"description": "Vite plugin for compiling LWC components into static bundles for off-platform and MCP use",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"author": "Salesforce",
|
|
@@ -59,9 +59,9 @@
|
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@lwc/rollup-plugin": "^9.0.0",
|
|
61
61
|
"@salesforce/lds-adapters-onestore-graphql": "^1.440.0",
|
|
62
|
-
"@salesforce/platform-sdk": "^10.2.
|
|
62
|
+
"@salesforce/platform-sdk": "^10.2.2",
|
|
63
63
|
"@salesforce/state-managers-uiapi": "^0.30.0",
|
|
64
|
-
"@salesforce/ui-bundle": "^10.2.
|
|
64
|
+
"@salesforce/ui-bundle": "^10.2.2",
|
|
65
65
|
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0",
|
|
66
66
|
"zod": "^3.23.8"
|
|
67
67
|
},
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"devDependencies": {
|
|
88
88
|
"@conduit-client/bindings-utils": "3.19.6",
|
|
89
89
|
"@conduit-client/command-base": "3.19.6",
|
|
90
|
-
"@salesforce/platform-sdk": "^10.2.
|
|
90
|
+
"@salesforce/platform-sdk": "^10.2.2",
|
|
91
91
|
"typescript": "^5.9.3",
|
|
92
92
|
"vite": "^7.0.0",
|
|
93
93
|
"vite-plugin-dts": "^4.5.4",
|