@ops-ai/react-router-toggly 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/CHANGELOG.md +17 -0
- package/LICENSE +21 -0
- package/README.md +107 -0
- package/dist/client.cjs +832 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.cts +603 -0
- package/dist/client.d.ts +603 -0
- package/dist/client.js +787 -0
- package/dist/client.js.map +1 -0
- package/dist/server.cjs +2324 -0
- package/dist/server.cjs.map +1 -0
- package/dist/server.d.cts +645 -0
- package/dist/server.d.ts +645 -0
- package/dist/server.js +2294 -0
- package/dist/server.js.map +1 -0
- package/dist/telemetry/grpc.cjs +159 -0
- package/dist/telemetry/grpc.cjs.map +1 -0
- package/dist/telemetry/grpc.d.cts +29 -0
- package/dist/telemetry/grpc.d.ts +29 -0
- package/dist/telemetry/grpc.js +149 -0
- package/dist/telemetry/grpc.js.map +1 -0
- package/package.json +107 -0
- package/proto/google/protobuf/timestamp.proto +17 -0
- package/proto/metrics.proto +54 -0
- package/proto/usage.proto +49 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Initial `@ops-ai/react-router-toggly` release for React Router 7/8 framework mode
|
|
8
|
+
- Folded Remix core/client/server into one package with `./client` and `./server` exports
|
|
9
|
+
- In-source core (eval, telemetry, types) — no dependency on `@ops-ai/remix-toggly-core`
|
|
10
|
+
- Peers: `react-router ^7 || ^8`, `react` / `react-dom ^18 || ^19`, optional `@react-router/node`
|
|
11
|
+
- Packed host coverage for RR7+React 18 and RR8+React 19.2.7+
|
|
12
|
+
|
|
13
|
+
### Migration
|
|
14
|
+
|
|
15
|
+
- `@ops-ai/remix-toggly-*` is deprecated. Use `@ops-ai/react-router-toggly` instead.
|
|
16
|
+
- Rename `RemixTogglyProvider` → `RouterTogglyProvider`
|
|
17
|
+
- Import from `@ops-ai/react-router-toggly/client` and `@ops-ai/react-router-toggly/server`
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-2026 opsAI LLC
|
|
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,107 @@
|
|
|
1
|
+
# @ops-ai/react-router-toggly
|
|
2
|
+
|
|
3
|
+
Toggly feature flags for **React Router 7/8 framework mode**. One package with
|
|
4
|
+
`./client` and `./server` entry points. Core evaluation and telemetry live
|
|
5
|
+
in-source (not published as a separate package).
|
|
6
|
+
|
|
7
|
+
> Migrating from `@ops-ai/remix-toggly-*`? Those packages are deprecated. Install
|
|
8
|
+
> `@ops-ai/react-router-toggly` and import from `/client` and `/server`.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @ops-ai/react-router-toggly react-router react react-dom
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Peers: `react-router ^7 || ^8`, `react` / `react-dom ^18 || ^19`. Optional:
|
|
17
|
+
`@react-router/node`. Requires Node `>=18`.
|
|
18
|
+
|
|
19
|
+
## Quick start
|
|
20
|
+
|
|
21
|
+
### Server loader
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
// app/toggly.server.ts
|
|
25
|
+
import { createTogglyLoader } from '@ops-ai/react-router-toggly/server';
|
|
26
|
+
|
|
27
|
+
export const toggly = createTogglyLoader({
|
|
28
|
+
appKey: process.env.TOGGLY_APP_KEY!,
|
|
29
|
+
environment: process.env.TOGGLY_ENVIRONMENT ?? 'Production',
|
|
30
|
+
getIdentity: async (request) => {
|
|
31
|
+
// Resolve session identity for this request
|
|
32
|
+
return null;
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
// app/root.tsx
|
|
39
|
+
import { Outlet } from 'react-router';
|
|
40
|
+
import { RouterTogglyProvider } from '@ops-ai/react-router-toggly/client';
|
|
41
|
+
import { toggly } from './toggly.server';
|
|
42
|
+
|
|
43
|
+
export async function loader(args: { request: Request }) {
|
|
44
|
+
return toggly.getLoaderData(args);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default function App() {
|
|
48
|
+
return (
|
|
49
|
+
<RouterTogglyProvider routeId="root">
|
|
50
|
+
<Outlet />
|
|
51
|
+
</RouterTogglyProvider>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Client gates
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
import { Feature, useFeature } from '@ops-ai/react-router-toggly/client';
|
|
60
|
+
|
|
61
|
+
export default function Home() {
|
|
62
|
+
const beta = useFeature('Beta');
|
|
63
|
+
return (
|
|
64
|
+
<Feature feature="Checkout">
|
|
65
|
+
<Checkout />
|
|
66
|
+
{beta ? <BetaBanner /> : null}
|
|
67
|
+
</Feature>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Feature-gated actions
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
import { createFeatureGatedAction } from '@ops-ai/react-router-toggly/server';
|
|
76
|
+
|
|
77
|
+
export const action = createFeatureGatedAction(
|
|
78
|
+
{
|
|
79
|
+
appKey: process.env.TOGGLY_APP_KEY!,
|
|
80
|
+
requiredFeatures: 'AdminTools',
|
|
81
|
+
},
|
|
82
|
+
async () => ({ ok: true }),
|
|
83
|
+
);
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Exports
|
|
87
|
+
|
|
88
|
+
| Subpath | Purpose |
|
|
89
|
+
|---------|---------|
|
|
90
|
+
| `@ops-ai/react-router-toggly/client` | `RouterTogglyProvider`, hooks, `Feature` components |
|
|
91
|
+
| `@ops-ai/react-router-toggly/server` | Loaders, actions, `TogglyServerClient` |
|
|
92
|
+
|
|
93
|
+
Server-only modules (`ws`, gRPC telemetry) must not be imported from client code.
|
|
94
|
+
|
|
95
|
+
## Development
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
npm install
|
|
99
|
+
npm run build
|
|
100
|
+
npm test
|
|
101
|
+
npm run test:coverage
|
|
102
|
+
npm run test:hosts # packed RR7/RR8 hosts (needs matching Node majors)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## License
|
|
106
|
+
|
|
107
|
+
MIT
|