@salesforce/storefront-next-runtime 0.4.2 → 1.0.0-alpha.1
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/README.md +9 -3
- package/dist/ComponentContext.js +199 -4
- package/dist/ComponentContext.js.map +1 -1
- package/dist/DesignComponent.js +2 -2
- package/dist/DesignRegion.js +2 -2
- package/dist/RegionContext.js +9 -0
- package/dist/RegionContext.js.map +1 -0
- package/dist/component.types.d.ts +1 -1
- package/dist/config.d.ts +34 -221
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +35 -116
- package/dist/config.js.map +1 -1
- package/dist/data-store.d.ts +185 -15
- package/dist/data-store.d.ts.map +1 -1
- package/dist/data-store.js +412 -10
- package/dist/data-store.js.map +1 -1
- package/dist/defaults.d.ts +106 -0
- package/dist/defaults.d.ts.map +1 -0
- package/dist/defaults.js +67 -0
- package/dist/defaults.js.map +1 -0
- package/dist/design-data.d.ts +238 -356
- package/dist/design-data.d.ts.map +1 -1
- package/dist/design-data.js +459 -30
- package/dist/design-data.js.map +1 -1
- package/dist/design-mode.d.ts +3 -2
- package/dist/design-mode.d.ts.map +1 -1
- package/dist/design-react-core.d.ts +5 -15
- package/dist/design-react-core.d.ts.map +1 -1
- package/dist/design-react-core.js +2 -2
- package/dist/design-react.d.ts +2 -2
- package/dist/design.d.ts +2 -2
- package/dist/events.d.ts +32 -6
- package/dist/events.d.ts.map +1 -1
- package/dist/i18n-client.d.ts.map +1 -1
- package/dist/i18n-client.js.map +1 -1
- package/dist/i18n.d.ts +1 -2
- package/dist/i18n.d.ts.map +1 -1
- package/dist/modeDetection.js +0 -18
- package/dist/modeDetection.js.map +1 -1
- package/dist/scapi.d.ts +2185 -466
- package/dist/scapi.d.ts.map +1 -1
- package/dist/scapi.js +1 -1
- package/dist/scapi.js.map +1 -1
- package/dist/schema.d.ts +17 -15
- package/dist/schema.d.ts.map +1 -1
- package/dist/security-react.d.ts +34 -0
- package/dist/security-react.d.ts.map +1 -0
- package/dist/security-react.js +21 -0
- package/dist/security-react.js.map +1 -0
- package/dist/security.d.ts +61 -0
- package/dist/security.d.ts.map +1 -0
- package/dist/security.js +304 -0
- package/dist/security.js.map +1 -0
- package/dist/site-context.d.ts +43 -27
- package/dist/site-context.d.ts.map +1 -1
- package/dist/site-context.js +2 -2
- package/dist/site-context2.js +41 -31
- package/dist/site-context2.js.map +1 -1
- package/dist/types.d.ts +19 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/types2.d.ts +89 -63
- package/dist/types2.d.ts.map +1 -1
- package/dist/types3.d.ts +1 -35
- package/dist/types3.d.ts.map +1 -1
- package/package.json +15 -20
- package/dist/DesignFrame.js +0 -204
- package/dist/DesignFrame.js.map +0 -1
- package/dist/custom-global-preferences.d.ts +0 -20
- package/dist/custom-global-preferences.d.ts.map +0 -1
- package/dist/custom-global-preferences.js +0 -31
- package/dist/custom-global-preferences.js.map +0 -1
- package/dist/custom-site-preferences.d.ts +0 -20
- package/dist/custom-site-preferences.d.ts.map +0 -1
- package/dist/custom-site-preferences.js +0 -31
- package/dist/custom-site-preferences.js.map +0 -1
- package/dist/data-store-custom-global-preferences.d.ts +0 -2
- package/dist/data-store-custom-global-preferences.js +0 -6
- package/dist/data-store-custom-site-preferences.d.ts +0 -2
- package/dist/data-store-custom-site-preferences.js +0 -6
- package/dist/data-store-gcp-preferences.d.ts +0 -2
- package/dist/data-store-gcp-preferences.js +0 -6
- package/dist/gcp-preferences.d.ts +0 -52
- package/dist/gcp-preferences.d.ts.map +0 -1
- package/dist/gcp-preferences.js +0 -64
- package/dist/gcp-preferences.js.map +0 -1
- package/dist/utils.js +0 -90
- package/dist/utils.js.map +0 -1
package/dist/events.d.ts
CHANGED
|
@@ -114,10 +114,36 @@ interface ClickSearchSuggestionEvent extends BaseEvent {
|
|
|
114
114
|
searchInputText: string;
|
|
115
115
|
suggestion: string;
|
|
116
116
|
}
|
|
117
|
-
/**
|
|
118
|
-
interface
|
|
119
|
-
eventType: '
|
|
120
|
-
surface: '
|
|
117
|
+
/** Wishlist item added by shopper */
|
|
118
|
+
interface WishlistItemAddedEvent extends BaseEvent {
|
|
119
|
+
eventType: 'wishlist_item_added';
|
|
120
|
+
surface: 'pdp' | 'plp' | 'cart' | 'wishlist-page';
|
|
121
|
+
productId: string;
|
|
122
|
+
}
|
|
123
|
+
/** Wishlist item removed by shopper */
|
|
124
|
+
interface WishlistItemRemovedEvent extends BaseEvent {
|
|
125
|
+
eventType: 'wishlist_item_removed';
|
|
126
|
+
surface: 'pdp' | 'plp' | 'cart' | 'wishlist-page';
|
|
127
|
+
productId: string;
|
|
128
|
+
}
|
|
129
|
+
/** Wishlist page viewed */
|
|
130
|
+
interface WishlistViewedEvent extends BaseEvent {
|
|
131
|
+
eventType: 'wishlist_viewed';
|
|
132
|
+
}
|
|
133
|
+
/** Individual product merged from guest to registered wishlist */
|
|
134
|
+
interface WishlistItemMergedEvent extends BaseEvent {
|
|
135
|
+
eventType: 'wishlist_item_merged';
|
|
136
|
+
productId: string;
|
|
137
|
+
}
|
|
138
|
+
/** Summary of guest wishlist merge operation on login */
|
|
139
|
+
interface WishlistMergedEvent extends BaseEvent {
|
|
140
|
+
eventType: 'wishlist_merged';
|
|
141
|
+
merged: number;
|
|
142
|
+
skipped: number;
|
|
143
|
+
failed: number;
|
|
144
|
+
mergedProductIds: string[];
|
|
145
|
+
skippedProductIds: string[];
|
|
146
|
+
failedProductIds: string[];
|
|
121
147
|
}
|
|
122
148
|
/**
|
|
123
149
|
* Interface for custom analytics events.
|
|
@@ -138,7 +164,7 @@ interface AnalyticsEventExtensions {}
|
|
|
138
164
|
*
|
|
139
165
|
* Custom types can be added by extending the AnalyticsEventExtensions interface.
|
|
140
166
|
*/
|
|
141
|
-
type AnalyticsEvent = ViewPageEvent | ViewProductEvent | ViewSearchEvent | ViewCategoryEvent | ViewRecommenderEvent | ClickProductInCategoryEvent | ClickProductInSearchEvent | ClickProductInRecommenderEvent | CartItemAddEvent | CheckoutStartEvent | CheckoutStepEvent | ViewSearchSuggestionEvent | ClickSearchSuggestionEvent |
|
|
167
|
+
type AnalyticsEvent = ViewPageEvent | ViewProductEvent | ViewSearchEvent | ViewCategoryEvent | ViewRecommenderEvent | ClickProductInCategoryEvent | ClickProductInSearchEvent | ClickProductInRecommenderEvent | CartItemAddEvent | CheckoutStartEvent | CheckoutStepEvent | ViewSearchSuggestionEvent | ClickSearchSuggestionEvent | WishlistItemAddedEvent | WishlistItemRemovedEvent | WishlistViewedEvent | WishlistItemMergedEvent | WishlistMergedEvent | AnalyticsEventExtensions[keyof AnalyticsEventExtensions];
|
|
142
168
|
/**
|
|
143
169
|
* Helper type for mapping event_type to the corresponding event type.
|
|
144
170
|
*/
|
|
@@ -237,5 +263,5 @@ declare function getEventMediator(getAdapters: () => EventAdapter[]): EventMedia
|
|
|
237
263
|
*/
|
|
238
264
|
declare function resetEventMediator(): void;
|
|
239
265
|
//#endregion
|
|
240
|
-
export { AnalyticsEvent, AnalyticsEventExtensions, AnalyticsPayload, AnalyticsUser, BaseEvent, CartItemAddEvent, CheckoutStartEvent, CheckoutStepEvent, ClickProductInCategoryEvent, ClickProductInRecommenderEvent, ClickProductInSearchEvent, ClickSearchSuggestionEvent,
|
|
266
|
+
export { AnalyticsEvent, AnalyticsEventExtensions, AnalyticsPayload, AnalyticsUser, BaseEvent, CartItemAddEvent, CheckoutStartEvent, CheckoutStepEvent, ClickProductInCategoryEvent, ClickProductInRecommenderEvent, ClickProductInSearchEvent, ClickSearchSuggestionEvent, ConsentCategory, ConsentPreferences, EventAdapter, EventMediator, EventPayload, EventSiteInfo, EventTypeMap, PayloadTbd, ViewCategoryEvent, ViewPageEvent, ViewProductEvent, ViewRecommenderEvent, ViewSearchEvent, ViewSearchSuggestionEvent, WishlistItemAddedEvent, WishlistItemMergedEvent, WishlistItemRemovedEvent, WishlistMergedEvent, WishlistViewedEvent, createEvent, getEventMediator, resetEventMediator, sendViewPageEvent };
|
|
241
267
|
//# sourceMappingURL=events.d.ts.map
|
package/dist/events.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","names":[],"sources":["../src/events/types.ts","../src/events/events.ts","../src/events/mediator.ts"],"sourcesContent":[],"mappings":";;;;;KAmBK,iBAAA,GAAoB,gBAAA,CAAiB,OAqEQ,CAAA,aAAA,CAAA,GArEiB,gBAAA,CAAiB,OAqElC,CAAA,aAAA,CAAA;AAQlD,KA5EK,MAAA,GAAS,gBAAA,CAAiB,OA4EI,CAAA,QAAA,CAAA,GA5EgB,gBAAA,CAAiB,OA4EjC,CAAA,QAAA,CAAA;;;;;;AAQnC;AAOA;;;;;AAMA;AAMA;AAOA;;AAEe,UA3FE,aAAA,CA2FF;EAF2B,QAAA,EAAA,YAAA,GAAA,OAAA;EAAS,IAAA,CAAA,EAAA,MAAA;EAKlC,GAAA,CAAA,EAAA,MAAA;EAKA,SAAA,CAAA,EAAA,MAAA;EAOA,UAAA,CAAA,EAAA,MAAA;EAMA,UAAA,CAAA,EAAA,MAAA;EAOA,SAAA,CAAA,EAAA,MAAA;
|
|
1
|
+
{"version":3,"file":"events.d.ts","names":[],"sources":["../src/events/types.ts","../src/events/events.ts","../src/events/mediator.ts"],"sourcesContent":[],"mappings":";;;;;KAmBK,iBAAA,GAAoB,gBAAA,CAAiB,OAqEQ,CAAA,aAAA,CAAA,GArEiB,gBAAA,CAAiB,OAqElC,CAAA,aAAA,CAAA;AAQlD,KA5EK,MAAA,GAAS,gBAAA,CAAiB,OA4EI,CAAA,QAAA,CAAA,GA5EgB,gBAAA,CAAiB,OA4EjC,CAAA,QAAA,CAAA;;;;;;AAQnC;AAOA;;;;;AAMA;AAMA;AAOA;;AAEe,UA3FE,aAAA,CA2FF;EAF2B,QAAA,EAAA,YAAA,GAAA,OAAA;EAAS,IAAA,CAAA,EAAA,MAAA;EAKlC,GAAA,CAAA,EAAA,MAAA;EAKA,SAAA,CAAA,EAAA,MAAA;EAOA,UAAA,CAAA,EA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,uBAAuB,+BAA+B,KAAK,aAAa;WACvE;;;KAQD,aAAA;;;;;;;;;;;;;;;;;;;KAoBA,eAAA;;;;;;;KAQA,kBAAA,GAAqB;;;;;UAMhB,YAAA;;sBAGF,2BACI,oCACU,uBACpB;;;;;;KAOG,aAAA;iBACO,2BAA2B,oCAAoC;;;;;AAlNlF;;;;;;AAQA;AAOA;;;;;AAMA;AAMiB,iBCnFD,WDmFC,CAAA,UCnFqB,cDuFzB,CAAA,WAJ2C,CAAA,CAAA,CAAA,SAAS,EClFlD,CDkFkD,EAAA,IAAA,ECjFvD,YDiFuD,CCjF1C,CDiF0C,CAAA,CAAA,EChF9D,YDgF8D,CChFjD,CDgFiD,CAAA;AAOjE;;;;;AAKA;AAKA;AAOA;AAMA;AAOiB,iBCrGD,iBAAA,CDqGgC,KAAA,ECpGrC,aDoG8C,EAAA,aAAA,ECnGtC,aDmGsC,EAAA,QAAA,CAAA,EClG1C,aDkG0C,EAAA,kBAAA,CAAA,ECjGhC,kBDiGgC,CAAA,EAAA,IAAA;;;;AAhEzD;;;;;;AAQA;AAOiB,iBE1DD,gBAAA,CF0D6B,WAAA,EAAA,GAAA,GE1DO,YF0DP,EAAA,CAAA,EE1DwB,aF0DxB,GAAA,SAAA;;;;;AAM7C;AAMiB,iBEjDD,kBAAA,CAAA,CFiDgC,EAAA,IAInC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n-client.d.ts","names":[],"sources":["../src/i18n/types.ts","../src/i18n/client.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"i18n-client.d.ts","names":[],"sources":["../src/i18n/types.ts","../src/i18n/client.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;KAkCY,YAAA,yBAAqC;WAAmB;;;;;;;;;;;;;;;;;iBC+BpD,WAAA;;aAAsD;eAAmB;IAAiB"}
|
package/dist/i18n-client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n-client.js","names":["defaultInterpolation: InterpolationOptions"],"sources":["../src/i18n/defaults.ts","../src/i18n/client.ts"],"sourcesContent":["/**\n * Copyright 2026 Salesforce, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport type { InterpolationOptions } from 'i18next';\n\n/** Shared i18next interpolation config. Disables HTML escaping (React handles that) and adds `{{ value, number }}` formatting via `toLocaleString`. */\nexport const defaultInterpolation: InterpolationOptions = {\n escapeValue: false,\n format: (value, format) => {\n if (format === 'number' && typeof value === 'number') {\n return value.toLocaleString();\n }\n return value;\n },\n};\n","/**\n * Copyright 2026 Salesforce, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport i18next, { type i18n, type BackendModule, type ReadCallback } from 'i18next';\nimport { initReactI18next } from 'react-i18next';\nimport I18nextBrowserLanguageDetector from 'i18next-browser-languagedetector';\nimport { defaultInterpolation } from './defaults.js';\nimport type { LocaleLoader } from './types.js';\n\n/**\n * Custom i18next backend that calls the provided `loadLocale` callback to dynamically\n * import translations. Keeping the import() call in the template lets Vite resolve the\n * dynamic path at build time and split translations into per-language chunks.\n */\nfunction createDynamicImportBackend(instance: i18n, loadLocale: LocaleLoader): BackendModule {\n return {\n type: 'backend',\n init() {\n // No initialization needed\n },\n read(language: string, namespace: string, callback: ReadCallback) {\n loadLocale(language)\n .then((module) => {\n const translations = module.default;\n Object.entries(translations).forEach(([ns, nsTranslations]) => {\n instance.addResourceBundle(language, ns, nsTranslations, true, true);\n });\n callback(null, translations[namespace] ?? {});\n })\n .catch((error: Error) => {\n callback(error, false);\n });\n },\n };\n}\n\n/**\n * Initialize i18next on the client side.\n * Pass a `loadLocale` callback containing the dynamic import so Vite can resolve it\n * at build time relative to the template's source tree.\n *\n * @example\n * // In root.tsx — Vite resolves the import() relative to this file\n * initI18next({\n * language: document.documentElement.lang || undefined,\n * loadLocale: (language) => import(`@/locales/${language}/index.ts`),\n * });\n */\nexport function initI18next(options?: { language?: string; instance?: i18n; loadLocale?: LocaleLoader }): i18n {\n // NOTE: For any changes to this function, verify that Vite HMR still works with translations\n\n const language = options?.language;\n const instance = options?.instance ?? i18next;\n const loadLocale = options?.loadLocale;\n\n if (language) {\n instance.language = language;\n }\n\n const i18nextInstance = instance.use(initReactI18next);\n\n if (loadLocale) {\n i18nextInstance.use(createDynamicImportBackend(instance, loadLocale));\n }\n\n if (!language) {\n i18nextInstance.use(I18nextBrowserLanguageDetector);\n }\n\n void i18nextInstance.init({\n ns: [],\n ...(language\n ? { lng: language }\n : {\n detection: { order: ['htmlTag'], caches: [] },\n }),\n interpolation: defaultInterpolation,\n });\n\n return instance;\n}\n"],"mappings":";;;;;;AAkBA,MAAaA,uBAA6C;CACtD,aAAa;CACb,SAAS,OAAO,WAAW;AACvB,MAAI,WAAW,YAAY,OAAO,UAAU,SACxC,QAAO,MAAM,gBAAgB;AAEjC,SAAO;;CAEd;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"i18n-client.js","names":["defaultInterpolation: InterpolationOptions"],"sources":["../src/i18n/defaults.ts","../src/i18n/client.ts"],"sourcesContent":["/**\n * Copyright 2026 Salesforce, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport type { InterpolationOptions } from 'i18next';\n\n/** Shared i18next interpolation config. Disables HTML escaping (React handles that) and adds `{{ value, number }}` formatting via `toLocaleString`. */\nexport const defaultInterpolation: InterpolationOptions = {\n escapeValue: false,\n format: (value, format) => {\n if (format === 'number' && typeof value === 'number') {\n return value.toLocaleString();\n }\n return value;\n },\n};\n","/**\n * Copyright 2026 Salesforce, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// Browser-only entry. Imports `i18next-browser-languagedetector`, which has no Node\n// support — keep this file out of server code and only consume via the\n// `@salesforce/storefront-next-runtime/i18n/client` subpath in client modules\n// (e.g. `root.tsx` `useEffect`). Server-capable APIs live in the sibling\n// `@salesforce/storefront-next-runtime/i18n` subpath.\nimport i18next, { type i18n, type BackendModule, type ReadCallback } from 'i18next';\nimport { initReactI18next } from 'react-i18next';\nimport I18nextBrowserLanguageDetector from 'i18next-browser-languagedetector';\nimport { defaultInterpolation } from './defaults.js';\nimport type { LocaleLoader } from './types.js';\n\n/**\n * Custom i18next backend that calls the provided `loadLocale` callback to dynamically\n * import translations. Keeping the import() call in the template lets Vite resolve the\n * dynamic path at build time and split translations into per-language chunks.\n */\nfunction createDynamicImportBackend(instance: i18n, loadLocale: LocaleLoader): BackendModule {\n return {\n type: 'backend',\n init() {\n // No initialization needed\n },\n read(language: string, namespace: string, callback: ReadCallback) {\n loadLocale(language)\n .then((module) => {\n const translations = module.default;\n Object.entries(translations).forEach(([ns, nsTranslations]) => {\n instance.addResourceBundle(language, ns, nsTranslations, true, true);\n });\n callback(null, translations[namespace] ?? {});\n })\n .catch((error: Error) => {\n callback(error, false);\n });\n },\n };\n}\n\n/**\n * Initialize i18next on the client side.\n * Pass a `loadLocale` callback containing the dynamic import so Vite can resolve it\n * at build time relative to the template's source tree.\n *\n * @example\n * // In root.tsx — Vite resolves the import() relative to this file\n * initI18next({\n * language: document.documentElement.lang || undefined,\n * loadLocale: (language) => import(`@/locales/${language}/index.ts`),\n * });\n */\nexport function initI18next(options?: { language?: string; instance?: i18n; loadLocale?: LocaleLoader }): i18n {\n // NOTE: For any changes to this function, verify that Vite HMR still works with translations\n\n const language = options?.language;\n const instance = options?.instance ?? i18next;\n const loadLocale = options?.loadLocale;\n\n if (language) {\n instance.language = language;\n }\n\n const i18nextInstance = instance.use(initReactI18next);\n\n if (loadLocale) {\n i18nextInstance.use(createDynamicImportBackend(instance, loadLocale));\n }\n\n if (!language) {\n i18nextInstance.use(I18nextBrowserLanguageDetector);\n }\n\n void i18nextInstance.init({\n ns: [],\n ...(language\n ? { lng: language }\n : {\n detection: { order: ['htmlTag'], caches: [] },\n }),\n interpolation: defaultInterpolation,\n });\n\n return instance;\n}\n"],"mappings":";;;;;;AAkBA,MAAaA,uBAA6C;CACtD,aAAa;CACb,SAAS,OAAO,WAAW;AACvB,MAAI,WAAW,YAAY,OAAO,UAAU,SACxC,QAAO,MAAM,gBAAgB;AAEjC,SAAO;;CAEd;;;;;;;;;ACKD,SAAS,2BAA2B,UAAgB,YAAyC;AACzF,QAAO;EACH,MAAM;EACN,OAAO;EAGP,KAAK,UAAkB,WAAmB,UAAwB;AAC9D,cAAW,SAAS,CACf,MAAM,WAAW;IACd,MAAM,eAAe,OAAO;AAC5B,WAAO,QAAQ,aAAa,CAAC,SAAS,CAAC,IAAI,oBAAoB;AAC3D,cAAS,kBAAkB,UAAU,IAAI,gBAAgB,MAAM,KAAK;MACtE;AACF,aAAS,MAAM,aAAa,cAAc,EAAE,CAAC;KAC/C,CACD,OAAO,UAAiB;AACrB,aAAS,OAAO,MAAM;KACxB;;EAEb;;;;;;;;;;;;;;AAeL,SAAgB,YAAY,SAAmF;CAG3G,MAAM,WAAW,SAAS;CAC1B,MAAM,WAAW,SAAS,YAAY;CACtC,MAAM,aAAa,SAAS;AAE5B,KAAI,SACA,UAAS,WAAW;CAGxB,MAAM,kBAAkB,SAAS,IAAI,iBAAiB;AAEtD,KAAI,WACA,iBAAgB,IAAI,2BAA2B,UAAU,WAAW,CAAC;AAGzE,KAAI,CAAC,SACD,iBAAgB,IAAI,+BAA+B;AAGvD,CAAK,gBAAgB,KAAK;EACtB,IAAI,EAAE;EACN,GAAI,WACE,EAAE,KAAK,UAAU,GACjB,EACI,WAAW;GAAE,OAAO,CAAC,UAAU;GAAE,QAAQ,EAAE;GAAE,EAChD;EACP,eAAe;EAClB,CAAC;AAEF,QAAO"}
|
package/dist/i18n.d.ts
CHANGED
|
@@ -27,7 +27,6 @@ declare function mockI18nContext(contextProvider: RouterContextProvider, options
|
|
|
27
27
|
}): void;
|
|
28
28
|
//#endregion
|
|
29
29
|
//#region src/i18n/types.d.ts
|
|
30
|
-
|
|
31
30
|
/** Config passed to `createI18nMiddleware`. All values come from the template — the SDK never reads config values directly. */
|
|
32
31
|
interface I18nMiddlewareConfig {
|
|
33
32
|
resources: Resource;
|
|
@@ -59,5 +58,5 @@ declare function createI18nMiddleware(config: I18nMiddlewareConfig): MiddlewareF
|
|
|
59
58
|
/** Shared i18next interpolation config. Disables HTML escaping (React handles that) and adds `{{ value, number }}` formatting via `toLocaleString`. */
|
|
60
59
|
declare const defaultInterpolation: InterpolationOptions;
|
|
61
60
|
//#endregion
|
|
62
|
-
export { type I18nMiddlewareConfig, type LocaleLoader,
|
|
61
|
+
export { type I18nMiddlewareConfig, type LocaleLoader, createI18nMiddleware, defaultInterpolation, getLocale, getTranslation, mockI18nContext };
|
|
63
62
|
//# sourceMappingURL=i18n.d.ts.map
|
package/dist/i18n.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.d.ts","names":[],"sources":["../src/i18n/context.ts","../src/i18n/types.ts","../src/i18n/middleware.ts","../src/i18n/defaults.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AE2BA;AAA6C,iBFI7B,cAAA,CEJ6B,OAAA,CAAA,EFIJ,QEJI,CFIK,qBEJL,CAAA,CAAA,EAAA;EAA0C,OAAA,MAAA;EAAnB,CAAA,oBAAA,CAAA,CAAA,aAAA,EAAA,GAAA,MAAA,EAAA,CAAA,EAAA,SAAA,CAAA;CAAkB;;;;ACTtF;iBHqCgB,SAAA,UAAmB,SAAS;;;;;iBAQ5B,eAAA,kBACK;;aACsB
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","names":[],"sources":["../src/i18n/context.ts","../src/i18n/types.ts","../src/i18n/middleware.ts","../src/i18n/defaults.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AE2BA;AAA6C,iBFI7B,cAAA,CEJ6B,OAAA,CAAA,EFIJ,QEJI,CFIK,qBEJL,CAAA,CAAA,EAAA;EAA0C,OAAA,MAAA;EAAnB,CAAA,oBAAA,CAAA,CAAA,aAAA,EAAA,GAAA,MAAA,EAAA,CAAA,EAAA,SAAA,CAAA;CAAkB;;;;ACTtF;iBHqCgB,SAAA,UAAmB,SAAS;;;;;iBAQ5B,eAAA,kBACK;;aACsB;;;;AC/C3C;AACe,UADE,oBAAA,CACF;EAGK,SAAA,EAHL,QAGK;EACN,kBAAA,EAAA,MAAA,EAAA;EAAgB,gBAAA,EAAA,MAAA;EAWlB,aAAA,CAAA,EAZQ,oBAYgD;YAXtD;;;ACId;;;;;;;KDOY,YAAA,yBAAqC;EEhBpC,OAAA,EFgBuD,gBERnE;;;;;;;AHKD;AAAkD,iBEJlC,oBAAA,CFIkC,MAAA,EEJL,oBFIK,CAAA,EEJkB,kBFIlB,CEJqC,QFIrC,CAAA;;;ACblD;AACe,cEDF,oBFCE,EEDoB,oBFCpB"}
|
package/dist/modeDetection.js
CHANGED
|
@@ -1,23 +1,5 @@
|
|
|
1
1
|
//#region src/design/modeDetection.ts
|
|
2
2
|
/**
|
|
3
|
-
* Copyright 2026 Salesforce, Inc.
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
/**
|
|
18
|
-
* Utility functions for detecting active design/preview modes
|
|
19
|
-
*/
|
|
20
|
-
/**
|
|
21
3
|
* Get the mode parameter from URL search params
|
|
22
4
|
* @param url - Optional URL string or Request object for server-side usage. If not provided, uses window.location on client-side
|
|
23
5
|
* @returns The mode parameter value or null if not found
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modeDetection.js","names":["searchParams: URLSearchParams"],"sources":["../src/design/modeDetection.ts"],"sourcesContent":["/**\n * Copyright 2026 Salesforce, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Utility functions for detecting active design/preview modes\n */\n\n/**\n * Get the mode parameter from URL search params\n * @param url - Optional URL string or Request object for server-side usage. If not provided, uses window.location on client-side\n * @returns The mode parameter value or null if not found\n */\nexport const getUrlMode = (url?: string | URL | Request):
|
|
1
|
+
{"version":3,"file":"modeDetection.js","names":["searchParams: URLSearchParams"],"sources":["../src/design/modeDetection.ts"],"sourcesContent":["/**\n * Copyright 2026 Salesforce, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Utility functions for detecting active design/preview modes\n */\n\nexport type PageDesignerMode = 'EDIT' | 'PREVIEW';\n\n/**\n * Get the mode parameter from URL search params\n * @param url - Optional URL string or Request object for server-side usage. If not provided, uses window.location on client-side\n * @returns The mode parameter value or null if not found\n */\nexport const getUrlMode = (url?: string | URL | Request): PageDesignerMode | null => {\n let searchParams: URLSearchParams;\n\n if (url) {\n // Server-side: extract search params from provided URL or Request\n if (url instanceof Request) {\n searchParams = new URL(url.url).searchParams;\n } else {\n searchParams = new URL(url).searchParams;\n }\n } else {\n // Client-side: use window.location\n if (typeof window === 'undefined') {\n return null;\n }\n searchParams = new URLSearchParams(window.location.search);\n }\n\n return searchParams.get('mode') as PageDesignerMode | null;\n};\n\n/**\n * Check if design mode is active\n * @param url - Optional URL string or Request object for server-side usage\n * @returns True if mode=EDIT is present in URL\n */\nexport const isDesignModeActive = (url?: string | URL | Request): boolean => getUrlMode(url) === 'EDIT';\n\n/**\n * Check if preview mode is active\n * @param url - Optional URL string or Request object for server-side usage\n * @returns True if mode=PREVIEW is present in URL\n */\nexport const isPreviewModeActive = (url?: string | URL | Request): boolean => getUrlMode(url) === 'PREVIEW';\n"],"mappings":";;;;;;AA2BA,MAAa,cAAc,QAA0D;CACjF,IAAIA;AAEJ,KAAI,IAEA,KAAI,eAAe,QACf,gBAAe,IAAI,IAAI,IAAI,IAAI,CAAC;KAEhC,gBAAe,IAAI,IAAI,IAAI,CAAC;MAE7B;AAEH,MAAI,OAAO,WAAW,YAClB,QAAO;AAEX,iBAAe,IAAI,gBAAgB,OAAO,SAAS,OAAO;;AAG9D,QAAO,aAAa,IAAI,OAAO;;;;;;;AAQnC,MAAa,sBAAsB,QAA0C,WAAW,IAAI,KAAK;;;;;;AAOjG,MAAa,uBAAuB,QAA0C,WAAW,IAAI,KAAK"}
|