@sanity-labs/sdk-addon-dataset-runtime 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sanity Labs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # `@sanity-labs/sdk-addon-dataset-runtime`
2
+
3
+ This package provides the narrow runtime values that `@sanity-labs/sdk-comments` and
4
+ `@sanity-labs/sdk-tasks` both need:
5
+
6
+ - `addonDataset`
7
+ - `contentDataset?`
8
+ - `projectId`
9
+ - `workspaceId?`
10
+ - `workspaceTitle?`
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ pnpm add @sanity-labs/sdk-addon-dataset-runtime react react-dom
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ ```tsx
21
+ import { AddonDatasetRuntimeProvider } from "@sanity-labs/sdk-addon-dataset-runtime";
22
+
23
+ <AddonDatasetRuntimeProvider
24
+ addonDataset="production-comments"
25
+ contentDataset="production"
26
+ projectId="myProjectId"
27
+ workspaceId="news_and_media"
28
+ workspaceTitle="News and Media"
29
+ >
30
+ <App />
31
+ </AddonDatasetRuntimeProvider>;
32
+ ```
33
+
34
+ Use this provider when multiple components should share the same addon runtime
35
+ identity. Feature hooks in `@sanity-labs/sdk-comments` and `@sanity-labs/sdk-tasks`
36
+ also support direct configuration, so this package is recommended shared
37
+ infrastructure rather than a mandatory prerequisite for every integration.
38
+
39
+ ## Primary Exports
40
+
41
+ - `AddonDatasetRuntimeProvider`
42
+ - `useAddonDatasetRuntime()`
43
+ - `useOptionalAddonDatasetRuntime()`
44
+ - `AddonDatasetRuntimeValue`
45
+
46
+ ## What Is Not Included
47
+
48
+ This package intentionally does not ship:
49
+
50
+ - task caches
51
+ - optimistic feature state
52
+ - task mutation helpers
53
+ - comment mutation helpers
54
+
55
+ Feature behavior lives in `@sanity-labs/sdk-comments` and `@sanity-labs/sdk-tasks`.
@@ -0,0 +1,15 @@
1
+ import { type ReactNode } from 'react';
2
+ export interface AddonDatasetRuntimeValue {
3
+ addonDataset: string;
4
+ contentDataset?: string;
5
+ projectId: string;
6
+ workspaceId?: string;
7
+ workspaceTitle?: string;
8
+ }
9
+ interface AddonDatasetRuntimeProviderProps extends AddonDatasetRuntimeValue {
10
+ children: ReactNode;
11
+ }
12
+ export declare function AddonDatasetRuntimeProvider({ addonDataset, children, contentDataset, projectId, workspaceId, workspaceTitle, }: AddonDatasetRuntimeProviderProps): import("react/jsx-runtime").JSX.Element;
13
+ export declare function useAddonDatasetRuntime(): AddonDatasetRuntimeValue;
14
+ export declare function useOptionalAddonDatasetRuntime(): AddonDatasetRuntimeValue | null;
15
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext, useMemo } from 'react';
3
+ const AddonDatasetRuntimeContext = createContext(null);
4
+ export function AddonDatasetRuntimeProvider({ addonDataset, children, contentDataset, projectId, workspaceId, workspaceTitle, }) {
5
+ const value = useMemo(() => ({
6
+ addonDataset,
7
+ contentDataset,
8
+ projectId,
9
+ workspaceId,
10
+ workspaceTitle,
11
+ }), [addonDataset, contentDataset, projectId, workspaceId, workspaceTitle]);
12
+ return (_jsx(AddonDatasetRuntimeContext.Provider, { value: value, children: children }));
13
+ }
14
+ export function useAddonDatasetRuntime() {
15
+ const runtime = useContext(AddonDatasetRuntimeContext);
16
+ if (!runtime) {
17
+ throw new Error('useAddonDatasetRuntime must be used inside <AddonDatasetRuntimeProvider>');
18
+ }
19
+ return runtime;
20
+ }
21
+ export function useOptionalAddonDatasetRuntime() {
22
+ return useContext(AddonDatasetRuntimeContext);
23
+ }
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@sanity-labs/sdk-addon-dataset-runtime",
3
+ "version": "1.0.0",
4
+ "private": false,
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "description": "Shared addon dataset runtime context for Sanity Labs SDK feature packages.",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/sanity-labs/sdk-addon-dataset-runtime.git"
11
+ },
12
+ "homepage": "https://github.com/sanity-labs/sdk-addon-dataset-runtime#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/sanity-labs/sdk-addon-dataset-runtime/issues"
15
+ },
16
+ "keywords": [
17
+ "sanity",
18
+ "sanity-labs",
19
+ "runtime",
20
+ "react"
21
+ ],
22
+ "exports": {
23
+ ".": {
24
+ "types": "./dist/index.d.ts",
25
+ "import": "./dist/index.js",
26
+ "default": "./dist/index.js"
27
+ },
28
+ "./package.json": "./package.json"
29
+ },
30
+ "main": "./dist/index.js",
31
+ "types": "./dist/index.d.ts",
32
+ "files": [
33
+ "dist",
34
+ "README.md"
35
+ ],
36
+ "scripts": {
37
+ "build": "tsc -p tsconfig.build.json",
38
+ "typecheck": "tsc --noEmit -p tsconfig.json"
39
+ },
40
+ "peerDependencies": {
41
+ "react": "^18.0.0 || ^19.0.0",
42
+ "react-dom": "^18.0.0 || ^19.0.0"
43
+ },
44
+ "packageManager": "pnpm@10.32.1",
45
+ "devDependencies": {
46
+ "@types/react": "^19.2.14",
47
+ "@types/react-dom": "^19.2.3",
48
+ "typescript": "^6.0.2"
49
+ }
50
+ }