@gluhar/core 4.1.5 → 6.0.0-next.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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [4.2.0](https://github.com/gluharco/gluhar/compare/@gluhar/core@4.1.5...@gluhar/core@4.2.0) (2026-04-28)
7
+
8
+
9
+ ### 🚀 Enhancements
10
+
11
+ - Bump minor ([97ce7ec](https://github.com/gluharco/gluhar/commit/97ce7ece5e0d16846269319bdce425d497895ff1))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [4.1.5](https://github.com/gluharco/gluhar/compare/@gluhar/core@4.1.4...@gluhar/core@4.1.5) (2026-03-23)
7
18
 
8
19
  **📝 Note:** Version bump only for package @gluhar/core
package/README.md CHANGED
@@ -20,39 +20,33 @@ My new Nuxt module for doing amazing things.
20
20
  <!-- - [🏀 Online playground](https://stackblitz.com/github/your-org/my-module?file=playground%2Fapp.vue) -->
21
21
  <!-- - [📖 &nbsp;Documentation](https://example.com) -->
22
22
 
23
- ## Features
23
+ Shared composables and utils, installed by `@gluhar/app`. Installs `@nuxtjs/device`.
24
24
 
25
- <!-- Highlight some of the features your module provide here -->
26
- - ⛰ &nbsp;Foo
27
- - 🚠 &nbsp;Bar
28
- - 🌲 &nbsp;Baz
25
+ ## `useResponsive()`
29
26
 
30
- ## Quick Setup
27
+ The one breakpoint composable for every gluhar project. It replaces the project-level `useMobile` copies.
31
28
 
32
- 1. Add `my-module` dependency to your project
29
+ **For behaviour only** — event handlers, GSAP/ScrollTrigger setup, measuring. Responsive layout is Tailwind variants in the template; never put a width flag in `v-if` / `:class`.
33
30
 
34
- ```bash
35
- # Using pnpm
36
- pnpm add -D my-module
37
-
38
- # Using yarn
39
- yarn add --dev my-module
31
+ ```ts
32
+ const { isMobileDevice, mounted, mobile, tablet, desktop, touch, up, down, between } =
33
+ useResponsive();
40
34
 
41
- # Using npm
42
- npm install --save-dev my-module
35
+ const nav = up("nav"); // any --breakpoint-* the project declares
36
+ onMounted(() => {
37
+ if (desktop.value) initParallax(); // already correct here
38
+ });
43
39
  ```
44
40
 
45
- 2. Add `my-module` to the `modules` section of `nuxt.config.ts`
46
-
47
- ```js
48
- export default defineNuxtConfig({
49
- modules: [
50
- 'my-module'
51
- ]
52
- })
53
- ```
41
+ | | Source | On the server | Safe in markup |
42
+ |---|---|---|---|
43
+ | `isMobileDevice` | user agent | real value | yes — but it's a device guess, not a width |
44
+ | `mobile` `tablet` `desktop` `wide` `touch` `tabletExact` `desktopExact` `up()` `down()` `between()` | viewport width | `false` | no |
54
45
 
55
- That's it! You can now use My Module in your Nuxt app ✨
46
+ - Width flags stay `false` through the first hydration so server and client renders agree, then switch on in the composable's own `onMounted` — before any `onMounted` you register after calling it. Components created after hydration get live values immediately.
47
+ - Breakpoints are the project's `--breakpoint-*` CSS values (read by `@gluhar/theme`), defaulting to `tablet` 768 / `desktop` 1200 / `wide` 2000.
48
+ - `>=` comparisons, like CSS `min-width`: `tablet` and `tablet:` agree at every width, including exactly 768.
49
+ - `mobile` = below `tablet`; `touch` = below `desktop` (a width, not touch capability).
56
50
 
57
51
  ## Development
58
52
 
@@ -0,0 +1,5 @@
1
+ module.exports = function(...args) {
2
+ return import('./module.mjs').then(m => m.default.call(this, ...args))
3
+ }
4
+ const _meta = module.exports.meta = require('./module.json')
5
+ module.exports.getMeta = () => Promise.resolve(_meta)
@@ -0,0 +1,8 @@
1
+ import * as _nuxt_schema from '@nuxt/schema';
2
+
3
+ interface GluharCoreOptions {
4
+ }
5
+ declare const _default: _nuxt_schema.NuxtModule<GluharCoreOptions, GluharCoreOptions, false>;
6
+
7
+ export { _default as default };
8
+ export type { GluharCoreOptions };
@@ -0,0 +1,8 @@
1
+ import * as _nuxt_schema from '@nuxt/schema';
2
+
3
+ interface GluharCoreOptions {
4
+ }
5
+ declare const _default: _nuxt_schema.NuxtModule<GluharCoreOptions, GluharCoreOptions, false>;
6
+
7
+ export { _default as default };
8
+ export type { GluharCoreOptions };
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "@gluhar/core",
3
+ "configKey": "gluharCore",
4
+ "version": "6.0.0-next.0",
5
+ "builder": {
6
+ "@nuxt/module-builder": "0.8.3",
7
+ "unbuild": "2.0.0"
8
+ }
9
+ }
@@ -0,0 +1,18 @@
1
+ import { defineNuxtModule, createResolver, installModule, addImportsDir } from '@nuxt/kit';
2
+
3
+ const module = defineNuxtModule({
4
+ meta: {
5
+ name: "@gluhar/core",
6
+ configKey: "gluharCore"
7
+ },
8
+ // Default configuration options of the Nuxt module
9
+ defaults: {},
10
+ async setup() {
11
+ const { resolve } = createResolver(import.meta.url);
12
+ await installModule("@nuxtjs/device");
13
+ addImportsDir(resolve("runtime/composables"));
14
+ addImportsDir(resolve("runtime/utils"));
15
+ }
16
+ });
17
+
18
+ export { module as default };
@@ -0,0 +1,3 @@
1
+ export declare const useClientOnly: () => {
2
+ isClient: import("vue").Ref<boolean, boolean>;
3
+ };
@@ -0,0 +1,8 @@
1
+ import { onMounted, ref } from "vue";
2
+ export const useClientOnly = () => {
3
+ const mounted = ref(false);
4
+ onMounted(() => {
5
+ mounted.value = true;
6
+ });
7
+ return { isClient: mounted };
8
+ };
@@ -0,0 +1,42 @@
1
+ import { type ComputedRef } from "vue";
2
+ import type { GluharBreakpoints } from "../types.js";
3
+ /**
4
+ * Viewport state for BEHAVIOUR — event handlers, GSAP/ScrollTrigger setup,
5
+ * imperative measurement. Never for layout: responsive layout is Tailwind
6
+ * variants in the template (`tablet:`, `desktop:`), which the server renders
7
+ * for every width with no JS and no hydration risk.
8
+ *
9
+ * Two kinds of signal, kept apart on purpose:
10
+ *
11
+ * - `isMobileDevice` — user-agent based, identical on server and client. The
12
+ * only one safe in `v-if` / `:class` / props. A device guess, not a width.
13
+ *
14
+ * - Width flags (`mobile`, `tablet`, `desktop`, `up("nav")`, …) — `false` on
15
+ * the server and through the first hydration, so the server render and the
16
+ * first client render agree by construction. They switch on in this
17
+ * composable's own `onMounted`, which Vue runs before any `onMounted` you
18
+ * register later in the same setup. Components created after hydration
19
+ * (client-side navigation, SPA mode) get live values from the first render.
20
+ *
21
+ * Breakpoints come from the project's CSS (`--breakpoint-*` in the main
22
+ * stylesheet's `@theme`, read at build time by @gluhar/theme), so JS and CSS
23
+ * cannot drift. Comparisons are `>=`, matching CSS `min-width`: at exactly the
24
+ * breakpoint width, `tablet:` applies and `tablet` is true.
25
+ */
26
+ export declare const useResponsive: () => {
27
+ isMobileDevice: boolean;
28
+ /** True once hydrated — for guarding client-only behaviour explicitly. */
29
+ mounted: any;
30
+ breakpoints: GluharBreakpoints;
31
+ up: (name: string) => ComputedRef<any>;
32
+ down: (name: string) => ComputedRef<any>;
33
+ between: (from: string, to: string) => ComputedRef<any>;
34
+ mobile: ComputedRef<any>;
35
+ tablet: ComputedRef<any>;
36
+ tabletExact: ComputedRef<any>;
37
+ desktop: ComputedRef<any>;
38
+ desktopExact: ComputedRef<any>;
39
+ wide: ComputedRef<any>;
40
+ /** Below desktop width. A width, not touch capability. */
41
+ touch: ComputedRef<any>;
42
+ };
@@ -0,0 +1,36 @@
1
+ import { computed, onMounted, ref } from "vue";
2
+ import { useBreakpoints } from "@vueuse/core";
3
+ import { useAppConfig, useDevice, useNuxtApp } from "#imports";
4
+ const DEFAULT_BREAKPOINTS = { tablet: 768, desktop: 1200, wide: 2e3 };
5
+ export const useResponsive = () => {
6
+ const nuxtApp = useNuxtApp();
7
+ const breakpoints = {
8
+ ...DEFAULT_BREAKPOINTS,
9
+ ...useAppConfig().gluhar?.breakpoints
10
+ };
11
+ const viewport = useBreakpoints(breakpoints);
12
+ const { isMobile: isMobileDevice } = useDevice();
13
+ const mounted = ref(import.meta.client && !nuxtApp.isHydrating);
14
+ if (!mounted.value) onMounted(() => mounted.value = true);
15
+ const gate = (source) => computed(() => mounted.value && source.value);
16
+ const up = (name) => gate(viewport.greaterOrEqual(name));
17
+ const down = (name) => gate(viewport.smaller(name));
18
+ const between = (from, to) => gate(viewport.between(from, to));
19
+ return {
20
+ isMobileDevice,
21
+ /** True once hydrated — for guarding client-only behaviour explicitly. */
22
+ mounted,
23
+ breakpoints,
24
+ up,
25
+ down,
26
+ between,
27
+ mobile: down("tablet"),
28
+ tablet: up("tablet"),
29
+ tabletExact: between("tablet", "desktop"),
30
+ desktop: up("desktop"),
31
+ desktopExact: between("desktop", "wide"),
32
+ wide: up("wide"),
33
+ /** Below desktop width. A width, not touch capability. */
34
+ touch: down("desktop")
35
+ };
36
+ };
@@ -0,0 +1,18 @@
1
+ import { breakpointsTailwind } from "@vueuse/core";
2
+ export type NonNegativeInteger<T extends number> = number extends T ? never : `${T}` extends `-${string}` | `${string}.${string}` ? never : T;
3
+ /** Tailwind's default screens (sm…2xl), still present in v4. */
4
+ export type Breakpoint = keyof typeof breakpointsTailwind;
5
+ /** Breakpoint name -> min-width in px, as declared in the project's CSS. */
6
+ export type GluharBreakpoints = Record<string, number>;
7
+ declare module "nuxt/schema" {
8
+ interface AppConfigInput {
9
+ gluhar?: {
10
+ breakpoints?: GluharBreakpoints;
11
+ };
12
+ }
13
+ interface AppConfig {
14
+ gluhar?: {
15
+ breakpoints?: GluharBreakpoints;
16
+ };
17
+ }
18
+ }
File without changes
@@ -0,0 +1,10 @@
1
+ export declare const capitalize: (s: string) => string;
2
+ export declare const envMode: () => "dev" | "prod";
3
+ /**
4
+ * Returns the base URL based on the environment mode.
5
+ *
6
+ * @param {string} baseUrl - The base URL to be used.
7
+ * @returns {string | undefined} - The base URL if the environment mode is "prod", otherwise undefined.
8
+ */
9
+ export declare const useBaseUrl: (baseUrl: string) => string | undefined;
10
+ export declare const asyncTimeout: (ms: number) => Promise<unknown>;
@@ -0,0 +1,6 @@
1
+ export const capitalize = (s) => s && s[0].toUpperCase() + s.slice(1);
2
+ export const envMode = () => process.env.NODE_ENV === "development" ? "dev" : "prod";
3
+ export const useBaseUrl = (baseUrl) => {
4
+ return envMode() === "prod" ? baseUrl : void 0;
5
+ };
6
+ export const asyncTimeout = (ms) => new Promise((res) => setTimeout(res, ms));
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Evaluates a project config file (e.g. `config/i18n.config.ts`) at build time.
3
+ *
4
+ * Relative paths resolve against `rootDir` — pass `nuxt.options.rootDir`.
5
+ * `process.cwd()` is only the fallback: it is wrong whenever Nuxt is started
6
+ * from another directory (`nuxi dev playground`, monorepos, `--cwd`).
7
+ */
8
+ export declare const readModule: <T extends Record<string, any>>(path: string | undefined, options?: {
9
+ rootDir?: string;
10
+ default?: boolean;
11
+ }) => Promise<T>;
@@ -0,0 +1,13 @@
1
+ import { readFileSync } from "fs";
2
+ import { isAbsolute, join } from "path";
3
+ import { evalModule } from "mlly";
4
+ export const readModule = async (path, options = {}) => {
5
+ if (!path) throw new Error("[@gluhar/core] readModule | No path provided.");
6
+ const p = isAbsolute(path) ? path : join(options.rootDir ?? process.cwd(), path);
7
+ const file = readFileSync(p)?.toString();
8
+ if (!file)
9
+ throw new Error("[@gluhar/core] readModule | File not found on path: " + p);
10
+ const sanitizedFile = file.replaceAll(" as const", "");
11
+ const module = await evalModule(sanitizedFile);
12
+ return options.default ? module.default : module;
13
+ };
@@ -0,0 +1,6 @@
1
+ import type { NonNegativeInteger } from "../types.js";
2
+ export declare const getRandomInt: (max?: number) => number;
3
+ export declare const getRandomBetween: (min: number, max: number) => number;
4
+ export declare const getRandomDigits: <N extends number>(count: NonNegativeInteger<N>) => number;
5
+ export declare const getRandomHex: <N extends number>(count?: NonNegativeInteger<N>) => string;
6
+ export declare const getUuid: () => string;
@@ -0,0 +1,5 @@
1
+ export const getRandomInt = (max = 100) => Math.floor(Math.random() * max);
2
+ export const getRandomBetween = (min, max) => getRandomInt(max - min + 1) + min;
3
+ export const getRandomDigits = (count) => getRandomBetween(9 * 10 ** (count - 1), 10 ** (count - 1));
4
+ export const getRandomHex = (count) => [...Array(count || 6)].map(() => getRandomBetween(0, 15).toString(16)).join("");
5
+ export const getUuid = () => `huuid-${getRandomHex()}-${getRandomHex()}-${getRandomHex()}`;
@@ -0,0 +1,2 @@
1
+ export * from "./generators.js";
2
+ export * from "./common.js";
@@ -0,0 +1,2 @@
1
+ export * from "./generators.js";
2
+ export * from "./common.js";
@@ -0,0 +1,7 @@
1
+ import type { NuxtModule } from '@nuxt/schema'
2
+
3
+ import type { default as Module } from './module.js'
4
+
5
+ export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
6
+
7
+ export { default } from './module.js'
@@ -0,0 +1,7 @@
1
+ import type { NuxtModule } from '@nuxt/schema'
2
+
3
+ import type { default as Module } from './module'
4
+
5
+ export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
6
+
7
+ export { default } from './module'
package/package.json CHANGED
@@ -1,13 +1,17 @@
1
1
  {
2
2
  "name": "@gluhar/core",
3
- "version": "4.1.5",
3
+ "version": "6.0.0-next.0",
4
4
  "description": "Gluhar Core packages.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/gluharco/gluhar.git",
8
+ "directory": "packages/core"
9
+ },
5
10
  "type": "module",
6
11
  "exports": {
7
12
  ".": {
8
- "types": "./dist/types.d.ts",
9
- "import": "./dist/module.mjs",
10
- "require": "./dist/module.cjs"
13
+ "types": "./dist/types.d.mts",
14
+ "import": "./dist/module.mjs"
11
15
  },
12
16
  "./utils/*": {
13
17
  "types": "./dist/runtime/utils/*.d.ts",
@@ -17,8 +21,8 @@
17
21
  "types": "./dist/runtime/types/index.d.ts"
18
22
  }
19
23
  },
20
- "main": "./dist/module.cjs",
21
- "types": "./dist/types.d.ts",
24
+ "main": "./dist/module.mjs",
25
+ "types": "./dist/types.d.mts",
22
26
  "files": [
23
27
  "dist",
24
28
  "CHANGELOG.md"
@@ -35,23 +39,26 @@
35
39
  "test:watch": "vitest watch"
36
40
  },
37
41
  "dependencies": {
38
- "@nuxt/kit": "^3.13.1",
42
+ "@nuxt/kit": "^4.5.0",
39
43
  "@nuxtjs/device": "^3.2.2",
40
- "@vueuse/core": "^11.0.3",
44
+ "@vueuse/core": "^14.1.0",
41
45
  "mlly": "^1.7.1"
42
46
  },
43
47
  "devDependencies": {
44
48
  "@nuxt/devtools": "latest",
45
- "@nuxt/eslint-config": "^0.5.6",
46
- "@nuxt/module-builder": "^0.8.3",
47
- "@nuxt/schema": "^3.13.1",
48
- "@nuxt/test-utils": "^3.14.1",
49
+ "@nuxt/eslint-config": "^1.9.0",
50
+ "@nuxt/module-builder": "^1.0.3",
51
+ "@nuxt/schema": "^4.5.0",
52
+ "@nuxt/test-utils": "^3.19.2",
49
53
  "@types/node": "^22.5.4",
50
54
  "changelogen": "^0.5.5",
51
55
  "copyfiles": "^2.4.1",
52
56
  "eslint": "^9.10.0",
53
- "nuxt": "^3.13.1",
54
- "vitest": "^2.0.5"
57
+ "nuxt": "^4.5.0",
58
+ "vitest": "^3.2.4"
59
+ },
60
+ "peerDependencies": {
61
+ "nuxt": "^4.5.0"
55
62
  },
56
- "gitHead": "a60bf29f338bc3af3212a3a8ed647f75c69a2c4a"
63
+ "gitHead": "8773cd99c43cbe6a7dc415e50af8b13a7b8d4daf"
57
64
  }