@weaverse/hydrogen 5.11.0 → 5.12.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.d.mts CHANGED
@@ -105,8 +105,22 @@ declare function useThemeText(): ThemeTextValue;
105
105
 
106
106
  declare class WeaverseHydrogenItem extends WeaverseItemStore {
107
107
  weaverse: WeaverseHydrogen;
108
+ /**
109
+ * Cached merged snapshot (base + translations).
110
+ * Reset to `null` whenever `_store` or the item's translation entry changes.
111
+ */
112
+ private _cachedSnapshot;
113
+ private _snapshotStoreRef;
114
+ private _snapshotTranslationRef;
108
115
  constructor(initialData: HydrogenComponentData, weaverse: WeaverseHydrogen);
109
116
  get Element(): HydrogenElement;
117
+ /**
118
+ * Override getSnapShot to merge translation data when in translation mode.
119
+ * Memoizes the result: returns the same object reference as long as
120
+ * both `_store` and the translation entry haven't changed.
121
+ * This is critical for `useSyncExternalStore` stability.
122
+ */
123
+ getSnapShot: () => ElementData;
110
124
  }
111
125
  declare class WeaverseHydrogen extends Weaverse {
112
126
  pageId: string;
@@ -125,7 +139,42 @@ declare class WeaverseHydrogen extends Weaverse {
125
139
  data: HydrogenPageData;
126
140
  static itemInstances: Map<string, WeaverseHydrogenItem>;
127
141
  static elementRegistry: Map<string, HydrogenElement>;
142
+ /**
143
+ * Translation map received from the builder in design mode.
144
+ * Keyed by item ID, each entry maps field names to translated values.
145
+ * `WeaverseHydrogenItem.getSnapShot()` merges these into the data
146
+ * returned to components, so translations render without monkey-patching.
147
+ */
148
+ translationMap: TranslationMap;
149
+ translationLocale: string;
150
+ translationLanguageId: string;
128
151
  constructor(params: WeaverseHydrogenParams);
152
+ /**
153
+ * Extract translation sidecar data from `this.data` (the page data).
154
+ * The builder attaches `translationMap`, `translationLocale`, and
155
+ * `translationLanguageId` to the page data in design mode.
156
+ */
157
+ extractTranslationSidecar: () => void;
158
+ /**
159
+ * Set the translation sidecar data.
160
+ * Called by the studio bridge when translation data arrives or changes.
161
+ * Triggers a re-render of all items so translated snapshots are recalculated.
162
+ */
163
+ setTranslationSidecar: (translationMap: TranslationMap, locale: string, languageId: string) => void;
164
+ /**
165
+ * Update a single translation entry for a specific item field.
166
+ * Used by the studio bridge when the user edits a translatable field.
167
+ */
168
+ updateTranslation: (itemId: string, key: string, originalValue: string, translatedValue: string) => void;
169
+ /**
170
+ * Collect all translation changes across all weaverse instances.
171
+ * Used by the save flow to persist translation edits.
172
+ */
173
+ getTranslationChanges: () => TranslationChanges | undefined;
174
+ /**
175
+ * Override setProjectData to re-extract translation sidecar from new page data.
176
+ */
177
+ setProjectData: (data: HydrogenPageData) => void;
129
178
  }
130
179
  /**
131
180
  * Register a Weaverse component with the global element registry.
@@ -531,9 +580,6 @@ type WeaverseI18n = I18nBase & {
531
580
  [key: string]: any;
532
581
  };
533
582
  type HydrogenThemeSchema = {
534
- betaFlags?: {
535
- contentManager?: boolean;
536
- };
537
583
  info: {
538
584
  name: string;
539
585
  version: string;
@@ -550,6 +596,8 @@ type HydrogenThemeSchema = {
550
596
  defaultLocale: WeaverseI18n;
551
597
  shopLocales: WeaverseI18n[];
552
598
  staticContent?: Record<string, unknown>;
599
+ /** Enable the translation UI in the builder. */
600
+ translation?: boolean;
553
601
  };
554
602
  };
