@shipeasy/sdk 2.1.5 → 2.1.7

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.
@@ -792,7 +792,8 @@ function isEditLabelsMode() {
792
792
  if (typeof window !== "undefined") {
793
793
  return !!window.__SE_BOOTSTRAP?.editLabels || new URLSearchParams(location.search).has("se_edit_labels");
794
794
  }
795
- return globalThis[_EDIT_MODE_SSR_SYM]?.() ?? false;
795
+ const val = globalThis[_EDIT_MODE_SSR_SYM];
796
+ return typeof val === "boolean" ? val : typeof val === "function" ? val() : false;
796
797
  }
797
798
  function interpolate(raw, variables) {
798
799
  if (!variables) return raw;
@@ -749,7 +749,8 @@ function isEditLabelsMode() {
749
749
  if (typeof window !== "undefined") {
750
750
  return !!window.__SE_BOOTSTRAP?.editLabels || new URLSearchParams(location.search).has("se_edit_labels");
751
751
  }
752
- return globalThis[_EDIT_MODE_SSR_SYM]?.() ?? false;
752
+ const val = globalThis[_EDIT_MODE_SSR_SYM];
753
+ return typeof val === "boolean" ? val : typeof val === "function" ? val() : false;
753
754
  }
754
755
  function interpolate(raw, variables) {
755
756
  if (!variables) return raw;
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/server/index.ts
@@ -356,9 +366,10 @@ var FlagsClient = class {
356
366
  var _I18N_SSR_SYM = /* @__PURE__ */ Symbol.for("@shipeasy/sdk:ssr-i18n");
357
367
  var _EDIT_MODE_SSR_SYM = /* @__PURE__ */ Symbol.for("@shipeasy/sdk:ssr-edit-mode");
358
368
  var _i18nALS = new import_node_async_hooks.AsyncLocalStorage();
359
- var _editModeALS = new import_node_async_hooks.AsyncLocalStorage();
360
369
  globalThis[_I18N_SSR_SYM] = () => _i18nALS.getStore() ?? null;
361
- globalThis[_EDIT_MODE_SSR_SYM] = () => _editModeALS.getStore() ?? false;
370
+ if (globalThis[_EDIT_MODE_SSR_SYM] === void 0) {
371
+ globalThis[_EDIT_MODE_SSR_SYM] = false;
372
+ }
362
373
  var i18n = {
363
374
  /**
364
375
  * Fetch translation labels for the current request and store them in an
@@ -441,10 +452,20 @@ async function shipeasy(opts) {
441
452
  const clientKey = opts.clientKey ?? opts.apiKey ?? "";
442
453
  const profile = opts.i18nDefaultProfile ?? "en:prod";
443
454
  flags.configure({ apiKey });
444
- const editLabels = opts.urlOverrides ? new URLSearchParams(opts.urlOverrides).has("se_edit_labels") : false;
445
- _editModeALS.enterWith(editLabels);
455
+ let resolvedUrlOverrides = opts.urlOverrides;
456
+ if (!resolvedUrlOverrides) {
457
+ try {
458
+ const { headers } = await import("next/headers");
459
+ const h = await Promise.resolve(headers());
460
+ const search = h.get("x-se-search") ?? "";
461
+ if (search) resolvedUrlOverrides = search;
462
+ } catch {
463
+ }
464
+ }
465
+ const editLabels = resolvedUrlOverrides ? new URLSearchParams(resolvedUrlOverrides).has("se_edit_labels") : false;
466
+ globalThis[_EDIT_MODE_SSR_SYM] = editLabels;
446
467
  await Promise.allSettled([flags.initOnce(), i18n.init(clientKey, profile)]);
447
- const bootstrap = flags.evaluate(opts.user ?? {}, opts.urlOverrides);
468
+ const bootstrap = flags.evaluate(opts.user ?? {}, resolvedUrlOverrides);
448
469
  const i18nData = i18n.getForRequest();
449
470
  return {
450
471
  flags: bootstrap.flags,
@@ -323,9 +323,10 @@ var FlagsClient = class {
323
323
  var _I18N_SSR_SYM = /* @__PURE__ */ Symbol.for("@shipeasy/sdk:ssr-i18n");
324
324
  var _EDIT_MODE_SSR_SYM = /* @__PURE__ */ Symbol.for("@shipeasy/sdk:ssr-edit-mode");
325
325
  var _i18nALS = new AsyncLocalStorage();
326
- var _editModeALS = new AsyncLocalStorage();
327
326
  globalThis[_I18N_SSR_SYM] = () => _i18nALS.getStore() ?? null;
328
- globalThis[_EDIT_MODE_SSR_SYM] = () => _editModeALS.getStore() ?? false;
327
+ if (globalThis[_EDIT_MODE_SSR_SYM] === void 0) {
328
+ globalThis[_EDIT_MODE_SSR_SYM] = false;
329
+ }
329
330
  var i18n = {
330
331
  /**
331
332
  * Fetch translation labels for the current request and store them in an
@@ -408,10 +409,20 @@ async function shipeasy(opts) {
408
409
  const clientKey = opts.clientKey ?? opts.apiKey ?? "";
409
410
  const profile = opts.i18nDefaultProfile ?? "en:prod";
410
411
  flags.configure({ apiKey });
411
- const editLabels = opts.urlOverrides ? new URLSearchParams(opts.urlOverrides).has("se_edit_labels") : false;
412
- _editModeALS.enterWith(editLabels);
412
+ let resolvedUrlOverrides = opts.urlOverrides;
413
+ if (!resolvedUrlOverrides) {
414
+ try {
415
+ const { headers } = await import("next/headers");
416
+ const h = await Promise.resolve(headers());
417
+ const search = h.get("x-se-search") ?? "";
418
+ if (search) resolvedUrlOverrides = search;
419
+ } catch {
420
+ }
421
+ }
422
+ const editLabels = resolvedUrlOverrides ? new URLSearchParams(resolvedUrlOverrides).has("se_edit_labels") : false;
423
+ globalThis[_EDIT_MODE_SSR_SYM] = editLabels;
413
424
  await Promise.allSettled([flags.initOnce(), i18n.init(clientKey, profile)]);
414
- const bootstrap = flags.evaluate(opts.user ?? {}, opts.urlOverrides);
425
+ const bootstrap = flags.evaluate(opts.user ?? {}, resolvedUrlOverrides);
415
426
  const i18nData = i18n.getForRequest();
416
427
  return {
417
428
  flags: bootstrap.flags,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shipeasy/sdk",
3
- "version": "2.1.5",
3
+ "version": "2.1.7",
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",