@nimpl/getters 2.1.1 → 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/README.md +9 -9
- package/get-app-params.js +3 -4
- package/get-app-pathname.js +4 -1
- package/get-params.js +4 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
Implementation of server getters in React Server Components without switching to SSR in Next.js
|
|
6
6
|
|
|
7
|
-
Before using the library, read the [Possible Issues](https://nimpl.
|
|
7
|
+
Before using the library, read the [Possible Issues](https://nimpl.dev/docs/server-getters#possible-issues)
|
|
8
8
|
|
|
9
|
-
Visit https://nimpl.
|
|
9
|
+
Visit https://nimpl.dev/docs/server-getters to view the full documentation.
|
|
10
10
|
|
|
11
11
|
Use `@nimpl/getters 2.x` for Next.js v15. For earlier versions of Next.js use `@nimpl/getters 1.x`.
|
|
12
12
|
|
|
@@ -26,14 +26,14 @@ yarn add @nimpl/getters
|
|
|
26
26
|
|
|
27
27
|
## Current Getters
|
|
28
28
|
|
|
29
|
-
- [get-pathname](https://nimpl.
|
|
30
|
-
- [get-app-pathname](https://nimpl.
|
|
31
|
-
- [get-params](https://nimpl.
|
|
32
|
-
- [get-app-params](https://nimpl.
|
|
33
|
-
- [get-page-config](https://nimpl.
|
|
34
|
-
- [get-search-params](https://nimpl.
|
|
29
|
+
- [get-pathname](https://nimpl.dev/docs/server-getters#get-pathname)
|
|
30
|
+
- [get-app-pathname](https://nimpl.dev/docs/server-getters#get-app-pathname)
|
|
31
|
+
- [get-params](https://nimpl.dev/docs/server-getters#get-params)
|
|
32
|
+
- [get-app-params](https://nimpl.dev/docs/server-getters#get-app-params)
|
|
33
|
+
- [get-page-config](https://nimpl.dev/docs/server-getters#get-page-config)
|
|
34
|
+
- [get-search-params](https://nimpl.dev/docs/server-getters#get-search-params) (_deprecated_)
|
|
35
35
|
|
|
36
|
-
> _`create-server-context` and `get-server-context` were moved to a separate package - [@nimpl/context](https://nimpl.
|
|
36
|
+
> _`create-server-context` and `get-server-context` were moved to a separate package - [@nimpl/context](https://nimpl.dev/docs/context)_
|
|
37
37
|
|
|
38
38
|
## Stability
|
|
39
39
|
|
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
|
-
|
|
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) {
|
package/get-app-pathname.js
CHANGED
|
@@ -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
|
|
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
|
|
17
|
+
if (!pageConfigurationStore)
|
|
18
18
|
return {};
|
|
19
19
|
const { route } = pageConfigurationStore;
|
|
20
20
|
const pagePath = route;
|
|
21
|
-
const urlPathname = pageStore
|
|
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.
|
|
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
|
+
}
|