@nimpl/getters 1.3.4-canary.0 → 1.4.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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  (Former [next-impl-getters](https://www.npmjs.com/package/next-impl-getters))
4
4
 
5
- Implementation of server getters and server contexts in React Server Components without switching to SSR
5
+ Implementation of server getters in React Server Components without switching to SSR in next.js
6
6
 
7
7
  Before using the library, read the [Possible Issues](https://nimpl.tech/getters/possible-issues)
8
8
 
@@ -23,10 +23,9 @@ yarn add @nimpl/getters
23
23
  ## Current Getters
24
24
 
25
25
  * [get-pathname](https://nimpl.tech/getters/current-getters/get-pathname)
26
- * [server-contexts](https://nimpl.tech/getters/current-getters/server-contexts)
27
26
  * [get-page-config](https://nimpl.tech/getters/current-getters/get-page-config)
28
27
  * [get-params](https://nimpl.tech/getters/current-getters/get-params)
29
- * [get-search-params](https://nimpl.tech/getters/current-getters/get-search-params)
28
+ * [get-search-params](https://nimpl.tech/getters/current-getters/get-search-params) (*deprecated*)
30
29
 
31
30
  ## Stability
32
31
 
@@ -34,10 +33,6 @@ All getters are covered with tests. Tests are run on every release and every 6 h
34
33
 
35
34
  In this way, you can be sure not only of the stability of the code, but also that if there is a breaking change in `Next.js`, this will immediately become known. *Even before the release of a stable version of `Next.js`.*
36
35
 
37
- ## Examples
38
-
39
- You can see examples in the [directory](https://github.com/vordgi/nimpl-getters/tree/main/examples) of the repository.
40
-
41
36
  ## Additional
42
37
 
43
38
  Please consider giving a star if you like it, it will help promote the implementation in the eyes of the next.js team.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nimpl/getters",
3
- "version": "1.3.4-canary.0",
4
- "description": "Implementation of server getters and server contexts in React Server Components without switching to SSR",
3
+ "version": "1.4.0-canary.0",
4
+ "description": "Implementation of server getters in React Server Components without switching to SSR in next.js",
5
5
  "files": [
6
6
  "**/*.js",
7
7
  "**/*.d.ts"
@@ -18,8 +18,7 @@
18
18
  "getters",
19
19
  "implementation",
20
20
  "get-params",
21
- "rsc",
22
- "server context"
21
+ "rsc"
23
22
  ],
24
23
  "repository": {
25
24
  "type": "git",
@@ -1,3 +0,0 @@
1
- import type { ServerContext } from "./types";
2
- declare function createServerContext<T>(defaultValue?: T): ServerContext<T>;
3
- export default createServerContext;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const async_hooks_1 = require("async_hooks");
7
- const server_getter_in_client_component_error_1 = require("./server-getter-in-client-component-error");
8
- const react_1 = __importDefault(require("react"));
9
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
- const Enter = ({ storage, value }) => {
11
- storage.enterWith({ value });
12
- return react_1.default.createElement(react_1.default.Fragment, null);
13
- };
14
- function createServerContext(defaultValue) {
15
- (0, server_getter_in_client_component_error_1.serverGetterInClientComponentError)("createServerContext");
16
- const storage = new async_hooks_1.AsyncLocalStorage();
17
- return {
18
- Provider: async ({ children, value }) => {
19
- return (react_1.default.createElement(react_1.default.Fragment, null,
20
- react_1.default.createElement(Enter, { storage: storage, value: value }),
21
- children));
22
- },
23
- Consumer: ({ children }) => {
24
- const store = storage.getStore();
25
- return children(store ? store.value : defaultValue);
26
- },
27
- _storage: storage,
28
- _defaultValue: defaultValue,
29
- };
30
- }
31
- exports.default = createServerContext;
@@ -1,3 +0,0 @@
1
- import type { ServerContext } from "./types";
2
- declare function getServerContext<T>({ _storage, _defaultValue }: ServerContext<T>): T | undefined;
3
- export default getServerContext;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const server_getter_in_client_component_error_1 = require("./server-getter-in-client-component-error");
4
- function getServerContext({ _storage, _defaultValue }) {
5
- (0, server_getter_in_client_component_error_1.serverGetterInClientComponentError)("getServerContext");
6
- const store = _storage.getStore();
7
- if (!store)
8
- return _defaultValue;
9
- return store.value;
10
- }
11
- exports.default = getServerContext;
package/types.d.ts DELETED
@@ -1,16 +0,0 @@
1
- /// <reference types="react" />
2
- /// <reference types="node" />
3
- import type { AsyncLocalStorage } from "async_hooks";
4
- export type ServerContext<T> = {
5
- Provider: ({ children, value }: {
6
- children: React.ReactNode;
7
- value: T;
8
- }) => React.ReactNode;
9
- Consumer: ({ children }: {
10
- children: (context: T | undefined) => React.ReactNode;
11
- }) => React.ReactNode;
12
- _storage: AsyncLocalStorage<{
13
- value: T;
14
- }>;
15
- _defaultValue: T | undefined;
16
- };
package/types.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });