@chromahq/store 0.1.5 → 0.1.6
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 -20
- package/dist/index.d.ts +1 -9
- package/dist/index.es.js +1 -20
- 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) {
|
|
@@ -270,24 +269,6 @@ function createStoreHooks() {
|
|
|
270
269
|
};
|
|
271
270
|
}
|
|
272
271
|
|
|
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
272
|
class StoreBuilder {
|
|
292
273
|
constructor(name = "default") {
|
|
293
274
|
this.config = {
|
|
@@ -431,7 +412,6 @@ if (typeof globalThis !== "undefined") {
|
|
|
431
412
|
}
|
|
432
413
|
|
|
433
414
|
exports.BridgeStore = BridgeStore;
|
|
434
|
-
exports.Store = Store;
|
|
435
415
|
exports.StoreBuilder = StoreBuilder;
|
|
436
416
|
exports.chromeStoragePersist = chromeStoragePersist;
|
|
437
417
|
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) {
|
|
@@ -250,24 +249,6 @@ function createStoreHooks() {
|
|
|
250
249
|
};
|
|
251
250
|
}
|
|
252
251
|
|
|
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
252
|
class StoreBuilder {
|
|
272
253
|
constructor(name = "default") {
|
|
273
254
|
this.config = {
|
|
@@ -410,4 +391,4 @@ if (typeof globalThis !== "undefined") {
|
|
|
410
391
|
globalThis.initStores = init;
|
|
411
392
|
}
|
|
412
393
|
|
|
413
|
-
export { BridgeStore,
|
|
394
|
+
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.6",
|
|
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",
|