555
603
  type FetchProjectRequestBody = {
@@ -918,6 +966,35 @@ type LoadPageParams = {
918
966
  */
919
967
  projectId?: string;
920
968
  };
969
+ /** A single translated field for one item */
970
+ interface TranslationMapEntry {
971
+ originalValue: string;
972
+ translatedValue: string;
973
+ }
974
+ /** Per-item translation fields, keyed by field name */
975
+ type TranslationItemEntry = {
976
+ [key: string]: TranslationMapEntry;
977
+ };
978
+ /**
979
+ * Translation map sent from the builder alongside page data in design mode.
980
+ * Keyed by item ID, each value maps field names to translation entries.
981
+ */
982
+ type TranslationMap = {
983
+ [itemId: string]: TranslationItemEntry;
984
+ };
985
+ /** A single translation entry for save payloads */
986
+ interface TranslationEntry {
987
+ deleted?: boolean;
988
+ itemId: string;
989
+ key: string;
990
+ originalValue: string;
991
+ translatedValue: string;
992
+ }
993
+ /** Result of collecting translation changes for the save flow */
994
+ type TranslationChanges = {
995
+ languageId: string;
996
+ entries: TranslationEntry[];
997
+ };
921
998
 
922
999
  declare let defaultComponents: HydrogenComponent[];
923
1000
 
@@ -1020,4 +1097,4 @@ declare const IMAGES_PLACEHOLDERS: {
1020
1097
  product_18: string;
1021
1098
  };
1022
1099
 
1023
- export { type CacheResponseValidator, type ComponentDataValue, type ComponentLoaderArgs, type CreateHydrogenSchemaOptions, type DirectFetchResponse, type FetchProjectPayload, type FetchProjectRequestBody, type HydrogenComponent, type HydrogenComponentData, type HydrogenComponentPresets, type HydrogenComponentProps, type HydrogenComponentSchema, type HydrogenElement, type HydrogenPageAssignment, type HydrogenPageData, type HydrogenProjectType, type HydrogenSchemaValidationResult, type HydrogenThemeSchema, type HydrogenThemeSettings, IMAGES_PLACEHOLDERS, type LoadPageParams, type ProjectIdValidationResult, type ProjectIdValue, type PublicEnv, type RouteLoaderArgs, type ThemeSettingsResponse, ThemeTextProvider, type ThemeTextProviderProps, type ThemeTextValue, type TranslateFunction, type WeaverseArticle, type WeaverseBlog, WeaverseClient, type WeaverseClientArgs, type WeaverseCollection, type WeaverseDataContext, WeaverseError, WeaverseHydrogen, WeaverseHydrogenItem, type WeaverseHydrogenParams, WeaverseHydrogenRoot, type WeaverseI18n, type WeaverseInternal, type WeaverseLoaderData, type WeaverseLoaderRequestInfo, type WeaverseMetaObject, type WeaverseProduct, type WeaverseProjectConfigs, type WeaverseStudioQueries, type WithCacheFetchResponse, type WithWeaverseOptions, createWeaverseDataContext, defaultComponents, generateDataFromSchema, getNestedKey, getPreviewData, getRequestQueries, getSelectedProductOptions, getWeaverseConfigs, hasError, hasWeaverseStudio, interpolate, isFetchProjectPayload, isProjectIdFunction, isThemeSettingsResponse, isValidHydrogenSchema, isWithCacheFetchResponse, registerComponent, useThemeSettings, useThemeText, useWeaverseDataContext, withWeaverse };
1100
+ export { type CacheResponseValidator, type ComponentDataValue, type ComponentLoaderArgs, type CreateHydrogenSchemaOptions, type DirectFetchResponse, type FetchProjectPayload, type FetchProjectRequestBody, type HydrogenComponent, type HydrogenComponentData, type HydrogenComponentPresets, type HydrogenComponentProps, type HydrogenComponentSchema, type HydrogenElement, type HydrogenPageAssignment, type HydrogenPageData, type HydrogenProjectType, type HydrogenSchemaValidationResult, type HydrogenThemeSchema, type HydrogenThemeSettings, IMAGES_PLACEHOLDERS, type LoadPageParams, type ProjectIdValidationResult, type ProjectIdValue, type PublicEnv, type RouteLoaderArgs, type ThemeSettingsResponse, ThemeTextProvider, type ThemeTextProviderProps, type ThemeTextValue, type TranslateFunction, type TranslationChanges, type TranslationEntry, type TranslationItemEntry, type TranslationMap, type TranslationMapEntry, type WeaverseArticle, type WeaverseBlog, WeaverseClient, type WeaverseClientArgs, type WeaverseCollection, type WeaverseDataContext, WeaverseError, WeaverseHydrogen, WeaverseHydrogenItem, type WeaverseHydrogenParams, WeaverseHydrogenRoot, type WeaverseI18n, type WeaverseInternal, type WeaverseLoaderData, type WeaverseLoaderRequestInfo, type WeaverseMetaObject, type WeaverseProduct, type WeaverseProjectConfigs, type WeaverseStudioQueries, type WithCacheFetchResponse, type WithWeaverseOptions, createWeaverseDataContext, defaultComponents, generateDataFromSchema, getNestedKey, getPreviewData, getRequestQueries, getSelectedProductOptions, getWeaverseConfigs, hasError, hasWeaverseStudio, interpolate, isFetchProjectPayload, isProjectIdFunction, isThemeSettingsResponse, isValidHydrogenSchema, isWithCacheFetchResponse, registerComponent, useThemeSettings, useThemeText, useWeaverseDataContext, withWeaverse };
package/dist/index.d.ts CHANGED
@@ -105,8 +105,22 @@ declare function useThemeText(): ThemeTextValue;
105
105
 
106
106
  declare class WeaverseHydrogenItem extends WeaverseItemStore {
107
107
  weaverse: WeaverseHydrogen;
108
+ /**
109
+ * Cached merged snapshot (base + translations).
110
+ * Reset to `null` whenever `_store` or the item's translation entry changes.
111
+ */
112
+ private _cachedSnapshot;
113
+ private _snapshotStoreRef;
114
+ private _snapshotTranslationRef;
108
115
  constructor(initialData: HydrogenComponentData, weaverse: WeaverseHydrogen);
109
116
  get Element(): HydrogenElement;
117
+ /**
118
+ * Override getSnapShot to merge translation data when in translation mode.
119
+ * Memoizes the result: returns the same object reference as long as
120
+ * both `_store` and the translation entry haven't changed.
121
+ * This is critical for `useSyncExternalStore` stability.
122
+ */
123
+ getSnapShot: () => ElementData;
110
124
  }
111
125
  declare class WeaverseHydrogen extends Weaverse {
112
126
  pageId: string;
@@ -125,7 +139,42 @@ declare class WeaverseHydrogen extends Weaverse {
125
139
  data: HydrogenPageData;
126
140
  static itemInstances: Map<string, WeaverseHydrogenItem>;
127
141
  static elementRegistry: Map<string, HydrogenElement>;
142
+ /**
143
+ * Translation map received from the builder in design mode.
144
+ * Keyed by item ID, each entry maps field names to translated values.
145
+ * `WeaverseHydrogenItem.getSnapShot()` merges these into the data
146
+ * returned to components, so translations render without monkey-patching.
147
+ */
148
+ translationMap: TranslationMap;
149
+ translationLocale: string;
150
+ translationLanguageId: string;
128
151
  constructor(params: WeaverseHydrogenParams);
152
+ /**
153
+ * Extract translation sidecar data from `this.data` (the page data).
154
+ * The builder attaches `translationMap`, `translationLocale`, and
155
+ * `translationLanguageId` to the page data in design mode.
156
+ */
157
+ extractTranslationSidecar: () => void;
158
+ /**
159
+ * Set the translation sidecar data.
160
+ * Called by the studio bridge when translation data arrives or changes.
161
+ * Triggers a re-render of all items so translated snapshots are recalculated.
162
+ */
163
+ setTranslationSidecar: (translationMap: TranslationMap, locale: string, languageId: string) => void;
164
+ /**
165
+ * Update a single translation entry for a specific item field.
166
+ * Used by the studio bridge when the user edits a translatable field.
167
+ */
168
+ updateTranslation: (itemId: string, key: string, originalValue: string, translatedValue: string) => void;
169
+ /**
170
+ * Collect all translation changes across all weaverse instances.
171
+ * Used by the save flow to persist translation edits.
172
+ */
173
+ getTranslationChanges: () => TranslationChanges | undefined;
174
+ /**
175
+ * Override setProjectData to re-extract translation sidecar from new page data.
176
+ */
177
+ setProjectData: (data: HydrogenPageData) => void;
129
178
  }
130
179
  /**
131
180
  * Register a Weaverse component with the global element registry.
@@ -531,9 +580,6 @@ type WeaverseI18n = I18nBase & {
531
580
  [key: string]: any;
532
581
  };
533
582
  type HydrogenThemeSchema = {
534
- betaFlags?: {
535
- contentManager?: boolean;
536
- };
537
583
  info: {
538
584
  name: string;
539
585
  version: string;
@@ -550,6 +596,8 @@ type HydrogenThemeSchema = {
550
596
  defaultLocale: WeaverseI18n;
551
597
  shopLocales: WeaverseI18n[];
552
598
  staticContent?: Record<string, unknown>;
599
+ /** Enable the translation UI in the builder. */
600
+ translation?: boolean;
553
601
  };
554
602
  };
