@nimpl/getters 2.1.2 → 2.2.0-canary.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/get-app-params.js CHANGED
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getAppParams = void 0;
4
4
  const work_async_storage_external_1 = require("next/dist/server/app-render/work-async-storage.external");
5
- const work_unit_async_storage_external_1 = require("next/dist/server/app-render/work-unit-async-storage.external");
6
5
  const server_getter_in_client_component_error_1 = require("./server-getter-in-client-component-error");
7
6
  const utils_1 = require("./utils");
8
7
  const get_app_pathname_1 = require("./get-app-pathname");
@@ -13,14 +12,14 @@ const getAppParams = (options = {}) => {
13
12
  return {};
14
13
  const { ignoreDifferenceError, pagePaths, pathname } = options;
15
14
  const pageConfigurationStore = work_async_storage_external_1.workAsyncStorage.getStore();
16
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
- const pageStore = work_unit_async_storage_external_1.workUnitAsyncStorage.getStore();
18
- if (!pageConfigurationStore || !pageStore?.url?.pathname)
15
+ if (!pageConfigurationStore)
19
16
  return {};
20
17
  const { route } = pageConfigurationStore;
21
18
  const pagePath = route;
22
19
  const urlPathname = (0, get_app_pathname_1.getAppPathname)();
23
20
  const targetUrlPathname = pathname || urlPathname;
21
+ if (!targetUrlPathname)
22
+ return {};
24
23
  let isInvalid = false;
25
24
  try {
26
25
  if (pagePaths) {
@@ -7,7 +7,10 @@ function getAppPathname() {
7
7
  (0, server_getter_in_client_component_error_1.serverGetterInClientComponentError)("getAppPathname");
8
8
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
9
  const pageStore = work_unit_async_storage_external_1.workUnitAsyncStorage.getStore();
10
- const pageTags = pageStore.implicitTags.filter((tag) => tag.startsWith("_N_T_/"));
10
+ const tags = (Array.isArray(pageStore.implicitTags.tags) && pageStore.implicitTags.tags) ||
11
+ (Array.isArray(pageStore.implicitTags) && pageStore.implicitTags) ||
12
+ [];
13
+ const pageTags = tags.filter((tag) => tag.startsWith("_N_T_/"));
11
14
  const pathnameTag = pageTags[pageTags.length - 1];
12
15
  return pathnameTag.substring(5);
13
16
  }
package/get-params.js CHANGED
@@ -14,12 +14,14 @@ const getParams = (options = {}) => {
14
14
  const pageConfigurationStore = work_async_storage_external_1.workAsyncStorage.getStore();
15
15
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
16
  const pageStore = work_unit_async_storage_external_1.workUnitAsyncStorage.getStore();
17
- if (!pageConfigurationStore || !pageStore?.url?.pathname)
17
+ if (!pageConfigurationStore)
18
18
  return {};
19
19
  const { route } = pageConfigurationStore;
20
20
  const pagePath = route;
21
- const urlPathname = pageStore.url.pathname;
21
+ const urlPathname = pageStore?.url?.pathname;
22
22
  const targetUrlPathname = pathname || urlPathname;
23
+ if (!targetUrlPathname)
24
+ return {};
23
25
  let isInvalid = false;
24
26
  try {
25
27
  if (pagePaths) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nimpl/getters",
3
- "version": "2.1.2",
3
+ "version": "2.2.0-canary.0",
4
4
  "description": "Implementation of server getters in React Server Components without switching to SSR in next.js",
5
5
  "files": [
6
6
  "**/*.js",
@@ -44,4 +44,4 @@
44
44
  "react-dom": ">= 18.2.0",
45
45
  "next": ">= 14.0.0"
46
46
  }
47
- }
47
+ }