@shipeasy/sdk 2.1.10 → 2.1.11

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.
@@ -185,7 +185,7 @@ declare const LABEL_MARKER_START = "\uFFF9";
185
185
  declare const LABEL_MARKER_SEP = "\uFFFA";
186
186
  declare const LABEL_MARKER_END = "\uFFFB";
187
187
  declare const LABEL_MARKER_RE: RegExp;
188
- declare function encodeLabelMarker(key: string, value: string): string;
188
+ declare function encodeLabelMarker(key: string, value: string, variables?: I18nVariables): string;
189
189
  interface LabelAttrs {
190
190
  "data-label": string;
191
191
  "data-variables"?: string;
@@ -185,7 +185,7 @@ declare const LABEL_MARKER_START = "\uFFF9";
185
185
  declare const LABEL_MARKER_SEP = "\uFFFA";
186
186
  declare const LABEL_MARKER_END = "\uFFFB";
187
187
  declare const LABEL_MARKER_RE: RegExp;
188
- declare function encodeLabelMarker(key: string, value: string): string;
188
+ declare function encodeLabelMarker(key: string, value: string, variables?: I18nVariables): string;
189
189
  interface LabelAttrs {
190
190
  "data-label": string;
191
191
  "data-variables"?: string;
@@ -774,9 +774,10 @@ var flags = {
774
774
  var LABEL_MARKER_START = "\uFFF9";
775
775
  var LABEL_MARKER_SEP = "\uFFFA";
776
776
  var LABEL_MARKER_END = "\uFFFB";
777
- var LABEL_MARKER_RE = /([^]+)([^]*)/g;
778
- function encodeLabelMarker(key, value) {
779
- return `${LABEL_MARKER_START}${key}${LABEL_MARKER_SEP}${value}${LABEL_MARKER_END}`;
777
+ var LABEL_MARKER_RE = /([^]+)([^]*)([^]*)/g;
778
+ function encodeLabelMarker(key, value, variables) {
779
+ const varsJson = variables && Object.keys(variables).length > 0 ? JSON.stringify(variables) : "";
780
+ return `${LABEL_MARKER_START}${key}${LABEL_MARKER_SEP}${varsJson}${LABEL_MARKER_SEP}${value}${LABEL_MARKER_END}`;
780
781
  }
781
782
  function labelAttrs(key, variables, desc) {
782
783
  const attrs = { "data-label": key };
@@ -885,8 +886,19 @@ var i18n = {
885
886
  variables = fallbackOrVars;
886
887
  }
887
888
  const resolved = _resolveTranslation(key, variables);
888
- if (resolved !== void 0) return resolved;
889
- if (fallback !== void 0) return interpolate(fallback, variables);
889
+ if (resolved !== void 0) {
890
+ if (typeof window === "undefined" && isEditLabelsMode()) {
891
+ return encodeLabelMarker(key, resolved, variables);
892
+ }
893
+ return resolved;
894
+ }
895
+ if (fallback !== void 0) {
896
+ const text = interpolate(fallback, variables);
897
+ if (typeof window === "undefined" && isEditLabelsMode()) {
898
+ return encodeLabelMarker(key, text, variables);
899
+ }
900
+ return text;
901
+ }
890
902
  return key;
891
903
  },
892
904
  /**
@@ -929,7 +941,7 @@ var i18n = {
929
941
  if (isEditLabelsMode()) {
930
942
  const resolved = _resolveTranslation(key, variables);
931
943
  const text = resolved ?? interpolate(fallback, variables);
932
- return encodeLabelMarker(key, text);
944
+ return encodeLabelMarker(key, text, variables);
933
945
  }
934
946
  return this.t(key, fallback, variables);
935
947
  },
@@ -731,9 +731,10 @@ var flags = {
731
731
  var LABEL_MARKER_START = "\uFFF9";
732
732
  var LABEL_MARKER_SEP = "\uFFFA";
733
733
  var LABEL_MARKER_END = "\uFFFB";
734
- var LABEL_MARKER_RE = /([^]+)([^]*)/g;
735
- function encodeLabelMarker(key, value) {
736
- return `${LABEL_MARKER_START}${key}${LABEL_MARKER_SEP}${value}${LABEL_MARKER_END}`;
734
+ var LABEL_MARKER_RE = /([^]+)([^]*)([^]*)/g;
735
+ function encodeLabelMarker(key, value, variables) {
736
+ const varsJson = variables && Object.keys(variables).length > 0 ? JSON.stringify(variables) : "";
737
+ return `${LABEL_MARKER_START}${key}${LABEL_MARKER_SEP}${varsJson}${LABEL_MARKER_SEP}${value}${LABEL_MARKER_END}`;
737
738
  }
738
739
  function labelAttrs(key, variables, desc) {
739
740
  const attrs = { "data-label": key };
@@ -842,8 +843,19 @@ var i18n = {
842
843
  variables = fallbackOrVars;
843
844
  }
844
845
  const resolved = _resolveTranslation(key, variables);
845
- if (resolved !== void 0) return resolved;
846
- if (fallback !== void 0) return interpolate(fallback, variables);
846
+ if (resolved !== void 0) {
847
+ if (typeof window === "undefined" && isEditLabelsMode()) {
848
+ return encodeLabelMarker(key, resolved, variables);
849
+ }
850
+ return resolved;
851
+ }
852
+ if (fallback !== void 0) {
853
+ const text = interpolate(fallback, variables);
854
+ if (typeof window === "undefined" && isEditLabelsMode()) {
855
+ return encodeLabelMarker(key, text, variables);
856
+ }
857
+ return text;
858
+ }
847
859
  return key;
848
860
  },
849
861
  /**
@@ -886,7 +898,7 @@ var i18n = {
886
898
  if (isEditLabelsMode()) {
887
899
  const resolved = _resolveTranslation(key, variables);
888
900
  const text = resolved ?? interpolate(fallback, variables);
889
- return encodeLabelMarker(key, text);
901
+ return encodeLabelMarker(key, text, variables);
890
902
  }
891
903
  return this.t(key, fallback, variables);
892
904
  },
@@ -532,7 +532,7 @@ function getBootstrapHtml(bootstrap, i18nData, opts) {
532
532
  if (i18nData) payload.i18n = i18nData;
533
533
  if (opts.editLabels) payload.editLabels = true;
534
534
  parts.push(
535
- `(function(){if(!new URLSearchParams(location.search).has('se_edit_labels'))return;var R;function P(v){if(!v||typeof v.t!=='function'||v.__sePatched)return;var O=v.t.bind(v);v.__sePatched=true;window._sei18n_t=O;v.t=function(k,vars){var r=O(k,vars);return r===k?k:'\\uFFF9'+k+'\\uFFFA'+r+'\\uFFFB';};}Object.defineProperty(window,'i18n',{configurable:true,get:function(){return R;},set:function(v){P(v);R=v;}});})();`
535
+ `(function(){if(!new URLSearchParams(location.search).has('se_edit_labels'))return;var R;function P(v){if(!v||typeof v.t!=='function'||v.__sePatched)return;var O=v.t.bind(v);v.__sePatched=true;window._sei18n_t=O;v.t=function(k,vars){var r=O(k,vars);if(r===k)return k;var V='';try{if(vars&&typeof vars==='object'){var hasKey=false;for(var _k in vars){hasKey=true;break;}if(hasKey)V=JSON.stringify(vars);}}catch(_){V='';}return '\\uFFF9'+k+'\\uFFFA'+V+'\\uFFFA'+r+'\\uFFFB';};}Object.defineProperty(window,'i18n',{configurable:true,get:function(){return R;},set:function(v){P(v);R=v;}});})();`
536
536
  );
537
537
  parts.push(`window.__SE_BOOTSTRAP=${JSON.stringify(payload)};`);
538
538
  if (i18nData?.strings && Object.keys(i18nData.strings).length > 0) {
@@ -489,7 +489,7 @@ function getBootstrapHtml(bootstrap, i18nData, opts) {
489
489
  if (i18nData) payload.i18n = i18nData;
490
490
  if (opts.editLabels) payload.editLabels = true;
491
491
  parts.push(
492
- `(function(){if(!new URLSearchParams(location.search).has('se_edit_labels'))return;var R;function P(v){if(!v||typeof v.t!=='function'||v.__sePatched)return;var O=v.t.bind(v);v.__sePatched=true;window._sei18n_t=O;v.t=function(k,vars){var r=O(k,vars);return r===k?k:'\\uFFF9'+k+'\\uFFFA'+r+'\\uFFFB';};}Object.defineProperty(window,'i18n',{configurable:true,get:function(){return R;},set:function(v){P(v);R=v;}});})();`
492
+ `(function(){if(!new URLSearchParams(location.search).has('se_edit_labels'))return;var R;function P(v){if(!v||typeof v.t!=='function'||v.__sePatched)return;var O=v.t.bind(v);v.__sePatched=true;window._sei18n_t=O;v.t=function(k,vars){var r=O(k,vars);if(r===k)return k;var V='';try{if(vars&&typeof vars==='object'){var hasKey=false;for(var _k in vars){hasKey=true;break;}if(hasKey)V=JSON.stringify(vars);}}catch(_){V='';}return '\\uFFF9'+k+'\\uFFFA'+V+'\\uFFFA'+r+'\\uFFFB';};}Object.defineProperty(window,'i18n',{configurable:true,get:function(){return R;},set:function(v){P(v);R=v;}});})();`
493
493
  );
494
494
  parts.push(`window.__SE_BOOTSTRAP=${JSON.stringify(payload)};`);
495
495
  if (i18nData?.strings && Object.keys(i18nData.strings).length > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shipeasy/sdk",
3
- "version": "2.1.10",
3
+ "version": "2.1.11",
4
4
  "description": "Shipeasy SDK — feature gates, runtime configs, experiments, and metrics for the Shipeasy hosted service.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "homepage": "https://shipeasy.ai",