555
603
  type FetchProjectRequestBody = {
@@ -918,6 +966,35 @@ type LoadPageParams = {
918
966
  */
919
967
  projectId?: string;
920
968
  };
969
+ /** A single translated field for one item */
970
+ interface TranslationMapEntry {
971
+ originalValue: string;
972
+ translatedValue: string;
973
+ }
974
+ /** Per-item translation fields, keyed by field name */
975
+ type TranslationItemEntry = {
976
+ [key: string]: TranslationMapEntry;
977
+ };
978
+ /**
979
+ * Translation map sent from the builder alongside page data in design mode.
980
+ * Keyed by item ID, each value maps field names to translation entries.
981
+ */
982
+ type TranslationMap = {
983
+ [itemId: string]: TranslationItemEntry;
984
+ };
985
+ /** A single translation entry for save payloads */
986
+ interface TranslationEntry {
987
+ deleted?: boolean;
988
+ itemId: string;
989
+ key: string;
990
+ originalValue: string;
991
+ translatedValue: string;
992
+ }
993
+ /** Result of collecting translation changes for the save flow */
994
+ type TranslationChanges = {
995
+ languageId: string;
996
+ entries: TranslationEntry[];
997
+ };
921
998
 
922
999
  declare let defaultComponents: HydrogenComponent[];
923
1000
 
@@ -1020,4 +1097,4 @@ declare const IMAGES_PLACEHOLDERS: {
1020
1097
  product_18: string;
1021
1098
  };
1022
1099
 
1023
- export { type CacheResponseValidator, type ComponentDataValue, type ComponentLoaderArgs, type CreateHydrogenSchemaOptions, type DirectFetchResponse, type FetchProjectPayload, type FetchProjectRequestBody, type HydrogenComponent, type HydrogenComponentData, type HydrogenComponentPresets, type HydrogenComponentProps, type HydrogenComponentSchema, type HydrogenElement, type HydrogenPageAssignment, type HydrogenPageData, type HydrogenProjectType, type HydrogenSchemaValidationResult, type HydrogenThemeSchema, type HydrogenThemeSettings, IMAGES_PLACEHOLDERS, type LoadPageParams, type ProjectIdValidationResult, type ProjectIdValue, type PublicEnv, type RouteLoaderArgs, type ThemeSettingsResponse, ThemeTextProvider, type ThemeTextProviderProps, type ThemeTextValue, type TranslateFunction, type WeaverseArticle, type WeaverseBlog, WeaverseClient, type WeaverseClientArgs, type WeaverseCollection, type WeaverseDataContext, WeaverseError, WeaverseHydrogen, WeaverseHydrogenItem, type WeaverseHydrogenParams, WeaverseHydrogenRoot, type WeaverseI18n, type WeaverseInternal, type WeaverseLoaderData, type WeaverseLoaderRequestInfo, type WeaverseMetaObject, type WeaverseProduct, type WeaverseProjectConfigs, type WeaverseStudioQueries, type WithCacheFetchResponse, type WithWeaverseOptions, createWeaverseDataContext, defaultComponents, generateDataFromSchema, getNestedKey, getPreviewData, getRequestQueries, getSelectedProductOptions, getWeaverseConfigs, hasError, hasWeaverseStudio, interpolate, isFetchProjectPayload, isProjectIdFunction, isThemeSettingsResponse, isValidHydrogenSchema, isWithCacheFetchResponse, registerComponent, useThemeSettings, useThemeText, useWeaverseDataContext, withWeaverse };
1100
+ export { type CacheResponseValidator, type ComponentDataValue, type ComponentLoaderArgs, type CreateHydrogenSchemaOptions, type DirectFetchResponse, type FetchProjectPayload, type FetchProjectRequestBody, type HydrogenComponent, type HydrogenComponentData, type HydrogenComponentPresets, type HydrogenComponentProps, type HydrogenComponentSchema, type HydrogenElement, type HydrogenPageAssignment, type HydrogenPageData, type HydrogenProjectType, type HydrogenSchemaValidationResult, type HydrogenThemeSchema, type HydrogenThemeSettings, IMAGES_PLACEHOLDERS, type LoadPageParams, type ProjectIdValidationResult, type ProjectIdValue, type PublicEnv, type RouteLoaderArgs, type ThemeSettingsResponse, ThemeTextProvider, type ThemeTextProviderProps, type ThemeTextValue, type TranslateFunction, type TranslationChanges, type TranslationEntry, type TranslationItemEntry, type TranslationMap, type TranslationMapEntry, type WeaverseArticle, type WeaverseBlog, WeaverseClient, type WeaverseClientArgs, type WeaverseCollection, type WeaverseDataContext, WeaverseError, WeaverseHydrogen, WeaverseHydrogenItem, type WeaverseHydrogenParams, WeaverseHydrogenRoot, type WeaverseI18n, type WeaverseInternal, type WeaverseLoaderData, type WeaverseLoaderRequestInfo, type WeaverseMetaObject, type WeaverseProduct, type WeaverseProjectConfigs, type WeaverseStudioQueries, type WithCacheFetchResponse, type WithWeaverseOptions, createWeaverseDataContext, defaultComponents, generateDataFromSchema, getNestedKey, getPreviewData, getRequestQueries, getSelectedProductOptions, getWeaverseConfigs, hasError, hasWeaverseStudio, interpolate, isFetchProjectPayload, isProjectIdFunction, isThemeSettingsResponse, isValidHydrogenSchema, isWithCacheFetchResponse, registerComponent, useThemeSettings, useThemeText, useWeaverseDataContext, withWeaverse };
package/dist/index.js CHANGED
@@ -48,12 +48,12 @@ function getNestedKey(obj, path, fallback) {
48
48
  return fallback;
49
49
  }
50
50
  function interpolate(template, variables) {
51
- if (!variables || Object.keys(variables).length === 0) {
51
+ if (!variables) {
52
52
  return template;
53
53
  }
54
54
  return template.replace(/\{\{(\w+)\}\}/g, (match, key) => {
55
55
  const value = variables[key];
56
- return value !== void 0 ? String(value) : match;
56
+ return value === void 0 ? match : String(value);
57
57
  });
58
58
  }
59
59
  var ThemeTextContext = react$1.createContext(null);
@@ -501,6 +501,13 @@ function usePixel(context) {
501
501
  }, []);
502
502
  }
