@suman-malik-repo/snapcache 1.0.0 → 1.0.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/README.md CHANGED
@@ -4,8 +4,8 @@
4
4
 
5
5
  **IndexedDB + ETag validation** — instant API performance, zero complexity.
6
6
 
7
- [![npm](https://img.shields.io/npm/v/@ogensync/snapcache)](https://www.npmjs.com/package/@ogensync/snapcache)
8
- [![license](https://img.shields.io/npm/l/@ogensync/snapcache)](./LICENSE)
7
+ [![npm](https://img.shields.io/npm/v/@suman-malik-repo/snapcache)](https://www.npmjs.com/package/@suman-malik-repo/snapcache)
8
+ [![license](https://img.shields.io/npm/l/@suman-malik-repo/snapcache)](./LICENSE)
9
9
 
10
10
  ---
11
11
 
@@ -25,13 +25,13 @@
25
25
  ## Installation
26
26
 
27
27
  ```bash
28
- npm install @ogensync/snapcache
28
+ npm install @suman-malik-repo/snapcache
29
29
  ```
30
30
 
31
31
  ## Client Usage
32
32
 
33
33
  ```javascript
34
- import SnapCache from "@ogensync/snapcache";
34
+ import SnapCache from "@suman-malik-repo/snapcache";
35
35
 
36
36
  await SnapCache.init({
37
37
  ttl: 300, // Cache for 5 minutes
@@ -70,7 +70,7 @@ SnapCache.attachAxios(axios);
70
70
  ## Server Middleware (Express)
71
71
 
72
72
  ```javascript
73
- const { SnapCacheMiddleware } = require("@ogensync/snapcache/server");
73
+ const { SnapCacheMiddleware } = require("@suman-malik-repo/snapcache/server");
74
74
 
75
75
  // Global — auto-adds ETag to all res.json() calls
76
76
  app.use(SnapCacheMiddleware());
@@ -78,7 +78,7 @@ app.use(SnapCacheMiddleware());
78
78
 
79
79
  ```javascript
80
80
  // Or per-route
81
- const { sendWithETag } = require("@ogensync/snapcache/server");
81
+ const { sendWithETag } = require("@suman-malik-repo/snapcache/server");
82
82
 
83
83
  app.get("/api/users", (req, res) => {
84
84
  const data = getUsers();
package/client/index.js CHANGED
@@ -529,6 +529,12 @@ class SnapCacheCore {
529
529
 
530
530
  const instance = new SnapCacheCore();
531
531
 
532
+ // Always set window.SnapCache in browser contexts (CDN script tag)
533
+ if (typeof window !== 'undefined') {
534
+ window.SnapCache = instance;
535
+ }
536
+
537
+ // Also support CommonJS/Node require (for npm package bundlers)
532
538
  if (typeof module !== 'undefined' && module.exports) {
533
539
  module.exports = instance;
534
540
  module.exports.default = instance;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suman-malik-repo/snapcache",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Universal browser-side intelligent caching layer with IndexedDB + HTTP ETag validation. Zero setup, production-ready.",
5
5
  "main": "server/index.js",
6
6
  "browser": "client/index.js",
@@ -49,4 +49,4 @@
49
49
  "bugs": {
50
50
  "url": "https://github.com/ogensync/snapcache/issues"
51
51
  }
52
- }
52
+ }
package/server/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * SnapCache Server Middleware
3
3
  * Express middleware for automatic ETag / 304 handling
4
4
  *
5
- * @module @ogensync/snapcache/server
5
+ * @module @suman-malik-repo/snapcache/server
6
6
  */
7
7
 
8
8
  const crypto = require('crypto');
@@ -28,7 +28,7 @@ function generateETag(data) {
28
28
  * @returns {Function} Express middleware
29
29
  *
30
30
  * @example
31
- * const { SnapCacheMiddleware } = require("@ogensync/snapcache/server");
31
+ * const { SnapCacheMiddleware } = require("@suman-malik-repo/snapcache/server");
32
32
  * app.use(SnapCacheMiddleware());
33
33
  */
34
34
  function SnapCacheMiddleware(options = {}) {
@@ -82,7 +82,7 @@ function SnapCacheMiddleware(options = {}) {
82
82
  * @param {number} options.maxAge - max-age in seconds (default: 0)
83
83
  *
84
84
  * @example
85
- * const { sendWithETag } = require("@ogensync/snapcache/server");
85
+ * const { sendWithETag } = require("@suman-malik-repo/snapcache/server");
86
86
  * app.get("/api/users", (req, res) => {
87
87
  * const data = getUsers();
88
88
  * sendWithETag(req, res, data);