com-angel-authorization 1.0.0
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 +21 -0
- package/README.md +276 -0
- package/dist/index.cjs +110 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +55 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.js +107 -0
- package/dist/index.js.map +1 -0
- package/dist/react/index.cjs +156 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.cts +119 -0
- package/dist/react/index.d.ts +119 -0
- package/dist/react/index.js +134 -0
- package/dist/react/index.js.map +1 -0
- package/dist/vue/index.cjs +241 -0
- package/dist/vue/index.cjs.map +1 -0
- package/dist/vue/index.d.cts +173 -0
- package/dist/vue/index.d.ts +173 -0
- package/dist/vue/index.js +213 -0
- package/dist/vue/index.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
// src/vue/plugin.ts
|
|
2
|
+
import {
|
|
3
|
+
computed,
|
|
4
|
+
inject,
|
|
5
|
+
onScopeDispose,
|
|
6
|
+
shallowRef
|
|
7
|
+
} from "vue";
|
|
8
|
+
import {
|
|
9
|
+
createPermissionStore
|
|
10
|
+
} from "../core";
|
|
11
|
+
|
|
12
|
+
// src/vue/directive.ts
|
|
13
|
+
function parseBinding(binding) {
|
|
14
|
+
const value = binding.value;
|
|
15
|
+
const arg = binding.arg;
|
|
16
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
17
|
+
return {
|
|
18
|
+
permission: value.permission,
|
|
19
|
+
role: value.role,
|
|
20
|
+
mode: value.mode ?? (arg === "all" ? "all" : "any"),
|
|
21
|
+
combine: value.combine ?? "and",
|
|
22
|
+
display: value.display
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
if (arg === "role") {
|
|
26
|
+
return {
|
|
27
|
+
role: value,
|
|
28
|
+
mode: binding.modifiers.all ? "all" : "any",
|
|
29
|
+
combine: "and"
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
permission: value,
|
|
34
|
+
mode: arg === "all" || binding.modifiers.all ? "all" : "any",
|
|
35
|
+
combine: "and"
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function isAllowed(store, binding) {
|
|
39
|
+
const { permission, role, mode, combine } = parseBinding(binding);
|
|
40
|
+
const options = { mode };
|
|
41
|
+
const hasPermCheck = permission !== void 0;
|
|
42
|
+
const hasRoleCheck = role !== void 0;
|
|
43
|
+
if (!hasPermCheck && !hasRoleCheck) return true;
|
|
44
|
+
const permOk = hasPermCheck ? store.hasPermission(permission, options) : true;
|
|
45
|
+
const roleOk = hasRoleCheck ? store.hasRole(role, options) : true;
|
|
46
|
+
if (hasPermCheck && hasRoleCheck) {
|
|
47
|
+
return combine === "or" ? permOk || roleOk : permOk && roleOk;
|
|
48
|
+
}
|
|
49
|
+
return hasPermCheck ? permOk : roleOk;
|
|
50
|
+
}
|
|
51
|
+
function applyVisibility(el, allowed, display) {
|
|
52
|
+
if (el.__angelPermissionDisplay === void 0) {
|
|
53
|
+
el.__angelPermissionDisplay = el.style.display;
|
|
54
|
+
}
|
|
55
|
+
if (allowed) {
|
|
56
|
+
el.style.display = display ?? el.__angelPermissionDisplay ?? "";
|
|
57
|
+
el.removeAttribute("aria-hidden");
|
|
58
|
+
} else {
|
|
59
|
+
el.style.display = "none";
|
|
60
|
+
el.setAttribute("aria-hidden", "true");
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function createVPermission(store) {
|
|
64
|
+
return {
|
|
65
|
+
mounted(el, binding) {
|
|
66
|
+
const update = () => {
|
|
67
|
+
const { display } = parseBinding(binding);
|
|
68
|
+
applyVisibility(el, isAllowed(store, binding), display);
|
|
69
|
+
};
|
|
70
|
+
update();
|
|
71
|
+
el.__angelPermissionUnsubscribe = store.subscribe(update);
|
|
72
|
+
},
|
|
73
|
+
updated(el, binding) {
|
|
74
|
+
const { display } = parseBinding(binding);
|
|
75
|
+
applyVisibility(el, isAllowed(store, binding), display);
|
|
76
|
+
},
|
|
77
|
+
unmounted(el) {
|
|
78
|
+
el.__angelPermissionUnsubscribe?.();
|
|
79
|
+
delete el.__angelPermissionUnsubscribe;
|
|
80
|
+
delete el.__angelPermissionDisplay;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// src/vue/plugin.ts
|
|
86
|
+
var PERMISSION_STORE_KEY = /* @__PURE__ */ Symbol(
|
|
87
|
+
"angel-authorization-store"
|
|
88
|
+
);
|
|
89
|
+
function createPermissionPlugin(options = {}) {
|
|
90
|
+
const store = options.store ?? createPermissionStore(options.initialState);
|
|
91
|
+
const directiveName = options.directiveName ?? "permission";
|
|
92
|
+
const plugin = {
|
|
93
|
+
store,
|
|
94
|
+
install(app) {
|
|
95
|
+
app.provide(PERMISSION_STORE_KEY, store);
|
|
96
|
+
app.directive(directiveName, createVPermission(store));
|
|
97
|
+
app.config.globalProperties.$permission = store;
|
|
98
|
+
app.config.globalProperties.$can = (codes, opts) => store.can(codes, opts);
|
|
99
|
+
app.config.globalProperties.$hasRole = (codes, opts) => store.hasRole(codes, opts);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
return plugin;
|
|
103
|
+
}
|
|
104
|
+
function resolveStore(store) {
|
|
105
|
+
const injected = store ?? inject(PERMISSION_STORE_KEY, null);
|
|
106
|
+
if (!injected) {
|
|
107
|
+
throw new Error(
|
|
108
|
+
"[com-angel-authorization/vue] Permission store not found. Did you call app.use(createPermissionPlugin())?"
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
return injected;
|
|
112
|
+
}
|
|
113
|
+
function usePermission(store) {
|
|
114
|
+
const permissionStore = resolveStore(store);
|
|
115
|
+
const state = shallowRef(permissionStore.getState());
|
|
116
|
+
const unsubscribe = permissionStore.subscribe((next) => {
|
|
117
|
+
state.value = next;
|
|
118
|
+
});
|
|
119
|
+
onScopeDispose(unsubscribe);
|
|
120
|
+
return {
|
|
121
|
+
permissions: computed(() => state.value.permissions),
|
|
122
|
+
roles: computed(() => state.value.roles),
|
|
123
|
+
isSuperAdmin: computed(() => Boolean(state.value.isSuperAdmin)),
|
|
124
|
+
hasPermission: (codes, options) => permissionStore.hasPermission(codes, options),
|
|
125
|
+
hasRole: (codes, options) => permissionStore.hasRole(codes, options),
|
|
126
|
+
can: (codes, options) => permissionStore.can(codes, options),
|
|
127
|
+
setPermissions: permissionStore.setPermissions.bind(permissionStore),
|
|
128
|
+
setRoles: permissionStore.setRoles.bind(permissionStore),
|
|
129
|
+
setSuperAdmin: permissionStore.setSuperAdmin.bind(permissionStore),
|
|
130
|
+
hydrate: permissionStore.hydrate.bind(permissionStore),
|
|
131
|
+
clear: permissionStore.clear.bind(permissionStore),
|
|
132
|
+
store: permissionStore
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function useHasPermission(codes, options, store) {
|
|
136
|
+
const { permissions, isSuperAdmin, hasPermission } = usePermission(store);
|
|
137
|
+
return computed(() => {
|
|
138
|
+
void permissions.value;
|
|
139
|
+
void isSuperAdmin.value;
|
|
140
|
+
return hasPermission(codes, options);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
function useHasRole(codes, options, store) {
|
|
144
|
+
const { roles, isSuperAdmin, hasRole } = usePermission(store);
|
|
145
|
+
return computed(() => {
|
|
146
|
+
void roles.value;
|
|
147
|
+
void isSuperAdmin.value;
|
|
148
|
+
return hasRole(codes, options);
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// src/vue/Can.ts
|
|
153
|
+
import { computed as computed2, defineComponent } from "vue";
|
|
154
|
+
var Can = defineComponent({
|
|
155
|
+
name: "Can",
|
|
156
|
+
props: {
|
|
157
|
+
permission: {
|
|
158
|
+
type: [String, Array],
|
|
159
|
+
default: void 0
|
|
160
|
+
},
|
|
161
|
+
role: {
|
|
162
|
+
type: [String, Array],
|
|
163
|
+
default: void 0
|
|
164
|
+
},
|
|
165
|
+
mode: {
|
|
166
|
+
type: String,
|
|
167
|
+
default: "any"
|
|
168
|
+
},
|
|
169
|
+
combine: {
|
|
170
|
+
type: String,
|
|
171
|
+
default: "and"
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
setup(props, { slots }) {
|
|
175
|
+
const { hasPermission, hasRole, permissions, roles, isSuperAdmin } = usePermission();
|
|
176
|
+
const allowed = computed2(() => {
|
|
177
|
+
void permissions.value;
|
|
178
|
+
void roles.value;
|
|
179
|
+
void isSuperAdmin.value;
|
|
180
|
+
const hasPermCheck = props.permission !== void 0;
|
|
181
|
+
const hasRoleCheck = props.role !== void 0;
|
|
182
|
+
if (!hasPermCheck && !hasRoleCheck) return true;
|
|
183
|
+
const options = { mode: props.mode };
|
|
184
|
+
const permOk = hasPermCheck ? hasPermission(props.permission, options) : true;
|
|
185
|
+
const roleOk = hasRoleCheck ? hasRole(props.role, options) : true;
|
|
186
|
+
if (hasPermCheck && hasRoleCheck) {
|
|
187
|
+
return props.combine === "or" ? permOk || roleOk : permOk && roleOk;
|
|
188
|
+
}
|
|
189
|
+
return hasPermCheck ? permOk : roleOk;
|
|
190
|
+
});
|
|
191
|
+
return () => {
|
|
192
|
+
if (allowed.value) {
|
|
193
|
+
return slots.default?.();
|
|
194
|
+
}
|
|
195
|
+
return slots.fallback?.() ?? null;
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
// src/vue/index.ts
|
|
201
|
+
import { PermissionStore, createPermissionStore as createPermissionStore2 } from "../core";
|
|
202
|
+
export {
|
|
203
|
+
Can,
|
|
204
|
+
PERMISSION_STORE_KEY,
|
|
205
|
+
PermissionStore,
|
|
206
|
+
createPermissionPlugin,
|
|
207
|
+
createPermissionStore2 as createPermissionStore,
|
|
208
|
+
createVPermission,
|
|
209
|
+
useHasPermission,
|
|
210
|
+
useHasRole,
|
|
211
|
+
usePermission
|
|
212
|
+
};
|
|
213
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/vue/plugin.ts","../../src/vue/directive.ts","../../src/vue/Can.ts","../../src/vue/index.ts"],"sourcesContent":["import {\n computed,\n inject,\n onScopeDispose,\n shallowRef,\n type App,\n type ComputedRef,\n type InjectionKey,\n type Plugin,\n} from 'vue';\nimport {\n createPermissionStore,\n type CheckOptions,\n type PermissionCode,\n type PermissionState,\n type PermissionStore,\n type RoleCode,\n} from '../core';\nimport { createVPermission } from './directive';\n\nexport const PERMISSION_STORE_KEY: InjectionKey<PermissionStore> = Symbol(\n 'angel-authorization-store',\n);\n\nexport interface PermissionPluginOptions {\n /** Pass an existing store to share across apps. */\n store?: PermissionStore;\n /** Initial state when the plugin creates its own store. */\n initialState?: Partial<PermissionState>;\n /** Custom directive name. Default: `permission` → `v-permission`. */\n directiveName?: string;\n}\n\nexport function createPermissionPlugin(\n options: PermissionPluginOptions = {},\n): Plugin & { store: PermissionStore } {\n const store = options.store ?? createPermissionStore(options.initialState);\n const directiveName = options.directiveName ?? 'permission';\n\n const plugin: Plugin & { store: PermissionStore } = {\n store,\n install(app: App) {\n app.provide(PERMISSION_STORE_KEY, store);\n app.directive(directiveName, createVPermission(store));\n app.config.globalProperties.$permission = store;\n app.config.globalProperties.$can = (\n codes: PermissionCode | PermissionCode[],\n opts?: CheckOptions,\n ) => store.can(codes, opts);\n app.config.globalProperties.$hasRole = (\n codes: RoleCode | RoleCode[],\n opts?: CheckOptions,\n ) => store.hasRole(codes, opts);\n },\n };\n\n return plugin;\n}\n\nfunction resolveStore(store?: PermissionStore): PermissionStore {\n const injected = store ?? inject(PERMISSION_STORE_KEY, null);\n if (!injected) {\n throw new Error(\n '[com-angel-authorization/vue] Permission store not found. Did you call app.use(createPermissionPlugin())?',\n );\n }\n return injected;\n}\n\nexport interface UsePermissionResult {\n permissions: ComputedRef<PermissionCode[]>;\n roles: ComputedRef<RoleCode[]>;\n isSuperAdmin: ComputedRef<boolean>;\n hasPermission: (codes: PermissionCode | PermissionCode[], options?: CheckOptions) => boolean;\n hasRole: (codes: RoleCode | RoleCode[], options?: CheckOptions) => boolean;\n can: (codes: PermissionCode | PermissionCode[], options?: CheckOptions) => boolean;\n setPermissions: (permissions: PermissionCode[]) => void;\n setRoles: (roles: RoleCode[]) => void;\n setSuperAdmin: (isSuperAdmin: boolean) => void;\n hydrate: (payload: Partial<PermissionState>) => void;\n clear: () => void;\n store: PermissionStore;\n}\n\n/**\n * Reactive permission API for Vue 3 Composition API.\n */\nexport function usePermission(store?: PermissionStore): UsePermissionResult {\n const permissionStore = resolveStore(store);\n const state = shallowRef<PermissionState>(permissionStore.getState());\n\n const unsubscribe = permissionStore.subscribe((next) => {\n state.value = next;\n });\n onScopeDispose(unsubscribe);\n\n return {\n permissions: computed(() => state.value.permissions),\n roles: computed(() => state.value.roles),\n isSuperAdmin: computed(() => Boolean(state.value.isSuperAdmin)),\n hasPermission: (codes, options) => permissionStore.hasPermission(codes, options),\n hasRole: (codes, options) => permissionStore.hasRole(codes, options),\n can: (codes, options) => permissionStore.can(codes, options),\n setPermissions: permissionStore.setPermissions.bind(permissionStore),\n setRoles: permissionStore.setRoles.bind(permissionStore),\n setSuperAdmin: permissionStore.setSuperAdmin.bind(permissionStore),\n hydrate: permissionStore.hydrate.bind(permissionStore),\n clear: permissionStore.clear.bind(permissionStore),\n store: permissionStore,\n };\n}\n\nexport function useHasPermission(\n codes: PermissionCode | PermissionCode[],\n options?: CheckOptions,\n store?: PermissionStore,\n) {\n const { permissions, isSuperAdmin, hasPermission } = usePermission(store);\n return computed(() => {\n void permissions.value;\n void isSuperAdmin.value;\n return hasPermission(codes, options);\n });\n}\n\nexport function useHasRole(\n codes: RoleCode | RoleCode[],\n options?: CheckOptions,\n store?: PermissionStore,\n) {\n const { roles, isSuperAdmin, hasRole } = usePermission(store);\n return computed(() => {\n void roles.value;\n void isSuperAdmin.value;\n return hasRole(codes, options);\n });\n}\n\ndeclare module 'vue' {\n interface ComponentCustomProperties {\n $permission: PermissionStore;\n $can: (codes: PermissionCode | PermissionCode[], options?: CheckOptions) => boolean;\n $hasRole: (codes: RoleCode | RoleCode[], options?: CheckOptions) => boolean;\n }\n}\n","import type { Directive, DirectiveBinding } from 'vue';\nimport type { CheckOptions, MatchMode, PermissionCode, PermissionStore, RoleCode } from '../core';\n\nexport type PermissionDirectiveValue =\n | PermissionCode\n | PermissionCode[]\n | {\n permission?: PermissionCode | PermissionCode[];\n role?: RoleCode | RoleCode[];\n mode?: MatchMode;\n /** When both permission and role are set. Default: `and`. */\n combine?: 'and' | 'or';\n /** CSS display value when allowed. Default: restores original display. */\n display?: string;\n };\n\nfunction parseBinding(binding: DirectiveBinding<PermissionDirectiveValue>): {\n permission?: PermissionCode | PermissionCode[];\n role?: RoleCode | RoleCode[];\n mode?: MatchMode;\n combine: 'and' | 'or';\n display?: string;\n} {\n const value = binding.value;\n const arg = binding.arg;\n\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n return {\n permission: value.permission,\n role: value.role,\n mode: value.mode ?? (arg === 'all' ? 'all' : 'any'),\n combine: value.combine ?? 'and',\n display: value.display,\n };\n }\n\n if (arg === 'role') {\n return {\n role: value as RoleCode | RoleCode[],\n mode: binding.modifiers.all ? 'all' : 'any',\n combine: 'and',\n };\n }\n\n return {\n permission: value as PermissionCode | PermissionCode[],\n mode: arg === 'all' || binding.modifiers.all ? 'all' : 'any',\n combine: 'and',\n };\n}\n\nfunction isAllowed(\n store: PermissionStore,\n binding: DirectiveBinding<PermissionDirectiveValue>,\n): boolean {\n const { permission, role, mode, combine } = parseBinding(binding);\n const options: CheckOptions = { mode };\n\n const hasPermCheck = permission !== undefined;\n const hasRoleCheck = role !== undefined;\n\n if (!hasPermCheck && !hasRoleCheck) return true;\n\n const permOk = hasPermCheck ? store.hasPermission(permission!, options) : true;\n const roleOk = hasRoleCheck ? store.hasRole(role!, options) : true;\n\n if (hasPermCheck && hasRoleCheck) {\n return combine === 'or' ? permOk || roleOk : permOk && roleOk;\n }\n\n return hasPermCheck ? permOk : roleOk;\n}\n\ntype ElWithPermission = HTMLElement & {\n __angelPermissionDisplay?: string;\n __angelPermissionUnsubscribe?: () => void;\n};\n\nfunction applyVisibility(\n el: ElWithPermission,\n allowed: boolean,\n display?: string,\n): void {\n if (el.__angelPermissionDisplay === undefined) {\n el.__angelPermissionDisplay = el.style.display;\n }\n\n if (allowed) {\n el.style.display = display ?? el.__angelPermissionDisplay ?? '';\n el.removeAttribute('aria-hidden');\n } else {\n el.style.display = 'none';\n el.setAttribute('aria-hidden', 'true');\n }\n}\n\n/**\n * Create a `v-permission` directive bound to a specific store.\n * Prefer installing via `createPermissionPlugin()` which registers this automatically.\n */\nexport function createVPermission(\n store: PermissionStore,\n): Directive<ElWithPermission, PermissionDirectiveValue> {\n return {\n mounted(el, binding) {\n const update = () => {\n const { display } = parseBinding(binding);\n applyVisibility(el, isAllowed(store, binding), display);\n };\n\n update();\n el.__angelPermissionUnsubscribe = store.subscribe(update);\n },\n\n updated(el, binding) {\n const { display } = parseBinding(binding);\n applyVisibility(el, isAllowed(store, binding), display);\n },\n\n unmounted(el) {\n el.__angelPermissionUnsubscribe?.();\n delete el.__angelPermissionUnsubscribe;\n delete el.__angelPermissionDisplay;\n },\n };\n}\n","import { computed, defineComponent, type PropType } from 'vue';\nimport type { MatchMode, PermissionCode, RoleCode } from '../core';\nimport { usePermission } from './plugin';\n\n/**\n * Conditionally render slot content based on permission / role.\n *\n * @example\n * <Can permission=\"user:edit\">\n * <button>Edit</button>\n * </Can>\n *\n * <Can :permission=\"['user:edit', 'user:delete']\" mode=\"all\">\n * <AdminPanel />\n * <template #fallback>No access</template>\n * </Can>\n */\nexport const Can = defineComponent({\n name: 'Can',\n props: {\n permission: {\n type: [String, Array] as PropType<PermissionCode | PermissionCode[]>,\n default: undefined,\n },\n role: {\n type: [String, Array] as PropType<RoleCode | RoleCode[]>,\n default: undefined,\n },\n mode: {\n type: String as PropType<MatchMode>,\n default: 'any',\n },\n combine: {\n type: String as PropType<'and' | 'or'>,\n default: 'and',\n },\n },\n setup(props, { slots }) {\n const { hasPermission, hasRole, permissions, roles, isSuperAdmin } = usePermission();\n\n const allowed = computed(() => {\n void permissions.value;\n void roles.value;\n void isSuperAdmin.value;\n\n const hasPermCheck = props.permission !== undefined;\n const hasRoleCheck = props.role !== undefined;\n\n if (!hasPermCheck && !hasRoleCheck) return true;\n\n const options = { mode: props.mode };\n const permOk = hasPermCheck ? hasPermission(props.permission!, options) : true;\n const roleOk = hasRoleCheck ? hasRole(props.role!, options) : true;\n\n if (hasPermCheck && hasRoleCheck) {\n return props.combine === 'or' ? permOk || roleOk : permOk && roleOk;\n }\n\n return hasPermCheck ? permOk : roleOk;\n });\n\n return () => {\n if (allowed.value) {\n return slots.default?.();\n }\n return slots.fallback?.() ?? null;\n };\n },\n});\n","export {\n createPermissionPlugin,\n usePermission,\n useHasPermission,\n useHasRole,\n PERMISSION_STORE_KEY,\n} from './plugin';\nexport type { PermissionPluginOptions, UsePermissionResult } from './plugin';\n\nexport { createVPermission } from './directive';\nexport type { PermissionDirectiveValue } from './directive';\n\nexport { Can } from './Can';\n\nexport type {\n CheckOptions,\n MatchMode,\n PermissionChecker,\n PermissionCode,\n PermissionListener,\n PermissionState,\n RoleCode,\n} from '../core';\n\nexport { PermissionStore, createPermissionStore } from '../core';\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAKK;AACP;AAAA,EACE;AAAA,OAMK;;;ACDP,SAAS,aAAa,SAMpB;AACA,QAAM,QAAQ,QAAQ;AACtB,QAAM,MAAM,QAAQ;AAEpB,MAAI,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,GAAG;AAC/D,WAAO;AAAA,MACL,YAAY,MAAM;AAAA,MAClB,MAAM,MAAM;AAAA,MACZ,MAAM,MAAM,SAAS,QAAQ,QAAQ,QAAQ;AAAA,MAC7C,SAAS,M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A,MACpB,SAAS;AAAA,IACX;AAAA,IACA,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,IACA,SAAS;AAAA,MACP,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACA,MAAM,OAAO,EAAE,MAAM,GAAG;AACtB,UAAM,EAAE,eAAe,SAAS,aAAa,OAAO,aAAa,IAAI,cAAc;AAEnF,UAAM,UAAUC,UAAS,MAAM;AAC7B,WAAK,YAAY;AACjB,WAAK,MAAM;AACX,WAAK,aAAa;AAElB,YAAM,eAAe,MAAM,eAAe;AAC1C,YAAM,eAAe,MAAM,SAAS;AAEpC,UAAI,CAAC,gBAAgB,CAAC,aAAc,QAAO;AAE3C,YAAM,UAAU,EAAE,MAAM,MAAM,KAAK;AACnC,YAAM,SAAS,eAAe,cAAc,MAAM,YAAa,OAAO,IAAI;AAC1E,YAAM,SAAS,eAAe,QAAQ,MAAM,MAAO,OAAO,IAAI;AAE9D,UAAI,gBAAgB,cAAc;AAChC,eAAO,MAAM,YAAY,OAAO,UAAU,SAAS,UAAU;AAAA,MAC/D;AAEA,aAAO,eAAe,SAAS;AAAA,IACjC,CAAC;AAED,WAAO,MAAM;AACX,UAAI,QAAQ,OAAO;AACjB,eAAO,MAAM,UAAU;AAAA,MACzB;AACA,aAAO,MAAM,WAAW,KAAK;AAAA,IAC/B;AAAA,EACF;AACF,CAAC;;;AC5CD,SAAS,iBAAiB,yBAAAC,8BAA6B;","names":["computed","computed","createPermissionStore"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "com-angel-authorization",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Framework-agnostic user permission toolkit for React and Vue",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"./react": {
|
|
16
|
+
"types": "./dist/react/index.d.ts",
|
|
17
|
+
"import": "./dist/react/index.js",
|
|
18
|
+
"require": "./dist/react/index.cjs"
|
|
19
|
+
},
|
|
20
|
+
"./vue": {
|
|
21
|
+
"types": "./dist/vue/index.d.ts",
|
|
22
|
+
"import": "./dist/vue/index.js",
|
|
23
|
+
"require": "./dist/vue/index.cjs"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"README.md"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tsup",
|
|
32
|
+
"dev": "tsup --watch",
|
|
33
|
+
"typecheck": "tsc --noEmit",
|
|
34
|
+
"prepublishOnly": "npm run build"
|
|
35
|
+
},
|
|
36
|
+
"keywords": [
|
|
37
|
+
"permission",
|
|
38
|
+
"authorization",
|
|
39
|
+
"acl",
|
|
40
|
+
"rbac",
|
|
41
|
+
"react",
|
|
42
|
+
"vue",
|
|
43
|
+
"access-control"
|
|
44
|
+
],
|
|
45
|
+
"author": "",
|
|
46
|
+
"license": "MIT",
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"react": ">=17.0.0",
|
|
49
|
+
"vue": ">=3.0.0"
|
|
50
|
+
},
|
|
51
|
+
"peerDependenciesMeta": {
|
|
52
|
+
"react": {
|
|
53
|
+
"optional": true
|
|
54
|
+
},
|
|
55
|
+
"vue": {
|
|
56
|
+
"optional": true
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@types/react": "^18.3.12",
|
|
61
|
+
"react": "^18.3.1",
|
|
62
|
+
"tsup": "^8.3.5",
|
|
63
|
+
"typescript": "^5.6.3",
|
|
64
|
+
"vue": "^3.5.13"
|
|
65
|
+
},
|
|
66
|
+
"sideEffects": false
|
|
67
|
+
}
|