@salesforce/vite-plugin-lwc-ui-bundle 8.0.1 → 9.1.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/providers/index.d.ts +2 -0
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +3 -0
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/labels-graphql/constants.d.ts +10 -0
- package/dist/providers/labels-graphql/constants.d.ts.map +1 -0
- package/dist/providers/labels-graphql/index.d.ts +19 -0
- package/dist/providers/labels-graphql/index.d.ts.map +1 -0
- package/dist/providers/labels-graphql/index.js +62 -0
- package/dist/providers/labels-graphql/index.js.map +1 -0
- package/dist/providers/labels-graphql/runtime.d.ts +25 -0
- package/dist/providers/labels-graphql/runtime.d.ts.map +1 -0
- package/dist/providers/labels-graphql/runtime.js +100 -0
- package/dist/providers/labels-graphql/runtime.js.map +1 -0
- package/dist/providers/labels-graphql/types.d.ts +22 -0
- package/dist/providers/labels-graphql/types.d.ts.map +1 -0
- package/package.json +9 -5
|
@@ -10,5 +10,7 @@ export { accessCheck } from './access-check';
|
|
|
10
10
|
export { client } from './client';
|
|
11
11
|
export { primitiveUtils } from './primitive-utils';
|
|
12
12
|
export { lds } from './lds/index';
|
|
13
|
+
export { labelsGraphql } from './labels-graphql/index';
|
|
14
|
+
export type { LabelsGraphqlOptions } from './labels-graphql/index';
|
|
13
15
|
export type { LdsAdapterConfig, LdsAdapterRegistry, LdsGraphqlImperativeReadAdapterConfig, LdsGraphqlImperativeReadInvokerShape, LdsGraphqlMutationAdapterConfig, LdsGraphqlWireAdapterConfig, LdsImperativeMutationAdapterConfig, LdsImperativeReadAdapterConfig, LdsImperativeReadInvokerShape, LdsWireAdapterConfig, } from './lds/index';
|
|
14
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":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A6B,EAC7B,oBAAoB,GACpB,MAAM,aAAa,CAAC"}
|
package/dist/providers/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { lds } from "./lds/index.js";
|
|
2
|
+
import { labelsGraphql } from "./labels-graphql/index.js";
|
|
2
3
|
const LABEL_DEFAULTS = {
|
|
3
4
|
"LightningForm.edit": "Edit",
|
|
4
5
|
"LightningForm.save": "Save",
|
|
@@ -284,6 +285,7 @@ const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
|
|
|
284
285
|
gate,
|
|
285
286
|
i18n,
|
|
286
287
|
label,
|
|
288
|
+
labelsGraphql,
|
|
287
289
|
lds,
|
|
288
290
|
primitiveUtils
|
|
289
291
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
@@ -294,6 +296,7 @@ export {
|
|
|
294
296
|
index as i,
|
|
295
297
|
i18n,
|
|
296
298
|
label,
|
|
299
|
+
labelsGraphql,
|
|
297
300
|
lds,
|
|
298
301
|
primitiveUtils
|
|
299
302
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/providers/label.ts","../../src/providers/i18n.ts","../../src/providers/gate.ts","../../src/providers/access-check.ts","../../src/providers/client.ts","../../src/providers/primitive-utils.ts"],"sourcesContent":["/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport type { Provider } from \"../types\";\n\nconst LABEL_DEFAULTS: Record<string, string> = {\n\t\"LightningForm.edit\": \"Edit\",\n\t\"LightningForm.save\": \"Save\",\n\t\"LightningForm.cancel\": \"Cancel\",\n\t\"LightningForm.error\": \"Error\",\n\t\"RecordDetailUC.Expand\": \"Expand\",\n\t\"RecordDetailUC.Collapse\": \"Collapse\",\n\t\"Global_Entity.created_by\": \"Created By\",\n\t\"Global_Entity.last_modified_by\": \"Last Modified By\",\n\t\"DetailError.GenericSaveError\": \"An error occurred while saving.\",\n\t\"MobileWebError.NoPreEditAccess\": \"You don't have access to edit this record.\",\n\t\"DuplicateList.ToastMessageBlock\": \"Duplicate records were found.\",\n\t\"DuplicateList.NonBlockingHeaderText\": \"Duplicate records found\",\n\t\"DuplicateList.ToastMessageAlertEdit\": \"Duplicate records were found. You can continue editing.\",\n\t\"Errors.ErrorPopoverHeading\": \"Error\",\n};\n\nexport function label(overrides: Record<string, string> = {}): Provider {\n\tconst defaults = { ...LABEL_DEFAULTS, ...overrides };\n\treturn {\n\t\tprefix: \"@salesforce/label/\",\n\t\tresolve(specifier) {\n\t\t\tif (!specifier.startsWith(\"@salesforce/label/\")) return null;\n\n\t\t\tconst key = specifier.slice(\"@salesforce/label/\".length);\n\t\t\tconst fallbackLabel = key\n\t\t\t\t.split(\".\")\n\t\t\t\t.at(-1)!\n\t\t\t\t.replace(/([a-z0-9])([A-Z])/g, \"$1 $2\")\n\t\t\t\t.replace(/_/g, \" \")\n\t\t\t\t.trim();\n\t\t\tconst value = defaults[key] ?? fallbackLabel;\n\t\t\treturn `export default ${JSON.stringify(value)};`;\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport type { Provider } from \"../types\";\n\nconst BROWSER_DERIVED = new Set([\n\t\"lang\",\n\t\"dir\",\n\t\"locale\",\n\t\"currency\",\n\t\"timeZone\",\n\t\"firstDayOfWeek\",\n]);\n\nconst STATIC_DEFAULTS: Record<string, string> = {\n\t\"dateTime.shortDateFormat\": \"M/d/yyyy\",\n\t\"dateTime.mediumDateFormat\": \"MMM d, yyyy\",\n\t\"dateTime.longDateFormat\": \"MMMM d, yyyy\",\n\t\"dateTime.shortTimeFormat\": \"h:mm a\",\n\t\"dateTime.mediumTimeFormat\": \"h:mm:ss a\",\n\t\"dateTime.longTimeFormat\": \"h:mm:ss a z\",\n\t\"dateTime.shortDateTimeFormat\": \"M/d/yyyy, h:mm a\",\n\t\"number.numberFormat\": \"#,##0.##\",\n\t\"number.currencyFormat\": \"¤#,##0.00\",\n\t\"number.decimalSeparator\": \".\",\n\t\"number.groupingSeparator\": \",\",\n\t\"number.percentFormat\": \"#,##0%\",\n\t\"number.percentSign\": \"%\",\n\t\"number.plusSign\": \"+\",\n\t\"number.minusSign\": \"-\",\n\t\"number.exponentialSign\": \"E\",\n\t\"number.superscriptingExponentSign\": \"×\",\n\t\"number.perMilleSign\": \"‰\",\n\t\"number.infinity\": \"∞\",\n\t\"number.nan\": \"NaN\",\n\t\"number.currencySymbol\": \"$\",\n\tdefaultCalendar: \"gregory\",\n\tdefaultNumberingSystem: \"latn\",\n};\n\nconst MONTHS_WIDE = [\n\t\"January\",\n\t\"February\",\n\t\"March\",\n\t\"April\",\n\t\"May\",\n\t\"June\",\n\t\"July\",\n\t\"August\",\n\t\"September\",\n\t\"October\",\n\t\"November\",\n\t\"December\",\n];\nconst MONTHS_ABBR = [\n\t\"Jan\",\n\t\"Feb\",\n\t\"Mar\",\n\t\"Apr\",\n\t\"May\",\n\t\"Jun\",\n\t\"Jul\",\n\t\"Aug\",\n\t\"Sep\",\n\t\"Oct\",\n\t\"Nov\",\n\t\"Dec\",\n];\nconst DAYS_WIDE = [\"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\"];\nconst DAYS_ABBR = [\"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\"];\n\nconst OBJECT_DEFAULTS: Record<string, unknown> = {\n\t\"common.digits\": { latn: \"0123456789\" },\n\t\"common.calendarData\": {\n\t\tgregory: { calendarSystem: \"solar\", eras: {} },\n\t},\n\tcalendarData: {\n\t\tgregory: {\n\t\t\tmonths: {\n\t\t\t\tformat: {\n\t\t\t\t\twide: MONTHS_WIDE,\n\t\t\t\t\tabbreviated: MONTHS_ABBR,\n\t\t\t\t\tnarrow: MONTHS_ABBR,\n\t\t\t\t},\n\t\t\t},\n\t\t\tdays: {\n\t\t\t\tformat: {\n\t\t\t\t\twide: DAYS_WIDE,\n\t\t\t\t\tabbreviated: DAYS_ABBR,\n\t\t\t\t\tnarrow: DAYS_ABBR,\n\t\t\t\t},\n\t\t\t},\n\t\t\tdayPeriods: {\n\t\t\t\tformat: {\n\t\t\t\t\twide: [\"AM\", \"PM\"],\n\t\t\t\t\tabbreviated: [\"am\", \"pm\"],\n\t\t\t\t\tnarrow: [\"a\", \"p\"],\n\t\t\t\t},\n\t\t\t},\n\t\t\teras: {\n\t\t\t\teraAbbr: [\"AD\"],\n\t\t\t\teraNames: [\"Anno Domini\"],\n\t\t\t\teraNarrow: [\"A\"],\n\t\t\t},\n\t\t},\n\t},\n};\n\nconst RUNTIME_SOURCE = `\nconst RTL_LANGS = new Set([\n 'ar', 'arc', 'dv', 'fa', 'ha', 'he', 'khw', 'ks', 'ku', 'ps', 'ur', 'yi',\n]);\n\nfunction getLocale() {\n if (typeof navigator === 'undefined') return 'en-US';\n return navigator.language || 'en-US';\n}\n\nfunction getLang() {\n return getLocale().split('-')[0];\n}\n\nfunction getDir() {\n return RTL_LANGS.has(getLang()) ? 'rtl' : 'ltr';\n}\n\nfunction getCurrency() {\n try {\n const parts = new Intl.NumberFormat(getLocale(), {\n style: 'currency',\n currency: 'USD',\n currencyDisplay: 'code',\n }).resolvedOptions();\n return parts.currency || 'USD';\n } catch {\n return 'USD';\n }\n}\n\nfunction getTimeZone() {\n try {\n return Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC';\n } catch {\n return 'UTC';\n }\n}\n\nfunction getFirstDayOfWeek() {\n try {\n const loc = new Intl.Locale(getLocale());\n if (loc.weekInfo) return String(loc.weekInfo.firstDay);\n if (typeof loc.getWeekInfo === 'function') return String(loc.getWeekInfo().firstDay);\n } catch { /* unsupported in this browser */ }\n return '7';\n}\n\nconst values = {\n lang: getLang(),\n dir: getDir(),\n locale: getLocale(),\n currency: getCurrency(),\n timeZone: getTimeZone(),\n firstDayOfWeek: getFirstDayOfWeek(),\n};\n\nexport default values['__KEY__'];\n`;\n\nexport interface I18nOptions {\n\tstaticOverrides?: Record<string, string>;\n\tobjectOverrides?: Record<string, unknown>;\n}\n\nexport function i18n(options: I18nOptions = {}): Provider {\n\tconst { staticOverrides = {}, objectOverrides = {} } = options;\n\tconst statics = { ...STATIC_DEFAULTS, ...staticOverrides };\n\tconst objects = { ...OBJECT_DEFAULTS, ...objectOverrides };\n\n\treturn {\n\t\tprefix: \"@salesforce/i18n/\",\n\t\tresolve(specifier) {\n\t\t\tif (!specifier.startsWith(\"@salesforce/i18n/\")) return null;\n\n\t\t\tconst key = specifier.slice(\"@salesforce/i18n/\".length);\n\n\t\t\tif (BROWSER_DERIVED.has(key)) {\n\t\t\t\treturn RUNTIME_SOURCE.replace(\"__KEY__\", key);\n\t\t\t}\n\n\t\t\tif (key in objects) {\n\t\t\t\treturn `export default ${JSON.stringify(objects[key])};`;\n\t\t\t}\n\n\t\t\tconst value = statics[key] ?? key;\n\t\t\treturn `export default ${JSON.stringify(value)};`;\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport type { Provider } from \"../types\";\n\nexport function gate(overrides: Record<string, boolean> = {}): Provider {\n\treturn {\n\t\tprefix: \"@salesforce/gate/\",\n\t\tresolve(specifier) {\n\t\t\tif (!specifier.startsWith(\"@salesforce/gate/\")) return null;\n\t\t\tconst name = specifier.slice(\"@salesforce/gate/\".length);\n\t\t\tconst isOpen = overrides[name] ?? true;\n\t\t\treturn `export default { isOpen: () => ${isOpen} };`;\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport type { Provider } from \"../types\";\n\nexport function accessCheck(overrides: Record<string, boolean> = {}): Provider {\n\treturn {\n\t\tprefix: \"@salesforce/accessCheck/\",\n\t\tresolve(specifier) {\n\t\t\tif (!specifier.startsWith(\"@salesforce/accessCheck/\")) return null;\n\t\t\tconst name = specifier.slice(\"@salesforce/accessCheck/\".length);\n\t\t\tconst value = overrides[name] ?? false;\n\t\t\treturn `export default ${value};`;\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport type { Provider } from \"../types\";\n\nconst FORM_FACTOR_SOURCE = `\nfunction getFormFactor() {\n if (typeof window === 'undefined') return 'Large';\n if (window.matchMedia('(max-width: 767px)').matches) return 'Small';\n if (window.matchMedia('(max-width: 1023px)').matches) return 'Medium';\n return 'Large';\n}\n\nexport default getFormFactor();\n`;\n\nexport function client(): Provider {\n\treturn {\n\t\tprefix: \"@salesforce/client/\",\n\t\tresolve(specifier) {\n\t\t\tif (specifier === \"@salesforce/client/formFactor\") {\n\t\t\t\treturn FORM_FACTOR_SOURCE;\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport type { Provider } from \"../types\";\n\nexport function primitiveUtils(): Provider {\n\treturn {\n\t\tprefix: \"lightning/primitiveUtils\",\n\t\tmatch(id) {\n\t\t\treturn id === \"lightning/primitiveUtils\";\n\t\t},\n\t\tresolve(specifier) {\n\t\t\tif (specifier !== \"lightning/primitiveUtils\") return null;\n\n\t\t\treturn `export function normalizeBoolean(value) {\n return typeof value === 'string' || !!value;\n}\n\nexport function reflectAttribute(element, attrName, value) {\n if (!element) return;\n if (typeof value === 'string') {\n element.setAttribute(attrName, value);\n } else if (value === true) {\n element.setAttribute(attrName, '');\n } else if (!value) {\n element.removeAttribute(attrName);\n } else {\n console.warn(\\`Invalid attribute value for \"\\${attrName}\": \\${value}\\`);\n }\n}\n`;\n\t\t},\n\t};\n}\n"],"names":[],"mappings":";AAOA,MAAM,iBAAyC;AAAA,EAC9C,sBAAsB;AAAA,EACtB,sBAAsB;AAAA,EACtB,wBAAwB;AAAA,EACxB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AO,kCAAkC,MAAM;AAAA,IAChD;AAAA,EAAA;AAEF;ACVO,SAAS,YAAY,YAAqC,IAAc;AAC9E,SAAO;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ,WAAW;AAClB,UAAI,CAAC,UAAU,WAAW,0BAA0B,EAAG,QAAO;AAC9D,YAAM,OAAO,UAAU,MAAM,2BAA2B,MAAM;AAC9D,YAAM,QAAQ,UAAU,IAAI,KAAK;AACjC,aAAO,kBAAkB,KAAK;AAAA,IAC/B;AAAA,EAAA;AAEF;ACVA,MAAM,qBAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWpB,SAAS,SAAmB;AAClC,SAAO;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ,WAAW;AAClB,UAAI,cAAc,iCAAiC;AAClD,eAAO;AAAA,MACR;AACA,aAAO;AAAA,IACR;AAAA,EAAA;AAEF;ACrBO,SAAS,iBAA2B;AAC1C,SAAO;AAAA,IACN,QAAQ;AAAA,IACR,MAAM,IAAI;AACT,aAAO,OAAO;AAAA,IACf;AAAA,IACA,QAAQ,WAAW;AAClB,UAAI,cAAc,2BAA4B,QAAO;AAErD,aAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAiBR;AAAA,EAAA;AAEF;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/providers/label.ts","../../src/providers/i18n.ts","../../src/providers/gate.ts","../../src/providers/access-check.ts","../../src/providers/client.ts","../../src/providers/primitive-utils.ts"],"sourcesContent":["/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport type { Provider } from \"../types\";\n\nconst LABEL_DEFAULTS: Record<string, string> = {\n\t\"LightningForm.edit\": \"Edit\",\n\t\"LightningForm.save\": \"Save\",\n\t\"LightningForm.cancel\": \"Cancel\",\n\t\"LightningForm.error\": \"Error\",\n\t\"RecordDetailUC.Expand\": \"Expand\",\n\t\"RecordDetailUC.Collapse\": \"Collapse\",\n\t\"Global_Entity.created_by\": \"Created By\",\n\t\"Global_Entity.last_modified_by\": \"Last Modified By\",\n\t\"DetailError.GenericSaveError\": \"An error occurred while saving.\",\n\t\"MobileWebError.NoPreEditAccess\": \"You don't have access to edit this record.\",\n\t\"DuplicateList.ToastMessageBlock\": \"Duplicate records were found.\",\n\t\"DuplicateList.NonBlockingHeaderText\": \"Duplicate records found\",\n\t\"DuplicateList.ToastMessageAlertEdit\": \"Duplicate records were found. You can continue editing.\",\n\t\"Errors.ErrorPopoverHeading\": \"Error\",\n};\n\nexport function label(overrides: Record<string, string> = {}): Provider {\n\tconst defaults = { ...LABEL_DEFAULTS, ...overrides };\n\treturn {\n\t\tprefix: \"@salesforce/label/\",\n\t\tresolve(specifier) {\n\t\t\tif (!specifier.startsWith(\"@salesforce/label/\")) return null;\n\n\t\t\tconst key = specifier.slice(\"@salesforce/label/\".length);\n\t\t\tconst fallbackLabel = key\n\t\t\t\t.split(\".\")\n\t\t\t\t.at(-1)!\n\t\t\t\t.replace(/([a-z0-9])([A-Z])/g, \"$1 $2\")\n\t\t\t\t.replace(/_/g, \" \")\n\t\t\t\t.trim();\n\t\t\tconst value = defaults[key] ?? fallbackLabel;\n\t\t\treturn `export default ${JSON.stringify(value)};`;\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport type { Provider } from \"../types\";\n\nconst BROWSER_DERIVED = new Set([\n\t\"lang\",\n\t\"dir\",\n\t\"locale\",\n\t\"currency\",\n\t\"timeZone\",\n\t\"firstDayOfWeek\",\n]);\n\nconst STATIC_DEFAULTS: Record<string, string> = {\n\t\"dateTime.shortDateFormat\": \"M/d/yyyy\",\n\t\"dateTime.mediumDateFormat\": \"MMM d, yyyy\",\n\t\"dateTime.longDateFormat\": \"MMMM d, yyyy\",\n\t\"dateTime.shortTimeFormat\": \"h:mm a\",\n\t\"dateTime.mediumTimeFormat\": \"h:mm:ss a\",\n\t\"dateTime.longTimeFormat\": \"h:mm:ss a z\",\n\t\"dateTime.shortDateTimeFormat\": \"M/d/yyyy, h:mm a\",\n\t\"number.numberFormat\": \"#,##0.##\",\n\t\"number.currencyFormat\": \"¤#,##0.00\",\n\t\"number.decimalSeparator\": \".\",\n\t\"number.groupingSeparator\": \",\",\n\t\"number.percentFormat\": \"#,##0%\",\n\t\"number.percentSign\": \"%\",\n\t\"number.plusSign\": \"+\",\n\t\"number.minusSign\": \"-\",\n\t\"number.exponentialSign\": \"E\",\n\t\"number.superscriptingExponentSign\": \"×\",\n\t\"number.perMilleSign\": \"‰\",\n\t\"number.infinity\": \"∞\",\n\t\"number.nan\": \"NaN\",\n\t\"number.currencySymbol\": \"$\",\n\tdefaultCalendar: \"gregory\",\n\tdefaultNumberingSystem: \"latn\",\n};\n\nconst MONTHS_WIDE = [\n\t\"January\",\n\t\"February\",\n\t\"March\",\n\t\"April\",\n\t\"May\",\n\t\"June\",\n\t\"July\",\n\t\"August\",\n\t\"September\",\n\t\"October\",\n\t\"November\",\n\t\"December\",\n];\nconst MONTHS_ABBR = [\n\t\"Jan\",\n\t\"Feb\",\n\t\"Mar\",\n\t\"Apr\",\n\t\"May\",\n\t\"Jun\",\n\t\"Jul\",\n\t\"Aug\",\n\t\"Sep\",\n\t\"Oct\",\n\t\"Nov\",\n\t\"Dec\",\n];\nconst DAYS_WIDE = [\"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\"];\nconst DAYS_ABBR = [\"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\"];\n\nconst OBJECT_DEFAULTS: Record<string, unknown> = {\n\t\"common.digits\": { latn: \"0123456789\" },\n\t\"common.calendarData\": {\n\t\tgregory: { calendarSystem: \"solar\", eras: {} },\n\t},\n\tcalendarData: {\n\t\tgregory: {\n\t\t\tmonths: {\n\t\t\t\tformat: {\n\t\t\t\t\twide: MONTHS_WIDE,\n\t\t\t\t\tabbreviated: MONTHS_ABBR,\n\t\t\t\t\tnarrow: MONTHS_ABBR,\n\t\t\t\t},\n\t\t\t},\n\t\t\tdays: {\n\t\t\t\tformat: {\n\t\t\t\t\twide: DAYS_WIDE,\n\t\t\t\t\tabbreviated: DAYS_ABBR,\n\t\t\t\t\tnarrow: DAYS_ABBR,\n\t\t\t\t},\n\t\t\t},\n\t\t\tdayPeriods: {\n\t\t\t\tformat: {\n\t\t\t\t\twide: [\"AM\", \"PM\"],\n\t\t\t\t\tabbreviated: [\"am\", \"pm\"],\n\t\t\t\t\tnarrow: [\"a\", \"p\"],\n\t\t\t\t},\n\t\t\t},\n\t\t\teras: {\n\t\t\t\teraAbbr: [\"AD\"],\n\t\t\t\teraNames: [\"Anno Domini\"],\n\t\t\t\teraNarrow: [\"A\"],\n\t\t\t},\n\t\t},\n\t},\n};\n\nconst RUNTIME_SOURCE = `\nconst RTL_LANGS = new Set([\n 'ar', 'arc', 'dv', 'fa', 'ha', 'he', 'khw', 'ks', 'ku', 'ps', 'ur', 'yi',\n]);\n\nfunction getLocale() {\n if (typeof navigator === 'undefined') return 'en-US';\n return navigator.language || 'en-US';\n}\n\nfunction getLang() {\n return getLocale().split('-')[0];\n}\n\nfunction getDir() {\n return RTL_LANGS.has(getLang()) ? 'rtl' : 'ltr';\n}\n\nfunction getCurrency() {\n try {\n const parts = new Intl.NumberFormat(getLocale(), {\n style: 'currency',\n currency: 'USD',\n currencyDisplay: 'code',\n }).resolvedOptions();\n return parts.currency || 'USD';\n } catch {\n return 'USD';\n }\n}\n\nfunction getTimeZone() {\n try {\n return Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC';\n } catch {\n return 'UTC';\n }\n}\n\nfunction getFirstDayOfWeek() {\n try {\n const loc = new Intl.Locale(getLocale());\n if (loc.weekInfo) return String(loc.weekInfo.firstDay);\n if (typeof loc.getWeekInfo === 'function') return String(loc.getWeekInfo().firstDay);\n } catch { /* unsupported in this browser */ }\n return '7';\n}\n\nconst values = {\n lang: getLang(),\n dir: getDir(),\n locale: getLocale(),\n currency: getCurrency(),\n timeZone: getTimeZone(),\n firstDayOfWeek: getFirstDayOfWeek(),\n};\n\nexport default values['__KEY__'];\n`;\n\nexport interface I18nOptions {\n\tstaticOverrides?: Record<string, string>;\n\tobjectOverrides?: Record<string, unknown>;\n}\n\nexport function i18n(options: I18nOptions = {}): Provider {\n\tconst { staticOverrides = {}, objectOverrides = {} } = options;\n\tconst statics = { ...STATIC_DEFAULTS, ...staticOverrides };\n\tconst objects = { ...OBJECT_DEFAULTS, ...objectOverrides };\n\n\treturn {\n\t\tprefix: \"@salesforce/i18n/\",\n\t\tresolve(specifier) {\n\t\t\tif (!specifier.startsWith(\"@salesforce/i18n/\")) return null;\n\n\t\t\tconst key = specifier.slice(\"@salesforce/i18n/\".length);\n\n\t\t\tif (BROWSER_DERIVED.has(key)) {\n\t\t\t\treturn RUNTIME_SOURCE.replace(\"__KEY__\", key);\n\t\t\t}\n\n\t\t\tif (key in objects) {\n\t\t\t\treturn `export default ${JSON.stringify(objects[key])};`;\n\t\t\t}\n\n\t\t\tconst value = statics[key] ?? key;\n\t\t\treturn `export default ${JSON.stringify(value)};`;\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport type { Provider } from \"../types\";\n\nexport function gate(overrides: Record<string, boolean> = {}): Provider {\n\treturn {\n\t\tprefix: \"@salesforce/gate/\",\n\t\tresolve(specifier) {\n\t\t\tif (!specifier.startsWith(\"@salesforce/gate/\")) return null;\n\t\t\tconst name = specifier.slice(\"@salesforce/gate/\".length);\n\t\t\tconst isOpen = overrides[name] ?? true;\n\t\t\treturn `export default { isOpen: () => ${isOpen} };`;\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport type { Provider } from \"../types\";\n\nexport function accessCheck(overrides: Record<string, boolean> = {}): Provider {\n\treturn {\n\t\tprefix: \"@salesforce/accessCheck/\",\n\t\tresolve(specifier) {\n\t\t\tif (!specifier.startsWith(\"@salesforce/accessCheck/\")) return null;\n\t\t\tconst name = specifier.slice(\"@salesforce/accessCheck/\".length);\n\t\t\tconst value = overrides[name] ?? false;\n\t\t\treturn `export default ${value};`;\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport type { Provider } from \"../types\";\n\nconst FORM_FACTOR_SOURCE = `\nfunction getFormFactor() {\n if (typeof window === 'undefined') return 'Large';\n if (window.matchMedia('(max-width: 767px)').matches) return 'Small';\n if (window.matchMedia('(max-width: 1023px)').matches) return 'Medium';\n return 'Large';\n}\n\nexport default getFormFactor();\n`;\n\nexport function client(): Provider {\n\treturn {\n\t\tprefix: \"@salesforce/client/\",\n\t\tresolve(specifier) {\n\t\t\tif (specifier === \"@salesforce/client/formFactor\") {\n\t\t\t\treturn FORM_FACTOR_SOURCE;\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport type { Provider } from \"../types\";\n\nexport function primitiveUtils(): Provider {\n\treturn {\n\t\tprefix: \"lightning/primitiveUtils\",\n\t\tmatch(id) {\n\t\t\treturn id === \"lightning/primitiveUtils\";\n\t\t},\n\t\tresolve(specifier) {\n\t\t\tif (specifier !== \"lightning/primitiveUtils\") return null;\n\n\t\t\treturn `export function normalizeBoolean(value) {\n return typeof value === 'string' || !!value;\n}\n\nexport function reflectAttribute(element, attrName, value) {\n if (!element) return;\n if (typeof value === 'string') {\n element.setAttribute(attrName, value);\n } else if (value === true) {\n element.setAttribute(attrName, '');\n } else if (!value) {\n element.removeAttribute(attrName);\n } else {\n console.warn(\\`Invalid attribute value for \"\\${attrName}\": \\${value}\\`);\n }\n}\n`;\n\t\t},\n\t};\n}\n"],"names":[],"mappings":";;AAOA,MAAM,iBAAyC;AAAA,EAC9C,sBAAsB;AAAA,EACtB,sBAAsB;AAAA,EACtB,wBAAwB;AAAA,EACxB,uBAAuB;AAAA,EACvB,yBAAyB;AAAA,EACzB,2BAA2B;AAAA,EAC3B,4BAA4B;AAAA,EAC5B,kCAAkC;AAAA,EAClC,gCAAgC;AAAA,EAChC,kCAAkC;AAAA,EAClC,mCAAmC;AAAA,EACnC,uCAAuC;AAAA,EACvC,uCAAuC;AAAA,EACvC,8BAA8B;AAC/B;AAEO,SAAS,MAAM,YAAoC,IAAc;AACvE,QAAM,WAAW,EAAE,GAAG,gBAAgB,GAAG,UAAA;AACzC,SAAO;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ,WAAW;AAClB,UAAI,CAAC,UAAU,WAAW,oBAAoB,EAAG,QAAO;AAExD,YAAM,MAAM,UAAU,MAAM,qBAAqB,MAAM;AACvD,YAAM,gBAAgB,IACpB,MAAM,GAAG,EACT,GAAG,EAAE,EACL,QAAQ,sBAAsB,OAAO,EACrC,QAAQ,MAAM,GAAG,EACjB,KAAA;AACF,YAAM,QAAQ,SAAS,GAAG,KAAK;AAC/B,aAAO,kBAAkB,KAAK,UAAU,KAAK,CAAC;AAAA,IAC/C;AAAA,EAAA;AAEF;ACnCA,MAAM,sCAAsB,IAAI;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,CAAC;AAED,MAAM,kBAA0C;AAAA,EAC/C,4BAA4B;AAAA,EAC5B,6BAA6B;AAAA,EAC7B,2BAA2B;AAAA,EAC3B,4BAA4B;AAAA,EAC5B,6BAA6B;AAAA,EAC7B,2BAA2B;AAAA,EAC3B,gCAAgC;AAAA,EAChC,uBAAuB;AAAA,EACvB,yBAAyB;AAAA,EACzB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.txt file
|
|
5
|
+
*/
|
|
6
|
+
/** The scoped-module prefix for Salesforce custom label imports. */
|
|
7
|
+
export declare const LABEL_PREFIX = "@salesforce/label/";
|
|
8
|
+
/** Vite virtual-module prefix for resolved label modules. */
|
|
9
|
+
export declare const VIRTUAL_LABEL_PREFIX = "\0sf-label-graphql:";
|
|
10
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/providers/labels-graphql/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,oEAAoE;AACpE,eAAO,MAAM,YAAY,uBAAuB,CAAC;AAEjD,6DAA6D;AAC7D,eAAO,MAAM,oBAAoB,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
import { LabelsGraphqlOptions, LabelKey } from './types';
|
|
3
|
+
export type { LabelsGraphqlOptions } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Runtime GraphQL-backed label resolution.
|
|
6
|
+
*
|
|
7
|
+
* Each `@salesforce/label/c.foo` import becomes a module that calls into a
|
|
8
|
+
* shared runtime. The runtime batches label keys and fetches their translated
|
|
9
|
+
* values via UI API GraphQL at runtime, ensuring labels reflect the current
|
|
10
|
+
* user's locale.
|
|
11
|
+
*/
|
|
12
|
+
export declare function labelsGraphql(options?: LabelsGraphqlOptions): Plugin;
|
|
13
|
+
declare function camelFallback(key: string): string;
|
|
14
|
+
export declare const __test__: {
|
|
15
|
+
camelFallback: typeof camelFallback;
|
|
16
|
+
STATIC_DEFAULTS: Record<string, string>;
|
|
17
|
+
};
|
|
18
|
+
export type { LabelKey };
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/labels-graphql/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,OAAO,KAAK,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE9D,YAAY,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAsBpD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,OAAO,GAAE,oBAAyB,GAAG,MAAM,CAwBxE;AAUD,iBAAS,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAM1C;AAED,eAAO,MAAM,QAAQ;;;CAAqC,CAAC;AAC3D,YAAY,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
const LABEL_PREFIX = "@salesforce/label/";
|
|
5
|
+
const VIRTUAL_LABEL_PREFIX = "\0sf-label-graphql:";
|
|
6
|
+
const __dirname$1 = dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
const RUNTIME_MODULE_ID = "\0sf-labels-graphql-runtime";
|
|
8
|
+
const STATIC_DEFAULTS = {
|
|
9
|
+
"LightningForm.edit": "Edit",
|
|
10
|
+
"LightningForm.save": "Save",
|
|
11
|
+
"LightningForm.cancel": "Cancel",
|
|
12
|
+
"LightningForm.error": "Error",
|
|
13
|
+
"RecordDetailUC.Expand": "Expand",
|
|
14
|
+
"RecordDetailUC.Collapse": "Collapse",
|
|
15
|
+
"Global_Entity.created_by": "Created By",
|
|
16
|
+
"Global_Entity.last_modified_by": "Last Modified By",
|
|
17
|
+
"DetailError.GenericSaveError": "An error occurred while saving.",
|
|
18
|
+
"MobileWebError.NoPreEditAccess": "You don't have access to edit this record.",
|
|
19
|
+
"DuplicateList.ToastMessageBlock": "Duplicate records were found.",
|
|
20
|
+
"DuplicateList.NonBlockingHeaderText": "Duplicate records found",
|
|
21
|
+
"DuplicateList.ToastMessageAlertEdit": "Duplicate records were found. You can continue editing.",
|
|
22
|
+
"Errors.ErrorPopoverHeading": "Error"
|
|
23
|
+
};
|
|
24
|
+
function labelsGraphql(options = {}) {
|
|
25
|
+
const overrides = { ...STATIC_DEFAULTS, ...options.staticOverrides ?? {} };
|
|
26
|
+
return {
|
|
27
|
+
name: "vite-plugin-labels-graphql",
|
|
28
|
+
enforce: "pre",
|
|
29
|
+
resolveId(id) {
|
|
30
|
+
if (id === RUNTIME_MODULE_ID) return RUNTIME_MODULE_ID;
|
|
31
|
+
if (!id.startsWith(LABEL_PREFIX)) return null;
|
|
32
|
+
return VIRTUAL_LABEL_PREFIX + id;
|
|
33
|
+
},
|
|
34
|
+
load(id) {
|
|
35
|
+
if (id === RUNTIME_MODULE_ID) {
|
|
36
|
+
return readFileSync(join(__dirname$1, "runtime.js"), "utf-8");
|
|
37
|
+
}
|
|
38
|
+
if (!id.startsWith(VIRTUAL_LABEL_PREFIX)) return null;
|
|
39
|
+
const specifier = id.slice(VIRTUAL_LABEL_PREFIX.length);
|
|
40
|
+
const key = specifier.slice(LABEL_PREFIX.length);
|
|
41
|
+
const fallback = overrides[key] ?? camelFallback(key);
|
|
42
|
+
return generateLabelModule(key, fallback);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function generateLabelModule(key, fallback) {
|
|
47
|
+
return [
|
|
48
|
+
`import { getLabel } from "${RUNTIME_MODULE_ID}";`,
|
|
49
|
+
`const label = getLabel(${JSON.stringify(key)}, ${JSON.stringify(fallback)});`,
|
|
50
|
+
`export default label;`
|
|
51
|
+
].join("\n");
|
|
52
|
+
}
|
|
53
|
+
function camelFallback(key) {
|
|
54
|
+
const tail = key.slice(1 + key.lastIndexOf("."));
|
|
55
|
+
return tail.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/_/g, " ").trim();
|
|
56
|
+
}
|
|
57
|
+
const __test__ = { camelFallback, STATIC_DEFAULTS };
|
|
58
|
+
export {
|
|
59
|
+
__test__,
|
|
60
|
+
labelsGraphql
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/providers/labels-graphql/constants.ts","../../../src/providers/labels-graphql/index.ts"],"sourcesContent":["/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\n\n/** The scoped-module prefix for Salesforce custom label imports. */\nexport const LABEL_PREFIX = \"@salesforce/label/\";\n\n/** Vite virtual-module prefix for resolved label modules. */\nexport const VIRTUAL_LABEL_PREFIX = \"\\0sf-label-graphql:\";\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { Plugin } from \"vite\";\nimport { LABEL_PREFIX, VIRTUAL_LABEL_PREFIX } from \"./constants\";\nimport type { LabelsGraphqlOptions, LabelKey } from \"./types\";\n\nexport type { LabelsGraphqlOptions } from \"./types\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\nconst RUNTIME_MODULE_ID = \"\\0sf-labels-graphql-runtime\";\n\nconst STATIC_DEFAULTS: Record<string, string> = {\n\t\"LightningForm.edit\": \"Edit\",\n\t\"LightningForm.save\": \"Save\",\n\t\"LightningForm.cancel\": \"Cancel\",\n\t\"LightningForm.error\": \"Error\",\n\t\"RecordDetailUC.Expand\": \"Expand\",\n\t\"RecordDetailUC.Collapse\": \"Collapse\",\n\t\"Global_Entity.created_by\": \"Created By\",\n\t\"Global_Entity.last_modified_by\": \"Last Modified By\",\n\t\"DetailError.GenericSaveError\": \"An error occurred while saving.\",\n\t\"MobileWebError.NoPreEditAccess\": \"You don't have access to edit this record.\",\n\t\"DuplicateList.ToastMessageBlock\": \"Duplicate records were found.\",\n\t\"DuplicateList.NonBlockingHeaderText\": \"Duplicate records found\",\n\t\"DuplicateList.ToastMessageAlertEdit\": \"Duplicate records were found. You can continue editing.\",\n\t\"Errors.ErrorPopoverHeading\": \"Error\",\n};\n\n/**\n * Runtime GraphQL-backed label resolution.\n *\n * Each `@salesforce/label/c.foo` import becomes a module that calls into a\n * shared runtime. The runtime batches label keys and fetches their translated\n * values via UI API GraphQL at runtime, ensuring labels reflect the current\n * user's locale.\n */\nexport function labelsGraphql(options: LabelsGraphqlOptions = {}): Plugin {\n\tconst overrides = { ...STATIC_DEFAULTS, ...(options.staticOverrides ?? {}) };\n\n\treturn {\n\t\tname: \"vite-plugin-labels-graphql\",\n\t\tenforce: \"pre\",\n\n\t\tresolveId(id) {\n\t\t\tif (id === RUNTIME_MODULE_ID) return RUNTIME_MODULE_ID;\n\t\t\tif (!id.startsWith(LABEL_PREFIX)) return null;\n\t\t\treturn VIRTUAL_LABEL_PREFIX + id;\n\t\t},\n\n\t\tload(id) {\n\t\t\tif (id === RUNTIME_MODULE_ID) {\n\t\t\t\treturn readFileSync(join(__dirname, \"runtime.js\"), \"utf-8\");\n\t\t\t}\n\t\t\tif (!id.startsWith(VIRTUAL_LABEL_PREFIX)) return null;\n\t\t\tconst specifier = id.slice(VIRTUAL_LABEL_PREFIX.length);\n\t\t\tconst key = specifier.slice(LABEL_PREFIX.length);\n\t\t\tconst fallback = overrides[key] ?? camelFallback(key);\n\t\t\treturn generateLabelModule(key, fallback);\n\t\t},\n\t};\n}\n\nfunction generateLabelModule(key: string, fallback: string): string {\n\treturn [\n\t\t`import { getLabel } from \"${RUNTIME_MODULE_ID}\";`,\n\t\t`const label = getLabel(${JSON.stringify(key)}, ${JSON.stringify(fallback)});`,\n\t\t`export default label;`,\n\t].join(\"\\n\");\n}\n\nfunction camelFallback(key: string): string {\n\tconst tail = key.slice(1 + key.lastIndexOf(\".\"));\n\treturn tail\n\t\t.replace(/([a-z0-9])([A-Z])/g, \"$1 $2\")\n\t\t.replace(/_/g, \" \")\n\t\t.trim();\n}\n\nexport const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AA0B,KAAK,UAAU,GAAG,CAAC,KAAK,KAAK,UAAU,QAAQ,CAAC;AAAA,IAC1E;AAAA,EAAA,EACC,KAAK,IAAI;AACZ;AAEA,SAAS,cAAc,KAAqB;AAC3C,QAAM,OAAO,IAAI,MAAM,IAAI,IAAI,YAAY,GAAG,CAAC;AAC/C,SAAO,KACL,QAAQ,sBAAsB,OAAO,EACrC,QAAQ,MAAM,GAAG,EACjB,KAAA;AACH;AAEO,MAAM,WAAW,EAAE,eAAe,gBAAA;"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
export declare function getLabel(key: string, fallback: string): string;
|
|
7
|
+
export declare function groupByNamespace(keys: string[]): Map<string, string[]>;
|
|
8
|
+
interface GraphqlEndpoint {
|
|
9
|
+
url: string;
|
|
10
|
+
headers?: Record<string, string>;
|
|
11
|
+
}
|
|
12
|
+
declare global {
|
|
13
|
+
interface Window {
|
|
14
|
+
__SF_LABELS_GRAPHQL_FETCH__?: (query: string, variables: Record<string, unknown>) => Promise<unknown>;
|
|
15
|
+
__SF_GRAPHQL_ENDPOINT__?: GraphqlEndpoint;
|
|
16
|
+
openai?: {
|
|
17
|
+
callTool?: (toolName: string, params: unknown) => Promise<unknown>;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export declare function graphqlFetch(query: string, variables: Record<string, unknown>): Promise<unknown>;
|
|
22
|
+
/** Reset internal state — exposed for tests only. */
|
|
23
|
+
export declare function __resetForTest(): void;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/providers/labels-graphql/runtime.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAM9D;AAkDD,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,CAIrC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
const labelCache = /* @__PURE__ */ new Map();
|
|
2
|
+
const pendingKeys = /* @__PURE__ */ new Set();
|
|
3
|
+
let fetchScheduled = false;
|
|
4
|
+
function getLabel(key, fallback) {
|
|
5
|
+
if (labelCache.has(key)) return labelCache.get(key);
|
|
6
|
+
labelCache.set(key, fallback);
|
|
7
|
+
pendingKeys.add(key);
|
|
8
|
+
scheduleFetch();
|
|
9
|
+
return fallback;
|
|
10
|
+
}
|
|
11
|
+
function scheduleFetch() {
|
|
12
|
+
if (fetchScheduled) return;
|
|
13
|
+
fetchScheduled = true;
|
|
14
|
+
Promise.resolve().then(() => {
|
|
15
|
+
fetchScheduled = false;
|
|
16
|
+
if (pendingKeys.size === 0) return;
|
|
17
|
+
const keys = [...pendingKeys];
|
|
18
|
+
pendingKeys.clear();
|
|
19
|
+
fetchLabelsFromOrg(keys);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
async function fetchLabelsFromOrg(keys) {
|
|
23
|
+
const grouped = groupByNamespace(keys);
|
|
24
|
+
for (const [namespace, names] of grouped) {
|
|
25
|
+
for (let i = 0; i < names.length; i += 100) {
|
|
26
|
+
const batch = names.slice(i, i + 100);
|
|
27
|
+
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
|
+
const response = await graphqlFetch(query, { namespace, names: batch });
|
|
38
|
+
const labels = response?.data?.uiapi?.labels ?? [];
|
|
39
|
+
for (const item of labels) {
|
|
40
|
+
const ns = item.namespace ?? namespace;
|
|
41
|
+
labelCache.set(ns + "." + item.name, item.value);
|
|
42
|
+
}
|
|
43
|
+
} catch (e) {
|
|
44
|
+
console.warn("[labels-graphql] Runtime fetch failed:", e);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function groupByNamespace(keys) {
|
|
50
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
51
|
+
for (const key of keys) {
|
|
52
|
+
const dot = key.indexOf(".");
|
|
53
|
+
const namespace = dot === -1 ? "c" : key.slice(0, dot);
|
|
54
|
+
const name = dot === -1 ? key : key.slice(dot + 1);
|
|
55
|
+
if (name.includes(".")) continue;
|
|
56
|
+
if (!grouped.has(namespace)) grouped.set(namespace, []);
|
|
57
|
+
grouped.get(namespace).push(name);
|
|
58
|
+
}
|
|
59
|
+
return grouped;
|
|
60
|
+
}
|
|
61
|
+
async function graphqlFetch(query, variables) {
|
|
62
|
+
if (typeof window !== "undefined" && window.__SF_LABELS_GRAPHQL_FETCH__) {
|
|
63
|
+
return window.__SF_LABELS_GRAPHQL_FETCH__(query, variables);
|
|
64
|
+
}
|
|
65
|
+
if (typeof window !== "undefined" && window.openai) {
|
|
66
|
+
const sdk = window.openai;
|
|
67
|
+
if (typeof sdk.callTool === "function") {
|
|
68
|
+
return sdk.callTool("graphqlQuery", { query, variables });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const endpoint = typeof window !== "undefined" ? window.__SF_GRAPHQL_ENDPOINT__ : void 0;
|
|
72
|
+
if (!endpoint) {
|
|
73
|
+
console.warn(
|
|
74
|
+
"[labels-graphql] No GraphQL endpoint configured. Labels will use fallback values."
|
|
75
|
+
);
|
|
76
|
+
return {};
|
|
77
|
+
}
|
|
78
|
+
const res = await fetch(endpoint.url, {
|
|
79
|
+
method: "POST",
|
|
80
|
+
headers: {
|
|
81
|
+
"Content-Type": "application/json",
|
|
82
|
+
...endpoint.headers || {}
|
|
83
|
+
},
|
|
84
|
+
body: JSON.stringify({ query, variables })
|
|
85
|
+
});
|
|
86
|
+
if (!res.ok) throw new Error("GraphQL fetch failed: " + res.status);
|
|
87
|
+
return res.json();
|
|
88
|
+
}
|
|
89
|
+
function __resetForTest() {
|
|
90
|
+
labelCache.clear();
|
|
91
|
+
pendingKeys.clear();
|
|
92
|
+
fetchScheduled = false;
|
|
93
|
+
}
|
|
94
|
+
export {
|
|
95
|
+
__resetForTest,
|
|
96
|
+
getLabel,
|
|
97
|
+
graphqlFetch,
|
|
98
|
+
groupByNamespace
|
|
99
|
+
};
|
|
100
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +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 query = `query Labels($namespace: String, $names: [String!]) {\n uiapi {\n labels(namespace: $namespace, names: $names) {\n namespace\n name\n value\n }\n }\n }`;\n\t\t\t\tconst response = await graphqlFetch(query, { namespace, names: batch });\n\t\t\t\tconst labels =\n\t\t\t\t\t(response as { data?: { uiapi?: { labels?: LabelRecord[] } } })?.data?.uiapi?.labels ??\n\t\t\t\t\t[];\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}\n"],"names":[],"mappings":"AAMA,MAAM,iCAAiB,IAAA;AACvB,MAAM,kCAAkB,IAAA;AACxB,IAAI,iBAAiB;AAEd,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,UAAU,iBAAiB,IAAI;AACrC,aAAW,CAAC,WAAW,KAAK,KAAK,SAAS;AACzC,aAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,KAAK;AAC3C,YAAM,QAAQ,MAAM,MAAM,GAAG,IAAI,GAAG;AACpC,UAAI;AACH,cAAM,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASd,cAAM,WAAW,MAAM,aAAa,OAAO,EAAE,WAAW,OAAO,OAAO;AACtE,cAAM,SACJ,UAAgE,MAAM,OAAO,UAC9E,CAAA;AACD,mBAAW,QAAQ,QAAQ;AAC1B,gBAAM,KAAK,KAAK,aAAa;AAC7B,qBAAW,IAAI,KAAK,MAAM,KAAK,MAAM,KAAK,KAAK;AAAA,QAChD;AAAA,MACD,SAAS,GAAG;AACX,gBAAQ,KAAK,0CAA0C,CAAC;AAAA,MACzD;AAAA,IACD;AAAA,EACD;AACD;AAQO,SAAS,iBAAiB,MAAuC;AACvE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
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
export interface LabelsGraphqlOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Static overrides applied as initial values before the runtime fetch
|
|
9
|
+
* resolves. Useful for fallback text that appears immediately while
|
|
10
|
+
* labels are loading.
|
|
11
|
+
*/
|
|
12
|
+
staticOverrides?: Record<string, string>;
|
|
13
|
+
/** Enable verbose logging during build. */
|
|
14
|
+
debug?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface LabelKey {
|
|
17
|
+
/** The full specifier, e.g. `@salesforce/label/c.appTitle`. */
|
|
18
|
+
specifier: string;
|
|
19
|
+
/** The label key without the `@salesforce/label/` prefix, e.g. `c.appTitle`. */
|
|
20
|
+
key: string;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/providers/labels-graphql/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,oBAAoB;IACpC;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,2CAA2C;IAC3C,KAAK,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,QAAQ;IACxB,+DAA+D;IAC/D,SAAS,EAAE,MAAM,CAAC;IAClB,gFAAgF;IAChF,GAAG,EAAE,MAAM,CAAC;CACZ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/vite-plugin-lwc-ui-bundle",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.1.0",
|
|
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",
|
|
@@ -34,6 +34,10 @@
|
|
|
34
34
|
"types": "./dist/providers/lds/index.d.ts",
|
|
35
35
|
"import": "./dist/providers/lds/index.js"
|
|
36
36
|
},
|
|
37
|
+
"./providers/labels-graphql": {
|
|
38
|
+
"types": "./dist/providers/labels-graphql/index.d.ts",
|
|
39
|
+
"import": "./dist/providers/labels-graphql/index.js"
|
|
40
|
+
},
|
|
37
41
|
"./package.json": "./package.json"
|
|
38
42
|
},
|
|
39
43
|
"main": "./dist/index.js",
|
|
@@ -45,7 +49,7 @@
|
|
|
45
49
|
"skills"
|
|
46
50
|
],
|
|
47
51
|
"scripts": {
|
|
48
|
-
"build": "vite build && vite build --mode runtime-lds",
|
|
52
|
+
"build": "vite build && vite build --mode runtime-lds && vite build --mode runtime-labels-graphql",
|
|
49
53
|
"clean": "rm -rf dist",
|
|
50
54
|
"dev": "vite build --watch",
|
|
51
55
|
"test": "vitest run",
|
|
@@ -54,8 +58,8 @@
|
|
|
54
58
|
},
|
|
55
59
|
"peerDependencies": {
|
|
56
60
|
"@lwc/rollup-plugin": "^9.0.0",
|
|
57
|
-
"@salesforce/platform-sdk": "^
|
|
58
|
-
"@salesforce/ui-bundle": "^
|
|
61
|
+
"@salesforce/platform-sdk": "^9.1.0",
|
|
62
|
+
"@salesforce/ui-bundle": "^9.1.0",
|
|
59
63
|
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0",
|
|
60
64
|
"zod": "^3.23.8"
|
|
61
65
|
},
|
|
@@ -75,7 +79,7 @@
|
|
|
75
79
|
"devDependencies": {
|
|
76
80
|
"@conduit-client/bindings-utils": "3.19.6",
|
|
77
81
|
"@conduit-client/command-base": "3.19.6",
|
|
78
|
-
"@salesforce/platform-sdk": "^
|
|
82
|
+
"@salesforce/platform-sdk": "^9.1.0",
|
|
79
83
|
"typescript": "^5.9.3",
|
|
80
84
|
"vite": "^7.0.0",
|
|
81
85
|
"vite-plugin-dts": "^4.5.4",
|