@checkstack/theme-common 0.0.2
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/CHANGELOG.md +23 -0
- package/package.json +26 -0
- package/src/index.ts +2 -0
- package/src/plugin-metadata.ts +9 -0
- package/src/rpc-contract.ts +43 -0
- package/tsconfig.json +6 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# @checkstack/theme-common
|
|
2
|
+
|
|
3
|
+
## 0.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d20d274: Initial release of all @checkstack packages. Rebranded from Checkmate to Checkstack with new npm organization @checkstack and domain checkstack.dev.
|
|
8
|
+
- Updated dependencies [d20d274]
|
|
9
|
+
- @checkstack/common@0.0.2
|
|
10
|
+
|
|
11
|
+
## 0.0.3
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [a65e002]
|
|
16
|
+
- @checkstack/common@0.2.0
|
|
17
|
+
|
|
18
|
+
## 0.0.2
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [ffc28f6]
|
|
23
|
+
- @checkstack/common@0.1.0
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@checkstack/theme-common",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": {
|
|
7
|
+
"types": "./src/index.ts",
|
|
8
|
+
"import": "./src/index.ts"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@checkstack/common": "workspace:*",
|
|
13
|
+
"@orpc/contract": "^1.13.2",
|
|
14
|
+
"zod": "^4.0.0"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@checkstack/tsconfig": "workspace:*",
|
|
18
|
+
"typescript": "^5.7.2",
|
|
19
|
+
"@checkstack/scripts": "workspace:*"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"typecheck": "tsc --noEmit",
|
|
23
|
+
"lint": "bun run lint:code",
|
|
24
|
+
"lint:code": "eslint . --max-warnings 0"
|
|
25
|
+
}
|
|
26
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { definePluginMetadata } from "@checkstack/common";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Plugin metadata for the theme plugin.
|
|
5
|
+
* Exported from the common package so both backend and frontend can reference it.
|
|
6
|
+
*/
|
|
7
|
+
export const pluginMetadata = definePluginMetadata({
|
|
8
|
+
pluginId: "theme",
|
|
9
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { oc } from "@orpc/contract";
|
|
2
|
+
import {
|
|
3
|
+
createClientDefinition,
|
|
4
|
+
type ProcedureMetadata,
|
|
5
|
+
} from "@checkstack/common";
|
|
6
|
+
import { pluginMetadata } from "./plugin-metadata";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
|
|
9
|
+
// Theme type - matches ThemeProvider's Theme type
|
|
10
|
+
export const ThemeSchema = z.enum(["light", "dark", "system"]);
|
|
11
|
+
export type Theme = z.infer<typeof ThemeSchema>;
|
|
12
|
+
|
|
13
|
+
// Base builder with full metadata support
|
|
14
|
+
const _base = oc.$meta<ProcedureMetadata>({});
|
|
15
|
+
|
|
16
|
+
// Theme RPC Contract
|
|
17
|
+
export const themeContract = {
|
|
18
|
+
// Get current user's theme preference
|
|
19
|
+
// User-only - each user reads their own theme
|
|
20
|
+
getTheme: _base.meta({ userType: "user" }).output(
|
|
21
|
+
z.object({
|
|
22
|
+
theme: ThemeSchema,
|
|
23
|
+
})
|
|
24
|
+
),
|
|
25
|
+
|
|
26
|
+
// Set current user's theme preference
|
|
27
|
+
// User-only - each user sets their own theme
|
|
28
|
+
setTheme: _base
|
|
29
|
+
.meta({ userType: "user" })
|
|
30
|
+
.input(
|
|
31
|
+
z.object({
|
|
32
|
+
theme: ThemeSchema,
|
|
33
|
+
})
|
|
34
|
+
)
|
|
35
|
+
.output(z.void()),
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// Export contract type
|
|
39
|
+
export type ThemeContract = typeof themeContract;
|
|
40
|
+
|
|
41
|
+
// Export client definition for type-safe forPlugin usage
|
|
42
|
+
// Use: const client = rpcApi.forPlugin(ThemeApi);
|
|
43
|
+
export const ThemeApi = createClientDefinition(themeContract, pluginMetadata);
|