503
503
  var WeaverseHydrogenItem = class extends react.WeaverseItemStore {
504
+ /**
505
+ * Cached merged snapshot (base + translations).
506
+ * Reset to `null` whenever `_store` or the item's translation entry changes.
507
+ */
508
+ _cachedSnapshot = null;
509
+ _snapshotStoreRef = null;
510
+ _snapshotTranslationRef = null;
504
511
  constructor(initialData, weaverse) {
505
512
  super(initialData, weaverse);
506
513
  const { data, ...rest } = initialData;
@@ -514,6 +521,32 @@ var WeaverseHydrogenItem = class extends react.WeaverseItemStore {
514
521
  get Element() {
515
522
  return super.Element;
516
523
  }
524
+ /**
525
+ * Override getSnapShot to merge translation data when in translation mode.
526
+ * Memoizes the result: returns the same object reference as long as
527
+ * both `_store` and the translation entry haven't changed.
528
+ * This is critical for `useSyncExternalStore` stability.
529
+ */
530
+ getSnapShot = () => {
531
+ const base = this._store;
532
+ const translations = this.weaverse.translationMap?.[this._id];
533
+ if (!translations) {
534
+ return base;
535
+ }
536
+ if (this._cachedSnapshot && this._snapshotStoreRef === base && this._snapshotTranslationRef === translations) {
537
+ return this._cachedSnapshot;
538
+ }
539
+ const merged = { ...base };
540
+ for (const [key, entry] of Object.entries(translations)) {
541
+ if (entry.translatedValue !== void 0) {
542
+ merged[key] = entry.translatedValue;
543
+ }
544
+ }
545
+ this._cachedSnapshot = merged;
546
+ this._snapshotStoreRef = base;
547
+ this._snapshotTranslationRef = translations;
548
+ return merged;
549
+ };
517
550
  };
518
551
  react.Weaverse.ItemConstructor = WeaverseHydrogenItem;
519
552
  var WeaverseHydrogen = class extends react.Weaverse {
@@ -529,8 +562,16 @@ var WeaverseHydrogen = class extends react.Weaverse {
529
562
  isPreviewMode;
530
563
  isRevisionPreview;
531
564
  sectionType;
532
- static itemInstances;
533
- static elementRegistry;
565
+ // ─── Translation sidecar (design mode only) ────────────────────────
566
+ /**
567
+ * Translation map received from the builder in design mode.
568
+ * Keyed by item ID, each entry maps field names to translated values.
569
+ * `WeaverseHydrogenItem.getSnapShot()` merges these into the data
570
+ * returned to components, so translations render without monkey-patching.
571
+ */
572
+ translationMap = {};
573
+ translationLocale = "";
574
+ translationLanguageId = "";
534
575
  constructor(params) {
535
576
  const { internal, pageId, requestInfo, ...coreParams } = params;
536
577
  super({ ...coreParams });
@@ -546,7 +587,82 @@ var WeaverseHydrogen = class extends react.Weaverse {
546
587
  this.isPreviewMode = params.isPreviewMode ?? false;
547
588
  this.isRevisionPreview = params.isRevisionPreview ?? false;
548
589
  this.sectionType = params.sectionType || "";
590
+ this.extractTranslationSidecar();
549
591
  }
592
+ /**
593
+ * Extract translation sidecar data from `this.data` (the page data).
594
+ * The builder attaches `translationMap`, `translationLocale`, and
595
+ * `translationLanguageId` to the page data in design mode.
596
+ */
597
+ extractTranslationSidecar = () => {
598
+ const pageData = this.data;
599
+ if (pageData?.translationMap) {
600
+ this.translationMap = pageData.translationMap;
601
+ this.translationLocale = pageData.translationLocale || "";
602
+ this.translationLanguageId = pageData.translationLanguageId || "";
603
+ }
604
+ };
605
+ /**
606
+ * Set the translation sidecar data.
607
+ * Called by the studio bridge when translation data arrives or changes.
608
+ * Triggers a re-render of all items so translated snapshots are recalculated.
609
+ */
610
+ setTranslationSidecar = (translationMap, locale, languageId) => {
611
+ this.translationMap = translationMap;
612
+ this.translationLocale = locale;
613
+ this.translationLanguageId = languageId;
614
+ this.refreshAllItems();
615
+ };
616
+ /**
617
+ * Update a single translation entry for a specific item field.
618
+ * Used by the studio bridge when the user edits a translatable field.
619
+ */
620
+ updateTranslation = (itemId, key, originalValue, translatedValue) => {
621
+ if (!this.translationMap[itemId]) {
622
+ this.translationMap[itemId] = {};
623
+ }
624
+ this.translationMap[itemId] = {
625
+ ...this.translationMap[itemId],
626
+ [key]: { originalValue, translatedValue }
627
+ };
628
+ const instance = this.itemInstances.get(itemId);
629
+ if (instance) {
630
+ instance.triggerUpdate();
631
+ }
632
+ };
633
+ /**
634
+ * Collect all translation changes across all weaverse instances.
635
+ * Used by the save flow to persist translation edits.
636
+ */
637
+ getTranslationChanges = () => {
638
+ const entries = [];
639
+ const languageId = this.translationLanguageId;
640
+ if (!(this.translationLocale && languageId)) {
641
+ return void 0;
642
+ }
643
+ for (const [itemId, fields] of Object.entries(this.translationMap)) {
644
+ for (const [key, entry] of Object.entries(fields)) {
645
+ entries.push({
646
+ itemId,
647
+ key: `data.${key}`,
648
+ originalValue: entry.originalValue,
649
+ translatedValue: entry.translatedValue
650
+ });
651
+ }
652
+ }
653
+ if (entries.length === 0) {
654
+ return void 0;
655
+ }
656
+ return { languageId, entries };
657
+ };
658
+ /**
659
+ * Override setProjectData to re-extract translation sidecar from new page data.
660
+ */
661
+ setProjectData = (data) => {
662
+ this.data = data;
663
+ this.extractTranslationSidecar();
664
+ this.initProject();
665
+ };
550
666
  };
551
667
  function createWeaverseInstance(params) {
552
668
  if (react.isBrowser) {
@@ -1097,7 +1213,7 @@ var WeaverseClient = class {
1097
1213
  type: typeof result,
1098
1214
  isString: typeof result === "string",
1099
1215
  length: typeof result === "string" ? result.length : "N/A",
1100
- preview: typeof result === "string" ? `${result.substring(0, 50)}...` : String(result)
1216
+ preview: typeof result === "string" ? `${result.slice(0, 50)}...` : String(result)
1101
1217
  }
1102
1218
  );
1103
1219
  result = { theme: defaultThemeSettings };