@chromahq/store 0.1.5 → 0.1.7
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/dist/index.cjs.js +0 -21
- package/dist/index.d.ts +1 -9
- package/dist/index.es.js +1 -21
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
|
-
var core = require('@chromahq/core');
|
|
5
4
|
var vanilla = require('zustand/vanilla');
|
|
6
5
|
|
|
7
6
|
function _interopNamespaceDefault(e) {
|
|
@@ -76,7 +75,6 @@ function chromeStoragePersist(options) {
|
|
|
76
75
|
if (persistenceSetup) return;
|
|
77
76
|
persistenceSetup = true;
|
|
78
77
|
store.subscribe((state) => {
|
|
79
|
-
if (!isInitialized) return;
|
|
80
78
|
persistState(state);
|
|
81
79
|
});
|
|
82
80
|
};
|
|
@@ -270,24 +268,6 @@ function createStoreHooks() {
|
|
|
270
268
|
};
|
|
271
269
|
}
|
|
272
270
|
|
|
273
|
-
function Store(storeName) {
|
|
274
|
-
return function(target, propertyKey) {
|
|
275
|
-
Object.defineProperty(target, propertyKey, {
|
|
276
|
-
get() {
|
|
277
|
-
try {
|
|
278
|
-
const diKey = storeName ? `CentralStore:${storeName}` : "CentralStore";
|
|
279
|
-
if (core.container && core.container.isBound(diKey)) {
|
|
280
|
-
return core.container.get(diKey);
|
|
281
|
-
}
|
|
282
|
-
} catch {
|
|
283
|
-
}
|
|
284
|
-
},
|
|
285
|
-
enumerable: true,
|
|
286
|
-
configurable: true
|
|
287
|
-
});
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
|
|
291
271
|
class StoreBuilder {
|
|
292
272
|
constructor(name = "default") {
|
|
293
273
|
this.config = {
|
|
@@ -431,7 +411,6 @@ if (typeof globalThis !== "undefined") {
|
|
|
431
411
|
}
|
|
432
412
|
|
|
433
413
|
exports.BridgeStore = BridgeStore;
|
|
434
|
-
exports.Store = Store;
|
|
435
414
|
exports.StoreBuilder = StoreBuilder;
|
|
436
415
|
exports.chromeStoragePersist = chromeStoragePersist;
|
|
437
416
|
exports.createActionHookForStore = createActionHookForStore;
|
package/dist/index.d.ts
CHANGED
|
@@ -108,14 +108,6 @@ declare function createStoreHooks<T extends Record<string, any>>(): {
|
|
|
108
108
|
useAction: <K extends { [K_1 in keyof T]: T[K_1] extends (...args: any[]) => any ? K_1 : never; }[keyof T]>(actionKey: K) => T[K];
|
|
109
109
|
};
|
|
110
110
|
|
|
111
|
-
/**
|
|
112
|
-
* Property decorator to inject a store instance from DI container if available
|
|
113
|
-
* Usage:
|
|
114
|
-
* @Store() store: CentralStore<any>
|
|
115
|
-
* @Store('myStoreName') store: CentralStore<MyState>
|
|
116
|
-
*/
|
|
117
|
-
declare function Store(storeName?: string): (target: any, propertyKey: string) => void;
|
|
118
|
-
|
|
119
111
|
/**
|
|
120
112
|
* Core store builder with fluent API
|
|
121
113
|
*/
|
|
@@ -142,5 +134,5 @@ declare class StoreBuilder<T = any> {
|
|
|
142
134
|
*/
|
|
143
135
|
declare function createStore<T = any>(name?: string): StoreBuilder<T>;
|
|
144
136
|
|
|
145
|
-
export { BridgeStore,
|
|
137
|
+
export { BridgeStore, StoreBuilder, chromeStoragePersist, createActionHookForStore, createBridgeStore, createStore, createStoreHooks, useCentralDispatch, useCentralStore };
|
|
146
138
|
export type { Bridge, BridgeWithEvents, BridgeWithHandlers, CentralStore, ExtractSliceState, MergeSlices, PersistOptions, SliceCreator, StoreConfig, StoreDefinition };
|
package/dist/index.es.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useSyncExternalStore, createContext, useMemo, useContext, useRef } from 'react';
|
|
3
|
-
import { container } from '@chromahq/core';
|
|
4
3
|
import { createStore as createStore$1 } from 'zustand/vanilla';
|
|
5
4
|
|
|
6
5
|
function chromeStoragePersist(options) {
|
|
@@ -56,7 +55,6 @@ function chromeStoragePersist(options) {
|
|
|
56
55
|
if (persistenceSetup) return;
|
|
57
56
|
persistenceSetup = true;
|
|
58
57
|
store.subscribe((state) => {
|
|
59
|
-
if (!isInitialized) return;
|
|
60
58
|
persistState(state);
|
|
61
59
|
});
|
|
62
60
|
};
|
|
@@ -250,24 +248,6 @@ function createStoreHooks() {
|
|
|
250
248
|
};
|
|
251
249
|
}
|
|
252
250
|
|
|
253
|
-
function Store(storeName) {
|
|
254
|
-
return function(target, propertyKey) {
|
|
255
|
-
Object.defineProperty(target, propertyKey, {
|
|
256
|
-
get() {
|
|
257
|
-
try {
|
|
258
|
-
const diKey = storeName ? `CentralStore:${storeName}` : "CentralStore";
|
|
259
|
-
if (container && container.isBound(diKey)) {
|
|
260
|
-
return container.get(diKey);
|
|
261
|
-
}
|
|
262
|
-
} catch {
|
|
263
|
-
}
|
|
264
|
-
},
|
|
265
|
-
enumerable: true,
|
|
266
|
-
configurable: true
|
|
267
|
-
});
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
|
-
|
|
271
251
|
class StoreBuilder {
|
|
272
252
|
constructor(name = "default") {
|
|
273
253
|
this.config = {
|
|
@@ -410,4 +390,4 @@ if (typeof globalThis !== "undefined") {
|
|
|
410
390
|
globalThis.initStores = init;
|
|
411
391
|
}
|
|
412
392
|
|
|
413
|
-
export { BridgeStore,
|
|
393
|
+
export { BridgeStore, StoreBuilder, chromeStoragePersist, createActionHookForStore, createBridgeStore, createStore, createStoreHooks, useCentralDispatch, useCentralStore };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chromahq/store",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Centralized, persistent store for Chrome extensions using zustand, accessible from service workers and React, with chrome.storage.local persistence.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs.js",
|