@allstak/react 0.1.1

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) 2024 AllStak
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,80 @@
1
+ # @allstak-io/react
2
+
3
+ AllStak React SDK — `<AllStakErrorBoundary>`, `useAllStak()` hook, and `withAllStakProfiler` HOC.
4
+
5
+ ## Install
6
+
7
+ > **Auth required:** GitHub Packages requires a token with `read:packages` scope.
8
+
9
+ ### 1. Configure `.npmrc`
10
+
11
+ ```ini
12
+ @allstak-io:registry=https://npm.pkg.github.com
13
+ //npm.pkg.github.com/:_authToken=YOUR_GITHUB_PAT
14
+ ```
15
+
16
+ ### 2. Install
17
+
18
+ ```bash
19
+ npm install @allstak-io/react@0.1.1 @allstak-io/browser@0.1.1
20
+ # react >=16.8 is a peer dep — install separately if needed
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ ```tsx
26
+ import { AllStak } from '@allstak-io/browser';
27
+ import { AllStakErrorBoundary, useAllStak } from '@allstak-io/react';
28
+
29
+ // 1. Initialize once at app root
30
+ AllStak.init({
31
+ apiKey: process.env.ALLSTAK_API_KEY!,
32
+ environment: 'production',
33
+ release: 'v1.0.0',
34
+ });
35
+
36
+ // 2. Wrap your component tree
37
+ function App() {
38
+ return (
39
+ <AllStakErrorBoundary fallback={<p>Something went wrong.</p>}>
40
+ <MyApp />
41
+ </AllStakErrorBoundary>
42
+ );
43
+ }
44
+
45
+ // 3. Manual capture inside components
46
+ function MyComponent() {
47
+ const allstak = useAllStak();
48
+
49
+ const handleClick = () => {
50
+ try {
51
+ riskyOperation();
52
+ } catch (err) {
53
+ allstak.captureException(err as Error);
54
+ }
55
+ };
56
+
57
+ return <button onClick={handleClick}>Do risky thing</button>;
58
+ }
59
+ ```
60
+
61
+ ## API
62
+
63
+ | Export | Description |
64
+ |--------|-------------|
65
+ | `AllStak` | Re-exported from `@allstak-io/browser` — use to init |
66
+ | `AllStakErrorBoundary` | React error boundary; catches component-tree errors |
67
+ | `AllStakErrorBoundaryProps` | Props type for the boundary |
68
+ | `useAllStak()` | Hook returning `{ captureException, captureMessage, setUser, setTag }` |
69
+ | `withAllStakProfiler(Component)` | HOC that wraps a component in the profiler |
70
+
71
+ ## GitHub Packages
72
+
73
+ - **Package:** `@allstak-io/react`
74
+ - **Registry:** `https://npm.pkg.github.com`
75
+ - **Repo:** [github.com/allstak-io/allstak-react](https://github.com/allstak-io/allstak-react)
76
+ - **Releases:** [github.com/allstak-io/allstak-react/releases](https://github.com/allstak-io/allstak-react/releases)
77
+
78
+ ## Versioning
79
+
80
+ Tags must match `package.json` version exactly (e.g. `v0.1.1`). The release workflow fails if there's a mismatch.
@@ -0,0 +1 @@
1
+ export { AllStak, AllStakErrorBoundary, AllStakErrorBoundaryProps, useAllStak, withAllStakProfiler } from 'allstak-js/react';
@@ -0,0 +1 @@
1
+ export { AllStak, AllStakErrorBoundary, AllStakErrorBoundaryProps, useAllStak, withAllStakProfiler } from 'allstak-js/react';
package/dist/index.js ADDED
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ AllStak: () => import_react.AllStak,
24
+ AllStakErrorBoundary: () => import_react.AllStakErrorBoundary,
25
+ useAllStak: () => import_react.useAllStak,
26
+ withAllStakProfiler: () => import_react.withAllStakProfiler
27
+ });
28
+ module.exports = __toCommonJS(index_exports);
29
+ var import_react = require("allstak-js/react");
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @allstak/react — React-specific public API.\n *\n * Re-exports the React integration from allstak-js/react.\n * Components and hooks all rely on @allstak/browser being initialized first.\n */\nexport {\n AllStakErrorBoundary,\n type AllStakErrorBoundaryProps,\n useAllStak,\n withAllStakProfiler,\n AllStak,\n} from 'allstak-js/react';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,mBAMO;","names":[]}
package/dist/index.mjs ADDED
@@ -0,0 +1,14 @@
1
+ // src/index.ts
2
+ import {
3
+ AllStakErrorBoundary,
4
+ useAllStak,
5
+ withAllStakProfiler,
6
+ AllStak
7
+ } from "allstak-js/react";
8
+ export {
9
+ AllStak,
10
+ AllStakErrorBoundary,
11
+ useAllStak,
12
+ withAllStakProfiler
13
+ };
14
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @allstak/react — React-specific public API.\n *\n * Re-exports the React integration from allstak-js/react.\n * Components and hooks all rely on @allstak/browser being initialized first.\n */\nexport {\n AllStakErrorBoundary,\n type AllStakErrorBoundaryProps,\n useAllStak,\n withAllStakProfiler,\n AllStak,\n} from 'allstak-js/react';\n"],"mappings":";AAMA;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":[]}
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@allstak/react",
3
+ "version": "0.1.1",
4
+ "description": "AllStak React SDK — <AllStakErrorBoundary>, useAllStak() hook, withAllStakProfiler HOC. Depends on @allstak-io/browser.",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md",
18
+ "LICENSE"
19
+ ],
20
+ "license": "MIT",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/allstak-io/allstak-react.git"
24
+ },
25
+ "homepage": "https://allstak.sa",
26
+ "bugs": {
27
+ "url": "https://github.com/allstak-io/allstak-react/issues"
28
+ },
29
+ "keywords": [
30
+ "allstak",
31
+ "observability",
32
+ "react",
33
+ "error-boundary"
34
+ ],
35
+ "publishConfig": {
36
+ "access": "public",
37
+ "registry": "https://registry.npmjs.org/"
38
+ },
39
+ "scripts": {
40
+ "build": "tsup src/index.ts --format esm,cjs --dts --clean --sourcemap --platform browser --external react --external react-dom",
41
+ "typecheck": "tsc --noEmit"
42
+ },
43
+ "peerDependencies": {
44
+ "react": ">=16.8.0"
45
+ },
46
+ "dependencies": {
47
+ "@allstak/browser": "^0.1.1",
48
+ "@allstak/js": "^0.1.1"
49
+ },
50
+ "devDependencies": {
51
+ "@types/react": "^18.3.0",
52
+ "react": "^18.3.0",
53
+ "tsup": "^8.0.0",
54
+ "typescript": "^5.3.0"
55
+ }
56
+ }