🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@mooljs/plugin-store

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mooljs/plugin-store - npm Package Compare versions

Comparing version
1.2.2
to
1.2.3
+25
-19
dist/store.mjs

@@ -1,10 +0,10 @@

import { effectScope as c } from "vue";
function u(s) {
import { effectScope as a, inject as f } from "vue";
function d(i) {
let t = !1, e;
const n = c(!0);
return (...l) => (t || (e = n.run(() => s(...l)), t = !0), e);
const n = a(!0);
return (...s) => (t || (e = n.run(() => i(...s)), t = !0), e);
}
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
const f = Symbol("global-store");
class i {
const c = Symbol("global-store");
class r {
constructor() {

@@ -14,3 +14,3 @@ this.modules = {};

static getInstance() {
return i.instance || (i.instance = new i()), i.instance;
return r.instance || (r.instance = new r()), r.instance;
}

@@ -27,7 +27,7 @@ /**

);
Object.entries(moduleFiles).forEach(([l, a]) => {
var o;
const r = (o = l.match(/([^/]+)\.ts$/)) == null ? void 0 : o[1];
r && this.register(r, a.default);
}), e != null && e.initialState && this.register("@@initialState", () => e.initialState), t.provide(f, this.modules);
Object.entries(moduleFiles).forEach(([s, u]) => {
var l;
const o = (l = s.match(/([^/]+)\.ts$/)) == null ? void 0 : l[1];
o && this.register(o, u.default);
}), e != null && e.initialState && this.register("@@initialState", () => e.initialState), t.provide(c, this.modules);
}

@@ -38,3 +38,3 @@ /**

register(t, e) {
this.modules[t] && console.warn(`[StoreManager] 模块 ${t} 已存在,将被覆盖`), this.modules[t] = u(e);
this.modules[t] && console.warn(`[StoreManager] 模块 ${t} 已存在,将被覆盖`), this.modules[t] = d(e);
}

@@ -48,10 +48,16 @@ /**

}
const m = (s, t) => {
const e = i.getInstance();
return e.initialize(s, t), e;
const S = (i, t) => {
const e = r.getInstance();
return e.initialize(i, t), e;
}, b = (i) => {
const t = f(c, "");
if (!(t != null && t[i]))
throw new Error(`[useStore] 未找到命名空间为 ${i} 的模块`);
return t[i]();
};
export {
f as STORE_KEY,
i as StoreManager,
m as setupStore
c as STORE_KEY,
r as StoreManager,
S as setupStore,
b as useStore
};

@@ -26,3 +26,3 @@ const { readFileSync, existsSync, readdirSync } = require("node:fs");

injectMool: () => {
return [`import { STORE_KEY } from 'virtual:store';export const useStore = (namespace) => {const modules = inject(STORE_KEY,'');if (!modules?.[namespace]) {throw new Error(\`[useStore] 未找到命名空间为 \${namespace} 的模块\`)} return modules[namespace]()}`];
return [`export { useStore } from 'virtual:store';`];
},

@@ -36,3 +36,3 @@ injectModuleType: () => {

(module) => ` ${module}: typeof import("src/store/${module}")['default'];\n`,
).concat([` '@@initialState':Awaited<ReturnType<(typeof import("src/app.ts"))["getInitialState"]|(typeof import("src/app.tsx"))["getInitialState"]>>`])
).concat([` '@@initialState':(typeof import("src/app.ts"))["getInitialState"]|(typeof import("src/app.tsx"))["getInitialState"];`])
.join("");

@@ -39,0 +39,0 @@ return [

{
"name": "@mooljs/plugin-store",
"version": "1.2.2",
"version": "1.2.3",
"description": " global data store for mooljs",

@@ -5,0 +5,0 @@ "main": "index.js",