@vuetify/v0 0.1.2 → 0.1.4
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 +20 -3
- package/dist/adapter-BN-h5JbD.d.mts +344 -0
- package/dist/adapter-CJIj5ySf.d.mts +11 -0
- package/dist/adapter-D_0ptsPm.mjs +229 -0
- package/dist/adapters-BQ-Lr3PW.mjs +1 -0
- package/dist/adapters-DEXpW9If.mjs +1 -0
- package/dist/adapters-Q9WaOsJp.mjs +1 -0
- package/dist/adapters-SSDVth5e.mjs +1 -0
- package/dist/browser/index.js +5593 -4490
- package/dist/components/index.d.mts +20 -4
- package/dist/components/index.mjs +38 -6
- package/dist/{components-z56rRlS4.mjs → components-CMuzTJdK.mjs} +588 -90
- package/dist/composables/index.d.mts +17 -5
- package/dist/composables/index.mjs +36 -4
- package/dist/consola-DiUk9j3y.d.mts +15 -0
- package/dist/consola-GBy8XRuL.mjs +31 -0
- package/dist/constants/index.d.mts +1 -1
- package/dist/constants/index.mjs +3 -3
- package/dist/constants-B8pMSkcW.mjs +1 -0
- package/dist/createDataTable-BJnmvxfb.mjs +387 -0
- package/dist/createGroup-CPhp6FUh.mjs +363 -0
- package/dist/createPagination-cyOWlpfH.mjs +234 -0
- package/dist/createSelection-uqEbFgha.mjs +261 -0
- package/dist/createSingle-B59ya3aa.mjs +179 -0
- package/dist/createTokens-BlhLdHXE.mjs +682 -0
- package/dist/createTrinity-EeHQSsb6.mjs +149 -0
- package/dist/data-table/adapters/client/index.d.mts +3 -0
- package/dist/data-table/adapters/client/index.mjs +9 -0
- package/dist/data-table/adapters/index.d.mts +5 -0
- package/dist/data-table/adapters/index.mjs +12 -0
- package/dist/data-table/adapters/server/index.d.mts +3 -0
- package/dist/data-table/adapters/server/index.mjs +7 -0
- package/dist/data-table/adapters/virtual/index.d.mts +3 -0
- package/dist/data-table/adapters/virtual/index.mjs +9 -0
- package/dist/data-table/index.d.mts +7 -0
- package/dist/data-table/index.mjs +25 -0
- package/dist/date/index.d.mts +1 -1
- package/dist/date/index.mjs +19 -15
- package/dist/features/adapters/flagsmith/index.d.mts +16 -0
- package/dist/features/adapters/flagsmith/index.mjs +3 -0
- package/dist/features/adapters/launchdarkly/index.d.mts +15 -0
- package/dist/features/adapters/launchdarkly/index.mjs +3 -0
- package/dist/features/adapters/posthog/index.d.mts +15 -0
- package/dist/features/adapters/posthog/index.mjs +4 -0
- package/dist/features/index.d.mts +17 -0
- package/dist/features/index.mjs +18 -0
- package/dist/flagsmith-CHmpPGR7.mjs +40 -0
- package/dist/{globals-VwjZ5i4B.mjs → globals-B_GVfG06.mjs} +2 -2
- package/dist/index-7mWYFHA6.d.mts +251 -0
- package/dist/index-BDTbJClL.d.mts +11 -0
- package/dist/{index-DlxrzbvZ.d.mts → index-BFBN5Zl3.d.mts} +41 -1
- package/dist/index-BuOz3Rgm.d.mts +32 -0
- package/dist/{index-cPmI99rd.d.mts → index-Bv1VN_j5.d.mts} +1 -1
- package/dist/{index-PuLeBGZ3.d.mts → index-CQrDeqsK.d.mts} +894 -329
- package/dist/{index-CLKfXGEQ.d.mts → index-Dd0m0LIJ.d.mts} +2228 -1178
- package/dist/{index-CoO8LW8o.d.mts → index-UNwEBkQT.d.mts} +16 -2
- package/dist/index.d.mts +20 -8
- package/dist/index.mjs +39 -7
- package/dist/json/attributes.json +140 -0
- package/dist/json/importMap.json +36 -0
- package/dist/json/tags.json +75 -0
- package/dist/json/web-types.json +440 -1
- package/dist/launchdarkly-W8t8ZANX.mjs +28 -0
- package/dist/locale/adapters/index.d.mts +3 -0
- package/dist/locale/adapters/index.mjs +6 -0
- package/dist/locale/adapters/v0/index.d.mts +3 -0
- package/dist/locale/adapters/v0/index.mjs +5 -0
- package/dist/locale/index.d.mts +17 -0
- package/dist/locale/index.mjs +17 -0
- package/dist/logger/adapters/consola/index.d.mts +3 -0
- package/dist/logger/adapters/consola/index.mjs +3 -0
- package/dist/logger/adapters/index.d.mts +5 -0
- package/dist/logger/adapters/index.mjs +8 -0
- package/dist/logger/adapters/pino/index.d.mts +3 -0
- package/dist/logger/adapters/pino/index.mjs +5 -0
- package/dist/logger/adapters/v0/index.d.mts +3 -0
- package/dist/logger/adapters/v0/index.mjs +5 -0
- package/dist/logger/index.d.mts +17 -0
- package/dist/logger/index.mjs +10 -0
- package/dist/memory-BsZGbGnG.mjs +27 -0
- package/dist/memory-DVjquu_v.d.mts +25 -0
- package/dist/permissions/adapters/index.d.mts +18 -0
- package/dist/permissions/adapters/index.mjs +6 -0
- package/dist/permissions/adapters/v0/index.d.mts +18 -0
- package/dist/permissions/adapters/v0/index.mjs +5 -0
- package/dist/permissions/index.d.mts +17 -0
- package/dist/permissions/index.mjs +15 -0
- package/dist/pino-01x_NmWp.mjs +49 -0
- package/dist/pino-p-jDkNQd.d.mts +24 -0
- package/dist/posthog-BrGBPPir.mjs +50 -0
- package/dist/server-6cs14bj1.d.mts +20 -0
- package/dist/server-ClCwiLMA.mjs +45 -0
- package/dist/storage/adapters/index.d.mts +3 -0
- package/dist/storage/adapters/index.mjs +3 -0
- package/dist/storage/adapters/memory/index.d.mts +2 -0
- package/dist/storage/adapters/memory/index.mjs +3 -0
- package/dist/storage/index.d.mts +17 -0
- package/dist/storage/index.mjs +37 -0
- package/dist/theme/adapters/index.d.mts +17 -0
- package/dist/theme/adapters/index.mjs +6 -0
- package/dist/theme/adapters/v0/index.d.mts +17 -0
- package/dist/theme/adapters/v0/index.mjs +5 -0
- package/dist/theme/index.d.mts +17 -0
- package/dist/theme/index.mjs +16 -0
- package/dist/toArray-DIeXVX1C.mjs +38 -0
- package/dist/types/index.d.mts +2 -2
- package/dist/{useClickOutside-Dp1MHIjr.mjs → useClickOutside-p8HP07At.mjs} +2437 -5442
- package/dist/useFeatures-C4JF3Hgr.mjs +122 -0
- package/dist/useLocale-DlbShzF-.mjs +85 -0
- package/dist/useLogger-CO9JwbSJ.mjs +283 -0
- package/dist/usePermissions-DQVT_4nD.mjs +128 -0
- package/dist/useTheme-Bcw1Ebyt.mjs +135 -0
- package/dist/utilities/index.d.mts +3 -3
- package/dist/utilities/index.mjs +3 -2
- package/dist/{utilities-B58TiS_S.mjs → utilities-BqS1sC1W.mjs} +27 -1
- package/dist/v0-B40YkIQ-.mjs +21 -0
- package/dist/v0-BOxb3nD1.d.mts +33 -0
- package/dist/v0-BogbIzpM.mjs +41 -0
- package/dist/v0-BtQCSBOG.mjs +37 -0
- package/dist/v0-C-9dv_1S.d.mts +10 -0
- package/dist/v0-CtjuUUPl.mjs +73 -0
- package/dist/v0-DHMoZ7dS.d.mts +22 -0
- package/dist/v0-ONBWyQYQ.mjs +83 -0
- package/dist/v0-RepwEY1F.d.mts +9 -0
- package/dist/virtual-B3IPkHC0.d.mts +9 -0
- package/dist/virtual-BP9WXRzN.mjs +44 -0
- package/package.json +37 -4
- package/dist/index-qSuLpob3.d.mts +0 -1544
- /package/dist/{adapter-L4Php1_S.d.mts → adapter-DcwxFryd.d.mts} +0 -0
- /package/dist/{constants-DHKqjdjH.mjs → adapters-BGJKsBrw.mjs} +0 -0
- /package/dist/{htmlElements-DO9n35bD.mjs → htmlElements-d8iBCGpO.mjs} +0 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { d as isObject, i as isBoolean, o as isFunction, r as isArray } from "./utilities-BqS1sC1W.mjs";
|
|
2
|
+
import { o as createPluginContext } from "./useLogger-CO9JwbSJ.mjs";
|
|
3
|
+
import { t as createTokens } from "./createTokens-BlhLdHXE.mjs";
|
|
4
|
+
import { t as createGroup } from "./createGroup-CPhp6FUh.mjs";
|
|
5
|
+
|
|
6
|
+
//#region src/composables/useFeatures/adapters/generic/index.ts
|
|
7
|
+
var FeaturesAdapter = class {};
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/composables/useFeatures/index.ts
|
|
11
|
+
/**
|
|
12
|
+
* @module useFeatures
|
|
13
|
+
*
|
|
14
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-features
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* Feature flag system with boolean and token-based features.
|
|
18
|
+
*
|
|
19
|
+
* Key features:
|
|
20
|
+
* - Boolean features (true/false activation)
|
|
21
|
+
* - Token features with $variation support
|
|
22
|
+
* - Auto-selection of enabled features
|
|
23
|
+
* - Multi-select support for feature combinations
|
|
24
|
+
* - Perfect for A/B testing, progressive rollout, feature toggles
|
|
25
|
+
* - Adapter pattern for external feature flag services
|
|
26
|
+
*
|
|
27
|
+
* Inheritance chain: useRegistry → createSelection → createGroup → createFeatures
|
|
28
|
+
* Integrates with useTokens for token-based features.
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new features instance.
|
|
32
|
+
*
|
|
33
|
+
* @param options The options for the features instance.
|
|
34
|
+
* @template Z The type of the feature ticket.
|
|
35
|
+
* @template E The type of the feature context.
|
|
36
|
+
* @returns A new features instance.
|
|
37
|
+
*
|
|
38
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-features
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* import { createFeatures } from '@vuetify/v0'
|
|
43
|
+
*
|
|
44
|
+
* const [useFeatures, provideFeaturesContext, context] = createFeatures({
|
|
45
|
+
* namespace: 'v0:features',
|
|
46
|
+
* features: {
|
|
47
|
+
* 'dark-mode': true,
|
|
48
|
+
* 'theme-color': { $variation: 'blue' },
|
|
49
|
+
* },
|
|
50
|
+
* })
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
function createFeatures(_options = {}) {
|
|
54
|
+
const { features, ...options } = _options;
|
|
55
|
+
const tokens = createTokens(features, { flat: true });
|
|
56
|
+
const registry = createGroup({
|
|
57
|
+
...options,
|
|
58
|
+
reactive: true
|
|
59
|
+
});
|
|
60
|
+
for (const [id, { value }] of tokens.entries()) register({
|
|
61
|
+
id,
|
|
62
|
+
value
|
|
63
|
+
});
|
|
64
|
+
function variation(id, fallback = null) {
|
|
65
|
+
const ticket = registry.get(id);
|
|
66
|
+
if (!ticket) return fallback;
|
|
67
|
+
return /* @__PURE__ */ isObject(ticket.value) ? ticket.value.$variation ?? fallback : ticket.value ?? fallback;
|
|
68
|
+
}
|
|
69
|
+
function register(registration = {}) {
|
|
70
|
+
const item = {
|
|
71
|
+
value: false,
|
|
72
|
+
...registration
|
|
73
|
+
};
|
|
74
|
+
const ticket = registry.register(item);
|
|
75
|
+
if (/* @__PURE__ */ isBoolean(ticket.value) && ticket.value === true || /* @__PURE__ */ isObject(ticket.value) && /* @__PURE__ */ isBoolean(ticket.value.$value) && ticket.value.$value === true) registry.select(ticket.id);
|
|
76
|
+
return ticket;
|
|
77
|
+
}
|
|
78
|
+
function sync(flags) {
|
|
79
|
+
for (const [id, value] of Object.entries(flags)) if (registry.get(id)) {
|
|
80
|
+
const shouldSelect = /* @__PURE__ */ isBoolean(value) ? value === true : /* @__PURE__ */ isObject(value) && /* @__PURE__ */ isBoolean(value.$value) && value.$value === true;
|
|
81
|
+
registry.upsert(id, { value });
|
|
82
|
+
if (shouldSelect) registry.select(id);
|
|
83
|
+
else registry.unselect(id);
|
|
84
|
+
} else register({
|
|
85
|
+
id,
|
|
86
|
+
value
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
function onboard(registrations) {
|
|
90
|
+
return registry.batch(() => registrations.map((registration) => register(registration)));
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
...registry,
|
|
94
|
+
variation,
|
|
95
|
+
register,
|
|
96
|
+
onboard,
|
|
97
|
+
sync,
|
|
98
|
+
get size() {
|
|
99
|
+
return registry.size;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function createFeaturesFallback() {
|
|
104
|
+
return {
|
|
105
|
+
size: 0,
|
|
106
|
+
variation: (_id, fallback = null) => fallback,
|
|
107
|
+
sync: () => {}
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
const [createFeaturesContext, createFeaturesPlugin, useFeatures] = createPluginContext("v0:features", (options) => createFeatures(options), {
|
|
111
|
+
fallback: () => createFeaturesFallback(),
|
|
112
|
+
setup: (context, app, { adapter }) => {
|
|
113
|
+
if (!adapter) return;
|
|
114
|
+
for (const a of /* @__PURE__ */ isArray(adapter) ? adapter : [adapter]) {
|
|
115
|
+
context.sync(a.setup((flags) => context.sync(flags)));
|
|
116
|
+
if (/* @__PURE__ */ isFunction(a.dispose)) app.onUnmount(() => a.dispose());
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
//#endregion
|
|
122
|
+
export { FeaturesAdapter as a, useFeatures as i, createFeaturesContext as n, createFeaturesPlugin as r, createFeatures as t };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { p as isString } from "./utilities-BqS1sC1W.mjs";
|
|
2
|
+
import { o as createPluginContext } from "./useLogger-CO9JwbSJ.mjs";
|
|
3
|
+
import { t as createTokens } from "./createTokens-BlhLdHXE.mjs";
|
|
4
|
+
import { t as createSingle } from "./createSingle-B59ya3aa.mjs";
|
|
5
|
+
import { t as toArray } from "./toArray-DIeXVX1C.mjs";
|
|
6
|
+
import { t as Vuetify0LocaleAdapter } from "./v0-BtQCSBOG.mjs";
|
|
7
|
+
|
|
8
|
+
//#region src/composables/useLocale/index.ts
|
|
9
|
+
/**
|
|
10
|
+
* @module useLocale
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* Internationalization (i18n) composable with adapter pattern for message translation.
|
|
14
|
+
*
|
|
15
|
+
* Key features:
|
|
16
|
+
* - Locale selection with createSingle
|
|
17
|
+
* - Token-based message storage with useTokens
|
|
18
|
+
* - Numbered and named placeholder support ({0}, {name})
|
|
19
|
+
* - Number formatting with Intl.NumberFormat
|
|
20
|
+
* - Adapter pattern for integration with i18n providers
|
|
21
|
+
*
|
|
22
|
+
* Integrates with createSingle for locale selection and useTokens for message resolution.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Creates a new locale instance.
|
|
26
|
+
*
|
|
27
|
+
* @param options The options for the locale instance.
|
|
28
|
+
* @template Z The type of the locale ticket.
|
|
29
|
+
* @template E The type of the locale context.
|
|
30
|
+
* @returns A new locale instance.
|
|
31
|
+
*
|
|
32
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-locale
|
|
33
|
+
*/
|
|
34
|
+
function createLocale(_options = {}) {
|
|
35
|
+
const { adapter = new Vuetify0LocaleAdapter(), messages = {}, ...options } = _options;
|
|
36
|
+
const tokens = createTokens(messages);
|
|
37
|
+
const registry = createSingle(options);
|
|
38
|
+
for (const id in messages) {
|
|
39
|
+
registry.register({ id });
|
|
40
|
+
if (id === options.default && !registry.selectedId.value) registry.select(id);
|
|
41
|
+
}
|
|
42
|
+
function t(key, params, fallback) {
|
|
43
|
+
const locale = registry.selectedId.value;
|
|
44
|
+
const args = toArray(params);
|
|
45
|
+
if (!locale) return adapter.t(fallback ?? key, ...args);
|
|
46
|
+
const path = `${locale}.${key}`;
|
|
47
|
+
const message = tokens.get(path)?.value;
|
|
48
|
+
const template = /* @__PURE__ */ isString(message) ? resolve(locale, message) : fallback ?? key;
|
|
49
|
+
return adapter.t(template, ...args);
|
|
50
|
+
}
|
|
51
|
+
function n(value, ...params) {
|
|
52
|
+
return adapter.n(value, registry.selectedId.value, ...params);
|
|
53
|
+
}
|
|
54
|
+
function resolve(locale, str, visited = /* @__PURE__ */ new Set()) {
|
|
55
|
+
return str.replace(/{([a-zA-Z0-9.-_]+)}/g, (match, key) => {
|
|
56
|
+
const [prefix, ...rest] = key.split(".");
|
|
57
|
+
const target = registry.has(prefix) ? prefix : locale;
|
|
58
|
+
const path = `${target}.${registry.has(prefix) ? rest.join(".") : key}`;
|
|
59
|
+
if (visited.has(path)) return match;
|
|
60
|
+
visited.add(path);
|
|
61
|
+
const resolved = tokens.get(path)?.value;
|
|
62
|
+
if (/* @__PURE__ */ isString(resolved)) return resolve(target, resolved, visited);
|
|
63
|
+
return match;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
...registry,
|
|
68
|
+
t,
|
|
69
|
+
n,
|
|
70
|
+
get size() {
|
|
71
|
+
return registry.size;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function createLocaleFallback() {
|
|
76
|
+
return {
|
|
77
|
+
size: 0,
|
|
78
|
+
t: (key, _params, fallback) => fallback ?? key,
|
|
79
|
+
n: String
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const [createLocaleContext, createLocalePlugin, useLocale] = createPluginContext("v0:locale", (options) => createLocale(options), { fallback: () => createLocaleFallback() });
|
|
83
|
+
|
|
84
|
+
//#endregion
|
|
85
|
+
export { useLocale as a, createLocalePlugin as i, createLocaleContext as n, createLocaleFallback as r, createLocale as t };
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { s as __LOGGER_ENABLED__, t as IN_BROWSER } from "./globals-B_GVfG06.mjs";
|
|
2
|
+
import { h as isUndefined } from "./utilities-BqS1sC1W.mjs";
|
|
3
|
+
import { i as useContext, n as createContext, t as createTrinity } from "./createTrinity-EeHQSsb6.mjs";
|
|
4
|
+
import { t as Vuetify0LoggerAdapter } from "./v0-CtjuUUPl.mjs";
|
|
5
|
+
import { hasInjectionContext } from "vue";
|
|
6
|
+
|
|
7
|
+
//#region src/composables/createPlugin/index.ts
|
|
8
|
+
/**
|
|
9
|
+
* @module createPlugin
|
|
10
|
+
*
|
|
11
|
+
* @see https://vuejs.org/guide/reusability/plugins.html
|
|
12
|
+
* @see https://0.vuetifyjs.com/composables/foundation/create-plugin
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* Factory for creating Vue plugins with proper context provision.
|
|
16
|
+
*
|
|
17
|
+
* Wraps the provide function in app.runWithContext() to ensure proper execution context,
|
|
18
|
+
* allowing plugins to safely provide dependency injection contexts at the application level.
|
|
19
|
+
*
|
|
20
|
+
* Also exports `createPluginContext` — a higher-level factory that generates the standard
|
|
21
|
+
* context/plugin/consumer triple for plugin composables, eliminating boilerplate.
|
|
22
|
+
*/
|
|
23
|
+
const INSTALLED = Symbol.for("v0:installed-plugins");
|
|
24
|
+
function getInstalled(app) {
|
|
25
|
+
const ctx = app._context;
|
|
26
|
+
return ctx[INSTALLED] ??= /* @__PURE__ */ new Set();
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new Vue plugin.
|
|
30
|
+
*
|
|
31
|
+
* @param options The plugin options.
|
|
32
|
+
* @returns A new Vue plugin.
|
|
33
|
+
*
|
|
34
|
+
* @see https://0.vuetifyjs.com/composables/foundation/create-plugin#create-plugin
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* export const [useContext, provideContext] = createContext<MyContext>('my-plugin')
|
|
39
|
+
*
|
|
40
|
+
* const context = {}
|
|
41
|
+
*
|
|
42
|
+
* export const MyPlugin = createPlugin({
|
|
43
|
+
* namespace: 'my-plugin',
|
|
44
|
+
* provide: (app) => {
|
|
45
|
+
* provideContext(context, app)
|
|
46
|
+
* },
|
|
47
|
+
* setup: (app) => {
|
|
48
|
+
* // Optional setup logic
|
|
49
|
+
* },
|
|
50
|
+
* })
|
|
51
|
+
*/
|
|
52
|
+
function createPlugin(options) {
|
|
53
|
+
return { install(app) {
|
|
54
|
+
app.runWithContext(() => {
|
|
55
|
+
options.provide(app);
|
|
56
|
+
const installed = getInstalled(app);
|
|
57
|
+
if (installed.has(options.namespace)) return;
|
|
58
|
+
installed.add(options.namespace);
|
|
59
|
+
options.setup?.(app);
|
|
60
|
+
});
|
|
61
|
+
} };
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Creates the three standard functions for a plugin composable.
|
|
65
|
+
*
|
|
66
|
+
* @param defaultNamespace The default DI namespace string (e.g. `'v0:logger'`).
|
|
67
|
+
* @param factory Function that creates the composable context instance from options.
|
|
68
|
+
* @param config Optional setup callback and fallback factory.
|
|
69
|
+
* @returns A readonly tuple: `[createXContext, createXPlugin, useX]`.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* // Simple — no setup or fallback
|
|
74
|
+
* export const [createStorageContext, createStoragePlugin, useStorage] =
|
|
75
|
+
* createPluginContext('v0:storage', options => createStorage(options))
|
|
76
|
+
*
|
|
77
|
+
* // With fallback — safe outside component instances
|
|
78
|
+
* export const [createLoggerContext, createLoggerPlugin, useLogger] =
|
|
79
|
+
* createPluginContext('v0:logger', options => createLogger(options), {
|
|
80
|
+
* fallback: ns => createFallbackLogger(ns),
|
|
81
|
+
* setup: (context) => {
|
|
82
|
+
* if (__DEV__ && IN_BROWSER) (window as any).__v0Logger__ = context
|
|
83
|
+
* },
|
|
84
|
+
* })
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
function createPluginContext(defaultNamespace, factory, config) {
|
|
88
|
+
function createXContext(_options = {}) {
|
|
89
|
+
const { namespace = defaultNamespace, ...options } = _options;
|
|
90
|
+
const [_use, _provide] = createContext(namespace);
|
|
91
|
+
const context = factory(options);
|
|
92
|
+
function provide$1(_context = context, app) {
|
|
93
|
+
return _provide(_context, app);
|
|
94
|
+
}
|
|
95
|
+
return createTrinity(_use, provide$1, context);
|
|
96
|
+
}
|
|
97
|
+
function createXPlugin(_options = {}) {
|
|
98
|
+
const { namespace = defaultNamespace, ...options } = _options;
|
|
99
|
+
const [, provide$1, context] = createXContext({
|
|
100
|
+
...options,
|
|
101
|
+
namespace
|
|
102
|
+
});
|
|
103
|
+
return createPlugin({
|
|
104
|
+
namespace,
|
|
105
|
+
provide: (app) => {
|
|
106
|
+
provide$1(context, app);
|
|
107
|
+
},
|
|
108
|
+
setup: config?.setup ? (app) => config.setup(context, app, options) : void 0
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function useX(namespace = defaultNamespace) {
|
|
112
|
+
if (config?.fallback) {
|
|
113
|
+
const instance = config.fallback(namespace);
|
|
114
|
+
if (!hasInjectionContext()) return instance;
|
|
115
|
+
return useContext(namespace, instance);
|
|
116
|
+
}
|
|
117
|
+
return useContext(namespace);
|
|
118
|
+
}
|
|
119
|
+
return [
|
|
120
|
+
createXContext,
|
|
121
|
+
createXPlugin,
|
|
122
|
+
useX
|
|
123
|
+
];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
//#endregion
|
|
127
|
+
//#region src/composables/useLogger/index.ts
|
|
128
|
+
/**
|
|
129
|
+
* @module useLogger
|
|
130
|
+
*
|
|
131
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-logger
|
|
132
|
+
*
|
|
133
|
+
* @remarks
|
|
134
|
+
* Logging composable with adapter pattern supporting console, consola, and pino.
|
|
135
|
+
*
|
|
136
|
+
* Key features:
|
|
137
|
+
* - Multiple log levels (trace, debug, info, warn, error, fatal)
|
|
138
|
+
* - Adapter pattern for console/consola/pino integration
|
|
139
|
+
* - Enable/disable logging
|
|
140
|
+
* - Fallback logger for undefined loggers
|
|
141
|
+
* - Context logging support
|
|
142
|
+
*
|
|
143
|
+
* Uses adapter pattern to abstract logging implementation.
|
|
144
|
+
*/
|
|
145
|
+
/**
|
|
146
|
+
* Creates a new logger instance.
|
|
147
|
+
*
|
|
148
|
+
* @param options The options for the logger instance.
|
|
149
|
+
* @returns A new logger instance.
|
|
150
|
+
*
|
|
151
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-logger
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```ts
|
|
155
|
+
* import { createLogger } from '@vuetify/v0'
|
|
156
|
+
*
|
|
157
|
+
* const logger = createLogger({
|
|
158
|
+
* level: 'debug',
|
|
159
|
+
* prefix: '[MyApp]',
|
|
160
|
+
* })
|
|
161
|
+
*
|
|
162
|
+
* logger.info('This is an info message')
|
|
163
|
+
* logger.debug('This is a debug message')
|
|
164
|
+
* logger.error('This is an error message')
|
|
165
|
+
* logger.level('debug')
|
|
166
|
+
* logger.debug('This debug message will now be logged')
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
function createLogger(options = {}) {
|
|
170
|
+
const { adapter = new Vuetify0LoggerAdapter({ prefix: options.prefix }), level: initialLevel = "info", enabled: initialEnabled = __LOGGER_ENABLED__ } = options;
|
|
171
|
+
let currentLevel = initialLevel;
|
|
172
|
+
let isEnabled = initialEnabled;
|
|
173
|
+
function value(level$1) {
|
|
174
|
+
return {
|
|
175
|
+
trace: 0,
|
|
176
|
+
debug: 1,
|
|
177
|
+
info: 2,
|
|
178
|
+
warn: 3,
|
|
179
|
+
error: 4,
|
|
180
|
+
fatal: 5,
|
|
181
|
+
silent: 6
|
|
182
|
+
}[level$1] ?? 2;
|
|
183
|
+
}
|
|
184
|
+
function can(level$1) {
|
|
185
|
+
if (!isEnabled) return false;
|
|
186
|
+
return value(level$1) >= value(currentLevel);
|
|
187
|
+
}
|
|
188
|
+
function format(message) {
|
|
189
|
+
return message;
|
|
190
|
+
}
|
|
191
|
+
function debug(message, ...args) {
|
|
192
|
+
if (can("debug")) adapter.debug(format(message), ...args);
|
|
193
|
+
}
|
|
194
|
+
function info(message, ...args) {
|
|
195
|
+
if (can("info")) adapter.info(format(message), ...args);
|
|
196
|
+
}
|
|
197
|
+
function warn(message, ...args) {
|
|
198
|
+
if (can("warn")) adapter.warn(format(message), ...args);
|
|
199
|
+
}
|
|
200
|
+
function error(message, ...args) {
|
|
201
|
+
if (can("error")) adapter.error(format(message), ...args);
|
|
202
|
+
}
|
|
203
|
+
function trace(message, ...args) {
|
|
204
|
+
if (can("trace")) adapter.trace?.(format(message), ...args);
|
|
205
|
+
}
|
|
206
|
+
function fatal(message, ...args) {
|
|
207
|
+
if (can("fatal")) adapter.fatal?.(format(message), ...args);
|
|
208
|
+
}
|
|
209
|
+
function level(newLevel) {
|
|
210
|
+
currentLevel = newLevel;
|
|
211
|
+
}
|
|
212
|
+
function current() {
|
|
213
|
+
return currentLevel;
|
|
214
|
+
}
|
|
215
|
+
function enabled() {
|
|
216
|
+
return isEnabled;
|
|
217
|
+
}
|
|
218
|
+
function enable() {
|
|
219
|
+
isEnabled = true;
|
|
220
|
+
}
|
|
221
|
+
function disable() {
|
|
222
|
+
isEnabled = false;
|
|
223
|
+
}
|
|
224
|
+
return {
|
|
225
|
+
debug,
|
|
226
|
+
info,
|
|
227
|
+
warn,
|
|
228
|
+
error,
|
|
229
|
+
trace,
|
|
230
|
+
fatal,
|
|
231
|
+
level,
|
|
232
|
+
current,
|
|
233
|
+
enabled,
|
|
234
|
+
enable,
|
|
235
|
+
disable
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
function createFallbackLogger(namespace = "v0:logger") {
|
|
239
|
+
function format(message, type) {
|
|
240
|
+
return `[${namespace} ${type}] ${message}`;
|
|
241
|
+
}
|
|
242
|
+
return {
|
|
243
|
+
debug: (message, ...args) => console.debug(format(message, "debug"), ...args),
|
|
244
|
+
info: (message, ...args) => console.info(format(message, "info"), ...args),
|
|
245
|
+
warn: (message, ...args) => console.warn(format(message, "warn"), ...args),
|
|
246
|
+
error: (message, ...args) => console.error(format(message, "error"), ...args),
|
|
247
|
+
trace: (message, ...args) => console.trace(format(message, "trace"), ...args),
|
|
248
|
+
fatal: (message, ...args) => console.error(format(message, "fatal"), ...args),
|
|
249
|
+
level: () => {},
|
|
250
|
+
current: () => "info",
|
|
251
|
+
enabled: () => true,
|
|
252
|
+
enable: () => {},
|
|
253
|
+
disable: () => {}
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Creates a new logger context.
|
|
258
|
+
*
|
|
259
|
+
* @param options The options for the logger context.
|
|
260
|
+
* @template E The type of the logger context.
|
|
261
|
+
* @returns A new logger context.
|
|
262
|
+
*
|
|
263
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-logger
|
|
264
|
+
*
|
|
265
|
+
* @example
|
|
266
|
+
* ```ts
|
|
267
|
+
* import { createLoggerContext } from '@vuetify/v0'
|
|
268
|
+
*
|
|
269
|
+
* export const [useAppLogger, provideAppLogger, appLogger] = createLoggerContext({
|
|
270
|
+
* namespace: 'app:logger',
|
|
271
|
+
* level: 'debug',
|
|
272
|
+
* })
|
|
273
|
+
* ```
|
|
274
|
+
*/
|
|
275
|
+
const [createLoggerContext, createLoggerPlugin, useLogger] = createPluginContext("v0:logger", (options) => createLogger(options), {
|
|
276
|
+
fallback: (ns) => createFallbackLogger(ns),
|
|
277
|
+
setup: (context, _app, _options) => {
|
|
278
|
+
if (!/* @__PURE__ */ isUndefined(process.env.NODE_ENV !== "production") && process.env.NODE_ENV !== "production" && IN_BROWSER) window.__v0Logger__ = context;
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
//#endregion
|
|
283
|
+
export { createPlugin as a, useLogger as i, createLoggerContext as n, createPluginContext as o, createLoggerPlugin as r, createLogger as t };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { o as createPluginContext } from "./useLogger-CO9JwbSJ.mjs";
|
|
2
|
+
import { t as createTokens } from "./createTokens-BlhLdHXE.mjs";
|
|
3
|
+
import { t as toArray } from "./toArray-DIeXVX1C.mjs";
|
|
4
|
+
import { t as Vuetify0PermissionAdapter } from "./v0-B40YkIQ-.mjs";
|
|
5
|
+
|
|
6
|
+
//#region src/composables/usePermissions/index.ts
|
|
7
|
+
/**
|
|
8
|
+
* @module usePermissions
|
|
9
|
+
*
|
|
10
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-permissions
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* Permission management composable with support for RBAC and ABAC patterns.
|
|
14
|
+
*
|
|
15
|
+
* Key features:
|
|
16
|
+
* - Role-Based Access Control (RBAC) support
|
|
17
|
+
* - Attribute-Based Access Control (ABAC) with context
|
|
18
|
+
* - Functional permission conditions
|
|
19
|
+
* - Token-based permission storage
|
|
20
|
+
* - Adapter pattern for custom permission systems
|
|
21
|
+
*
|
|
22
|
+
* Built on useTokens for flexible permission configuration.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Creates a new permissions instance.
|
|
26
|
+
*
|
|
27
|
+
* @param options The options for the permissions instance.
|
|
28
|
+
* @template Z The type of the permission ticket.
|
|
29
|
+
* @template E The type of the permission context.
|
|
30
|
+
* @returns A new permissions instance.
|
|
31
|
+
*
|
|
32
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-permissions
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* import { createPermissions } from '@vuetify/v0'
|
|
37
|
+
*
|
|
38
|
+
* const [usePermissions, providePermissions] = createPermissions({
|
|
39
|
+
* namespace: 'v0:permissions',
|
|
40
|
+
* permissions: {
|
|
41
|
+
* admin: [['read', 'users']],
|
|
42
|
+
* editor: [['edit', 'posts']],
|
|
43
|
+
* },
|
|
44
|
+
* })
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
function createPermissions(_options = {}) {
|
|
48
|
+
const { adapter = new Vuetify0PermissionAdapter(), permissions = {}, ...options } = _options;
|
|
49
|
+
const record = {};
|
|
50
|
+
for (const role in permissions) {
|
|
51
|
+
if (!record[role]) record[role] = {};
|
|
52
|
+
for (const [actions, subjects, condition = true] of permissions[role]) for (const action of toArray(actions)) for (const subject of toArray(subjects)) {
|
|
53
|
+
if (!record[role][action]) record[role][action] = {};
|
|
54
|
+
record[role][action][subject] = condition;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const tokens = createTokens(record, options);
|
|
58
|
+
function can(id, action, subject, context = {}) {
|
|
59
|
+
return adapter.can(id, action, subject, context, tokens);
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
...tokens,
|
|
63
|
+
can
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Creates a new permissions context.
|
|
68
|
+
*
|
|
69
|
+
* @param options The options for the permissions context.
|
|
70
|
+
* @template Z The type of the permission ticket.
|
|
71
|
+
* @template E The type of the permission context.
|
|
72
|
+
* @returns A new permissions context.
|
|
73
|
+
*
|
|
74
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-permissions
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* import { createPermissionsContext } from '@vuetify/v0'
|
|
79
|
+
*
|
|
80
|
+
* export const [usePermissions, providePermissions, context] = createPermissionsContext({
|
|
81
|
+
* namespace: 'app:permissions',
|
|
82
|
+
* permissions: {
|
|
83
|
+
* admin: [['read', 'users'], ['edit', 'users']],
|
|
84
|
+
* editor: [['edit', 'posts']],
|
|
85
|
+
* },
|
|
86
|
+
* })
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
function createPermissionsFallback() {
|
|
90
|
+
return {
|
|
91
|
+
size: 0,
|
|
92
|
+
can: () => false
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
const [createPermissionsContext, createPermissionsPlugin, usePermissions] = createPluginContext("v0:permissions", (options) => createPermissions(options), { fallback: () => createPermissionsFallback() });
|
|
96
|
+
/**
|
|
97
|
+
* Creates a new permissions plugin.
|
|
98
|
+
*
|
|
99
|
+
* @param options The options for the permissions plugin.
|
|
100
|
+
* @template Z The type of the permission ticket.
|
|
101
|
+
* @template E The type of the permission context.
|
|
102
|
+
* @returns A new permissions plugin.
|
|
103
|
+
*
|
|
104
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-permissions
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* import { createApp } from 'vue'
|
|
109
|
+
* import { createPermissionsPlugin } from '@vuetify/v0'
|
|
110
|
+
* import App from './App.vue'
|
|
111
|
+
*
|
|
112
|
+
* const app = createApp(App)
|
|
113
|
+
*
|
|
114
|
+
* app.use(
|
|
115
|
+
* createPermissionsPlugin({
|
|
116
|
+
* permissions: {
|
|
117
|
+
* admin: [['read', 'users']],
|
|
118
|
+
* editor: [['edit', 'posts']],
|
|
119
|
+
* },
|
|
120
|
+
* })
|
|
121
|
+
* )
|
|
122
|
+
*
|
|
123
|
+
* app.mount('#app')
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
|
|
127
|
+
//#endregion
|
|
128
|
+
export { usePermissions as i, createPermissionsContext as n, createPermissionsPlugin as r, createPermissions as t };
|