@ansh-ui/nuxt 0.2.0 → 0.3.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/dist/module.cjs +25 -1
- package/dist/module.cjs.map +1 -1
- package/dist/module.d.cts +2 -1
- package/dist/module.d.ts +2 -1
- package/dist/module.js +25 -1
- package/dist/module.js.map +1 -1
- package/package.json +6 -6
package/dist/module.cjs
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
var kit = require('@nuxt/kit');
|
|
4
4
|
|
|
5
5
|
// src/module.ts
|
|
6
|
+
|
|
7
|
+
// src/names.ts
|
|
6
8
|
var COMPONENT_NAMES = [
|
|
7
9
|
// Backgrounds
|
|
8
10
|
"AuroraBackground",
|
|
@@ -18,6 +20,13 @@ var COMPONENT_NAMES = [
|
|
|
18
20
|
"LiquidBlob",
|
|
19
21
|
"NoiseLayer",
|
|
20
22
|
"Spotlight",
|
|
23
|
+
"LightRays",
|
|
24
|
+
"Smoke",
|
|
25
|
+
"PowderExplosion",
|
|
26
|
+
"FloatingGeometry",
|
|
27
|
+
"Orbit",
|
|
28
|
+
"StrangeAttractor",
|
|
29
|
+
"Swarm",
|
|
21
30
|
// Behaviours
|
|
22
31
|
"MagneticButton",
|
|
23
32
|
"TiltCard",
|
|
@@ -28,6 +37,7 @@ var COMPONENT_NAMES = [
|
|
|
28
37
|
// Text
|
|
29
38
|
"GradientText",
|
|
30
39
|
"AnimatedText",
|
|
40
|
+
"ScrambleText",
|
|
31
41
|
// Providers
|
|
32
42
|
"MotionConfig",
|
|
33
43
|
"ThemeProvider",
|
|
@@ -100,6 +110,7 @@ var COMPONENT_NAMES = [
|
|
|
100
110
|
"Meter",
|
|
101
111
|
// Navigation
|
|
102
112
|
"Tabs",
|
|
113
|
+
"Carousel",
|
|
103
114
|
"Breadcrumbs",
|
|
104
115
|
"Stepper",
|
|
105
116
|
"Sidebar",
|
|
@@ -138,8 +149,21 @@ var COMPOSABLE_NAMES = [
|
|
|
138
149
|
"useTheme",
|
|
139
150
|
"useFieldControl",
|
|
140
151
|
"useFieldContext",
|
|
141
|
-
"useControllableState"
|
|
152
|
+
"useControllableState",
|
|
153
|
+
// Headless primitives. `useId` is deliberately absent: Nuxt ships its own auto-imported `useId`,
|
|
154
|
+
// and registering ours would shadow it app-wide.
|
|
155
|
+
"useAutoFocus",
|
|
156
|
+
"useFocusRestore",
|
|
157
|
+
"useFocusTrap",
|
|
158
|
+
"useRovingFocus",
|
|
159
|
+
"useDismiss",
|
|
160
|
+
"useScrollLock",
|
|
161
|
+
"usePresence",
|
|
162
|
+
"useAnchoredPosition",
|
|
163
|
+
"useTypeahead"
|
|
142
164
|
];
|
|
165
|
+
|
|
166
|
+
// src/module.ts
|
|
143
167
|
var module$1 = kit.defineNuxtModule({
|
|
144
168
|
meta: {
|
|
145
169
|
name: "@ansh-ui/nuxt",
|
package/dist/module.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/module.ts"],"names":["module","defineNuxtModule","addComponent","addImports","addPluginTemplate"],"mappings":";;;;;AA4EA,IAAM,eAAA,GAAkB;AAAA;AAAA,EAEtB,kBAAA;AAAA,EACA,cAAA;AAAA,EACA,kBAAA;AAAA,EACA,eAAA;AAAA,EACA,eAAA;AAAA,EACA,cAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAAA,EACA,WAAA;AAAA,EACA,OAAA;AAAA,EACA,YAAA;AAAA,EACA,YAAA;AAAA,EACA,WAAA;AAAA;AAAA,EAEA,gBAAA;AAAA,EACA,UAAA;AAAA,EACA,QAAA;AAAA,EACA,SAAA;AAAA,EACA,cAAA;AAAA,EACA,UAAA;AAAA;AAAA,EAEA,cAAA;AAAA,EACA,cAAA;AAAA;AAAA,EAEA,cAAA;AAAA,EACA,eAAA;AAAA;AAAA,EAEA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA,MAAA;AAAA,EACA,UAAA;AAAA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CAAU,OAAA,CAAQ,aAAA,IAAiB,MAAM,CAAC,CAAA;;AAAA;AAAA,qBAAA,EAGjD,IAAA,CAAK,SAAA,CAAU,OAAA,CAAQ,SAAA,IAAa,CAAC,CAAC;;AAAA;AAAA,qBAAA,EAGtC,IAAA,CAAK,SAAA,CAAU,OAAA,CAAQ,eAAA,IAAmB,IAAI,CAAC,CAAA;AAAA,oBAAA,EAChD,IAAA,CAAK,SAAA,CAAU,OAAA,CAAQ,cAAA,IAAkB,IAAI,CAAC,CAAA;AAAA;;AAAA;AAAA;AAAA;AAAA,CAAA;AAAA;AAAA,MAQ9D,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AACF,CAAC,CAAA;AAED,IAAO,cAAA,GAAQJ","file":"module.cjs","sourcesContent":["import { addComponent, addImports, addPluginTemplate, defineNuxtModule } from '@nuxt/kit'\nimport type { NuxtModule } from '@nuxt/schema'\nimport type { ReducedMotionMode } from '@ansh-ui/core'\n\n/**\n * The Ansh Nuxt module.\n *\n * Nuxt gets its own package rather than instructions in the docs because there are four things a\n * Nuxt app needs that a bare Vue app does not, and every one of them is a footgun if left to the\n * consumer:\n *\n * 1. **Auto-imports.** Nuxt users expect `<AuroraBackground />` to work with no import statement.\n * That requires registering each component with `addComponent`, which only a module can do.\n * 2. **Transpilation.** Nuxt's server bundle externalises dependencies by default. Our packages\n * ship ESM that Nitro can consume, but the `'use client'`-free Vue build still needs to be in\n * the transpile list for older Nuxt versions to resolve it consistently.\n * 3. **The theme flash.** A themed app renders server-side with no knowledge of the user's stored\n * preference, so the first paint is the wrong theme. The only fix is a blocking inline script in\n * `<head>`, injected before any stylesheet — which is a `nuxt.options.app.head` concern.\n * 4. **Motion configuration.** `reducedMotion`, `timeScale` and lifecycle pausing need to be applied\n * once, on the client, after hydration. A generated plugin is the right place.\n */\n\nexport interface ModuleOptions {\n /**\n * Register every component for auto-import. Default `true`.\n *\n * Nuxt's component discovery is lazy per-component, so registering all of them does not increase\n * bundle size — only the ones actually used in templates are included.\n */\n components?: boolean\n\n /**\n * Prefix for auto-imported component names. Default `''` (no prefix), giving\n * `<AuroraBackground />`. Set to `'A'` for `<AAuroraBackground />` if you need to avoid a clash\n * with your own components.\n */\n prefix?: string\n\n /** Register the composables (`useMotionValue`, `useInView`, …) for auto-import. Default `true`. */\n composables?: boolean\n\n /**\n * Inject `@ansh-ui/tokens/ansh.css` into the app's global CSS. Default `true`.\n *\n * Set `false` if you import it yourself, or if you are overriding the token layer and need\n * control over cascade order.\n */\n css?: boolean\n\n /**\n * Inject the blocking theme script into `<head>`. Default `true`.\n *\n * Without this a themed app paints the wrong theme for one frame on every cold load. The script\n * is ~150 bytes and runs before the first stylesheet, which is the only point at which the flash\n * can be prevented.\n */\n themeScript?: boolean\n\n /** `localStorage` key the theme script reads. Default `'ansh-theme'`. */\n themeStorageKey?: string\n\n /** Application-level reduced-motion override. Default `'auto'` (follow the OS). */\n reducedMotion?: ReducedMotionMode\n\n /** Global playback rate. `0.5` is slow motion everywhere. Default `1`. */\n timeScale?: number\n\n /** Pause all animation while the document is hidden. Default `true`. */\n pauseWhenHidden?: boolean\n\n /** Reduce quality on low battery where the platform exposes it. Default `true`. */\n respectBattery?: boolean\n}\n\n/** Components exported by `@ansh-ui/vue`, registered individually for lazy auto-import. */\nconst COMPONENT_NAMES = [\n // Backgrounds\n 'AuroraBackground',\n 'MeshGradient',\n 'AnimatedGradient',\n 'ParticleField',\n 'Constellation',\n 'MeteorShower',\n 'Rain',\n 'Snow',\n 'Fireflies',\n 'Waves',\n 'LiquidBlob',\n 'NoiseLayer',\n 'Spotlight',\n // Behaviours\n 'MagneticButton',\n 'TiltCard',\n 'Ripple',\n 'Marquee',\n 'ScrollReveal',\n 'Parallax',\n // Text\n 'GradientText',\n 'AnimatedText',\n // Providers\n 'MotionConfig',\n 'ThemeProvider',\n // Layout\n 'Stack',\n 'HStack',\n 'VStack',\n 'Grid',\n 'GridItem',\n 'Container',\n 'Divider',\n 'Spacer',\n 'Center',\n 'AspectRatio',\n 'ScrollArea',\n 'Resizable',\n // Forms\n 'Field',\n 'Fieldset',\n 'VisuallyHidden',\n 'Input',\n 'NumberInput',\n 'Textarea',\n 'Checkbox',\n 'ChoiceCard',\n 'Radio',\n 'RadioGroup',\n 'Switch',\n 'OptionList',\n 'Select',\n 'Combobox',\n 'Slider',\n 'RangeSlider',\n 'PinInput',\n 'TagsInput',\n 'Rating',\n 'Dropzone',\n 'ColorPicker',\n 'Calendar',\n 'DatePicker',\n 'DateRangePicker',\n // Overlays\n 'Popover',\n 'PopoverTrigger',\n 'PopoverContent',\n 'HoverCard',\n 'Tooltip',\n 'TooltipProvider',\n 'Dialog',\n 'AlertDialog',\n 'DialogFooter',\n 'Drawer',\n 'DropdownMenu',\n 'ContextMenu',\n // Data\n 'Table',\n 'DataTable',\n 'Pagination',\n 'Badge',\n 'Avatar',\n 'AvatarGroup',\n 'Kbd',\n 'Stat',\n 'EmptyState',\n 'DescriptionList',\n 'Timeline',\n 'CodeBlock',\n 'Progress',\n 'CircularProgress',\n 'Meter',\n // Navigation\n 'Tabs',\n 'Breadcrumbs',\n 'Stepper',\n 'Sidebar',\n 'AppShell',\n 'NavigationMenu',\n // Feedback\n 'Alert',\n 'Banner',\n 'Callout',\n // Disclosure\n 'Collapsible',\n 'Accordion',\n 'DisclosureList',\n // Motion\n 'Motion',\n 'AnimatePresence',\n 'Draggable',\n] as const\n\n/** Composables exported by `@ansh-ui/vue`, registered for auto-import. */\nconst COMPOSABLE_NAMES = [\n 'useMotionValue',\n 'useMotionRef',\n 'useMotionStyle',\n 'useSpringValue',\n 'useAnimate',\n 'useAnimatedFrom',\n 'useTicker',\n 'useInView',\n 'useElementSize',\n 'useScrollProgress',\n 'useWindowScroll',\n 'usePointer',\n 'useReducedMotion',\n 'useFrameBudget',\n 'useBehaviour',\n 'useMotionConfig',\n 'useTheme',\n 'useFieldControl',\n 'useFieldContext',\n 'useControllableState',\n] as const\n\n/**\n * The return type is annotated explicitly rather than inferred.\n *\n * Without it TypeScript emits a declaration referencing `@nuxt/schema` by its resolved pnpm path,\n * which is not portable — the generated `.d.ts` would only typecheck on a machine with an\n * identically-hashed store directory.\n */\nconst module: NuxtModule<ModuleOptions> = defineNuxtModule<ModuleOptions>({\n meta: {\n name: '@ansh-ui/nuxt',\n configKey: 'ansh',\n compatibility: {\n nuxt: '>=3.10.0',\n },\n },\n\n defaults: {\n components: true,\n prefix: '',\n composables: true,\n css: true,\n themeScript: true,\n themeStorageKey: 'ansh-theme',\n reducedMotion: 'auto',\n timeScale: 1,\n pauseWhenHidden: true,\n respectBattery: true,\n },\n\n setup(options, nuxt) {\n // --- Transpile ---------------------------------------------------------\n // Nuxt externalises dependencies for the server build. Our packages are ESM-only and reference\n // browser globals inside functions (never at module scope), so they are SSR-safe — but Vite's\n // SSR resolver needs them in `noExternal` to consistently pick the ESM entry across the Nuxt\n // versions we support.\n nuxt.options.build.transpile.push('@ansh-ui/vue', '@ansh-ui/core', '@ansh-ui/tokens')\n\n // --- Global CSS --------------------------------------------------------\n if (options.css) {\n // Unshifted rather than pushed so the token layer lands *before* the application's own CSS.\n // Tokens are defaults meant to be overridden; if they came last they would win against the\n // consumer's overrides, which is the opposite of what a token layer should do.\n nuxt.options.css.unshift('@ansh-ui/tokens/ansh.css')\n }\n\n // --- Components --------------------------------------------------------\n if (options.components) {\n for (const name of COMPONENT_NAMES) {\n addComponent({\n name: `${options.prefix ?? ''}${name}`,\n export: name,\n filePath: '@ansh-ui/vue',\n // Every component mounts its effect in `onMounted`, so the server renders only the host\n // element. That is intentional and correct: the canvas has no meaningful server\n // representation, and rendering one would guarantee a hydration mismatch.\n mode: 'all',\n })\n }\n }\n\n // --- Composables -------------------------------------------------------\n if (options.composables) {\n addImports(\n COMPOSABLE_NAMES.map((name) => ({\n name,\n from: '@ansh-ui/vue',\n })),\n )\n }\n\n // --- Theme flash prevention -------------------------------------------\n if (options.themeScript) {\n const key = options.themeStorageKey ?? 'ansh-theme'\n nuxt.options.app.head = nuxt.options.app.head ?? {}\n nuxt.options.app.head.script = nuxt.options.app.head.script ?? []\n nuxt.options.app.head.script.unshift({\n // `tagPosition: 'head'` plus being first means this executes before any stylesheet is\n // applied, which is the only moment at which the theme can be set without a visible flash.\n innerHTML:\n `(function(){try{var t=localStorage.getItem(${JSON.stringify(key)});` +\n `if(t==='light'||t==='dark'){document.documentElement.setAttribute('data-theme',t)}}` +\n `catch(e){}})()`,\n tagPosition: 'head',\n })\n }\n\n // --- Runtime plugin ----------------------------------------------------\n // Generated rather than shipped as a file so the module's options are baked in at build time,\n // which avoids a runtime config read on every request.\n addPluginTemplate({\n filename: 'ansh-motion.client.mjs',\n getContents: () => `\nimport { defineNuxtPlugin } from '#app'\nimport { setReducedMotionMode, getTicker, attachLifecycle } from '@ansh-ui/core'\n\nexport default defineNuxtPlugin(() => {\n setReducedMotionMode(${JSON.stringify(options.reducedMotion ?? 'auto')})\n\n const ticker = getTicker()\n ticker.timeScale = ${JSON.stringify(options.timeScale ?? 1)}\n\n const detach = attachLifecycle(ticker, {\n pauseWhenHidden: ${JSON.stringify(options.pauseWhenHidden ?? true)},\n respectBattery: ${JSON.stringify(options.respectBattery ?? true)},\n })\n\n // Released on HMR dispose so a dev-server reload doesn't accumulate listeners across edits.\n if (import.meta.hot) import.meta.hot.dispose(detach)\n})\n`,\n // Client-only: every one of these touches a browser global.\n mode: 'client',\n })\n },\n})\n\nexport default module\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/names.ts","../src/module.ts"],"names":["module","defineNuxtModule","addComponent","addImports","addPluginTemplate"],"mappings":";;;;;;;AAUO,IAAM,eAAA,GAAkB;AAAA;AAAA,EAE7B,kBAAA;AAAA,EACA,cAAA;AAAA,EACA,kBAAA;AAAA,EACA,eAAA;AAAA,EACA,eAAA;AAAA,EACA,cAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAAA,EACA,WAAA;AAAA,EACA,OAAA;AAAA,EACA,YAAA;AAAA,EACA,YAAA;AAAA,EACA,WAAA;A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ACvC,MAAA,IAAA,CAAK,QAAQ,GAAA,CAAI,IAAA,GAAO,KAAK,OAAA,CAAQ,GAAA,CAAI,QAAQ,EAAC;AAClD,MAAA,IAAA,CAAK,OAAA,CAAQ,IAAI,IAAA,CAAK,MAAA,GAAS,KAAK,OAAA,CAAQ,GAAA,CAAI,IAAA,CAAK,MAAA,IAAU,EAAC;AAChE,MAAA,IAAA,CAAK,OAAA,CAAQ,GAAA,CAAI,IAAA,CAAK,MAAA,CAAO,OAAA,CAAQ;AAAA;AAAA;AAAA,QAGnC,SAAA,EACE,CAAA,2CAAA,EAA8C,IAAA,CAAK,SAAA,CAAU,GAAG,CAAC,CAAA,mGAAA,CAAA;AAAA,QAGnE,WAAA,EAAa;AAAA,OACd,CAAA;AAAA,IACH;AAKA,IAAAC,qBAAA,CAAkB;AAAA,MAChB,QAAA,EAAU,wBAAA;AAAA,MACV,aAAa,MAAM;AAAA;AAAA;;AAAA;AAAA,uBAAA,EAKA,IAAA,CAAK,SAAA,CAAU,OAAA,CAAQ,aAAA,IAAiB,MAAM,CAAC,CAAA;;AAAA;AAAA,qBAAA,EAGjD,IAAA,CAAK,SAAA,CAAU,OAAA,CAAQ,SAAA,IAAa,CAAC,CAAC;;AAAA;AAAA,qBAAA,EAGtC,IAAA,CAAK,SAAA,CAAU,OAAA,CAAQ,eAAA,IAAmB,IAAI,CAAC,CAAA;AAAA,oBAAA,EAChD,IAAA,CAAK,SAAA,CAAU,OAAA,CAAQ,cAAA,IAAkB,IAAI,CAAC,CAAA;AAAA;;AAAA;AAAA;AAAA;AAAA,CAAA;AAAA;AAAA,MAQ9D,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AACF,CAAC,CAAA;AAED,IAAO,cAAA,GAAQJ","file":"module.cjs","sourcesContent":["/**\n * What `@ansh-ui/nuxt` registers for auto-import.\n *\n * A static list rather than an enumeration of `@ansh-ui/vue`'s exports, because the module runs in\n * Nuxt's build process and importing the whole Vue package there just to read its keys would load\n * every component at config time. `test/module.test.ts` compares this list against the real exports,\n * so a new component can't be forgotten again (Carousel and seven effects were, until 0.3).\n */\n\n/** Components exported by `@ansh-ui/vue`, registered individually for lazy auto-import. */\nexport const COMPONENT_NAMES = [\n // Backgrounds\n 'AuroraBackground',\n 'MeshGradient',\n 'AnimatedGradient',\n 'ParticleField',\n 'Constellation',\n 'MeteorShower',\n 'Rain',\n 'Snow',\n 'Fireflies',\n 'Waves',\n 'LiquidBlob',\n 'NoiseLayer',\n 'Spotlight',\n 'LightRays',\n 'Smoke',\n 'PowderExplosion',\n 'FloatingGeometry',\n 'Orbit',\n 'StrangeAttractor',\n 'Swarm',\n // Behaviours\n 'MagneticButton',\n 'TiltCard',\n 'Ripple',\n 'Marquee',\n 'ScrollReveal',\n 'Parallax',\n // Text\n 'GradientText',\n 'AnimatedText',\n 'ScrambleText',\n // Providers\n 'MotionConfig',\n 'ThemeProvider',\n // Layout\n 'Stack',\n 'HStack',\n 'VStack',\n 'Grid',\n 'GridItem',\n 'Container',\n 'Divider',\n 'Spacer',\n 'Center',\n 'AspectRatio',\n 'ScrollArea',\n 'Resizable',\n // Forms\n 'Field',\n 'Fieldset',\n 'VisuallyHidden',\n 'Input',\n 'NumberInput',\n 'Textarea',\n 'Checkbox',\n 'ChoiceCard',\n 'Radio',\n 'RadioGroup',\n 'Switch',\n 'OptionList',\n 'Select',\n 'Combobox',\n 'Slider',\n 'RangeSlider',\n 'PinInput',\n 'TagsInput',\n 'Rating',\n 'Dropzone',\n 'ColorPicker',\n 'Calendar',\n 'DatePicker',\n 'DateRangePicker',\n // Overlays\n 'Popover',\n 'PopoverTrigger',\n 'PopoverContent',\n 'HoverCard',\n 'Tooltip',\n 'TooltipProvider',\n 'Dialog',\n 'AlertDialog',\n 'DialogFooter',\n 'Drawer',\n 'DropdownMenu',\n 'ContextMenu',\n // Data\n 'Table',\n 'DataTable',\n 'Pagination',\n 'Badge',\n 'Avatar',\n 'AvatarGroup',\n 'Kbd',\n 'Stat',\n 'EmptyState',\n 'DescriptionList',\n 'Timeline',\n 'CodeBlock',\n 'Progress',\n 'CircularProgress',\n 'Meter',\n // Navigation\n 'Tabs',\n 'Carousel',\n 'Breadcrumbs',\n 'Stepper',\n 'Sidebar',\n 'AppShell',\n 'NavigationMenu',\n // Feedback\n 'Alert',\n 'Banner',\n 'Callout',\n // Disclosure\n 'Collapsible',\n 'Accordion',\n 'DisclosureList',\n // Motion\n 'Motion',\n 'AnimatePresence',\n 'Draggable',\n] as const\n\n/** Composables exported by `@ansh-ui/vue`, registered for auto-import. */\nexport const COMPOSABLE_NAMES = [\n 'useMotionValue',\n 'useMotionRef',\n 'useMotionStyle',\n 'useSpringValue',\n 'useAnimate',\n 'useAnimatedFrom',\n 'useTicker',\n 'useInView',\n 'useElementSize',\n 'useScrollProgress',\n 'useWindowScroll',\n 'usePointer',\n 'useReducedMotion',\n 'useFrameBudget',\n 'useBehaviour',\n 'useMotionConfig',\n 'useTheme',\n 'useFieldControl',\n 'useFieldContext',\n 'useControllableState',\n // Headless primitives. `useId` is deliberately absent: Nuxt ships its own auto-imported `useId`,\n // and registering ours would shadow it app-wide.\n 'useAutoFocus',\n 'useFocusRestore',\n 'useFocusTrap',\n 'useRovingFocus',\n 'useDismiss',\n 'useScrollLock',\n 'usePresence',\n 'useAnchoredPosition',\n 'useTypeahead',\n] as const\n\n/** `@ansh-ui/vue` exports intentionally not auto-imported, with the reason. Checked by the tests. */\nexport const NOT_AUTO_IMPORTED: Readonly<Record<string, string>> = {\n useId: 'Nuxt provides its own useId',\n}\n","import { addComponent, addImports, addPluginTemplate, defineNuxtModule } from '@nuxt/kit'\nimport type { NuxtModule } from '@nuxt/schema'\nimport type { ReducedMotionMode } from '@ansh-ui/core'\nimport { COMPONENT_NAMES, COMPOSABLE_NAMES } from './names'\n\n/**\n * The Ansh Nuxt module.\n *\n * Nuxt gets its own package rather than instructions in the docs because there are four things a\n * Nuxt app needs that a bare Vue app does not, and every one of them is a footgun if left to the\n * consumer:\n *\n * 1. **Auto-imports.** Nuxt users expect `<AuroraBackground />` to work with no import statement.\n * That requires registering each component with `addComponent`, which only a module can do.\n * 2. **Transpilation.** Nuxt's server bundle externalises dependencies by default. Our packages\n * ship ESM that Nitro can consume, but the `'use client'`-free Vue build still needs to be in\n * the transpile list for older Nuxt versions to resolve it consistently.\n * 3. **The theme flash.** A themed app renders server-side with no knowledge of the user's stored\n * preference, so the first paint is the wrong theme. The only fix is a blocking inline script in\n * `<head>`, injected before any stylesheet — which is a `nuxt.options.app.head` concern.\n * 4. **Motion configuration.** `reducedMotion`, `timeScale` and lifecycle pausing need to be applied\n * once, on the client, after hydration. A generated plugin is the right place.\n */\n\nexport interface ModuleOptions {\n /**\n * Register every component for auto-import. Default `true`.\n *\n * Nuxt's component discovery is lazy per-component, so registering all of them does not increase\n * bundle size — only the ones actually used in templates are included.\n */\n components?: boolean\n\n /**\n * Prefix for auto-imported component names. Default `''` (no prefix), giving\n * `<AuroraBackground />`. Set to `'A'` for `<AAuroraBackground />` if you need to avoid a clash\n * with your own components.\n */\n prefix?: string\n\n /** Register the composables (`useMotionValue`, `useInView`, …) for auto-import. Default `true`. */\n composables?: boolean\n\n /**\n * Inject `@ansh-ui/tokens/ansh.css` into the app's global CSS. Default `true`.\n *\n * Set `false` if you import it yourself, or if you are overriding the token layer and need\n * control over cascade order.\n */\n css?: boolean\n\n /**\n * Inject the blocking theme script into `<head>`. Default `true`.\n *\n * Without this a themed app paints the wrong theme for one frame on every cold load. The script\n * is ~150 bytes and runs before the first stylesheet, which is the only point at which the flash\n * can be prevented.\n */\n themeScript?: boolean\n\n /** `localStorage` key the theme script reads. Default `'ansh-theme'`. */\n themeStorageKey?: string\n\n /** Application-level reduced-motion override. Default `'auto'` (follow the OS). */\n reducedMotion?: ReducedMotionMode\n\n /** Global playback rate. `0.5` is slow motion everywhere. Default `1`. */\n timeScale?: number\n\n /** Pause all animation while the document is hidden. Default `true`. */\n pauseWhenHidden?: boolean\n\n /** Reduce quality on low battery where the platform exposes it. Default `true`. */\n respectBattery?: boolean\n}\n\n/**\n * The return type is annotated explicitly rather than inferred.\n *\n * Without it TypeScript emits a declaration referencing `@nuxt/schema` by its resolved pnpm path,\n * which is not portable — the generated `.d.ts` would only typecheck on a machine with an\n * identically-hashed store directory.\n */\nconst module: NuxtModule<ModuleOptions> = defineNuxtModule<ModuleOptions>({\n meta: {\n name: '@ansh-ui/nuxt',\n configKey: 'ansh',\n compatibility: {\n nuxt: '>=3.10.0',\n },\n },\n\n defaults: {\n components: true,\n prefix: '',\n composables: true,\n css: true,\n themeScript: true,\n themeStorageKey: 'ansh-theme',\n reducedMotion: 'auto',\n timeScale: 1,\n pauseWhenHidden: true,\n respectBattery: true,\n },\n\n setup(options, nuxt) {\n // --- Transpile ---------------------------------------------------------\n // Nuxt externalises dependencies for the server build. Our packages are ESM-only and reference\n // browser globals inside functions (never at module scope), so they are SSR-safe — but Vite's\n // SSR resolver needs them in `noExternal` to consistently pick the ESM entry across the Nuxt\n // versions we support.\n nuxt.options.build.transpile.push('@ansh-ui/vue', '@ansh-ui/core', '@ansh-ui/tokens')\n\n // --- Global CSS --------------------------------------------------------\n if (options.css) {\n // Unshifted rather than pushed so the token layer lands *before* the application's own CSS.\n // Tokens are defaults meant to be overridden; if they came last they would win against the\n // consumer's overrides, which is the opposite of what a token layer should do.\n nuxt.options.css.unshift('@ansh-ui/tokens/ansh.css')\n }\n\n // --- Components --------------------------------------------------------\n if (options.components) {\n for (const name of COMPONENT_NAMES) {\n addComponent({\n name: `${options.prefix ?? ''}${name}`,\n export: name,\n filePath: '@ansh-ui/vue',\n // Every component mounts its effect in `onMounted`, so the server renders only the host\n // element. That is intentional and correct: the canvas has no meaningful server\n // representation, and rendering one would guarantee a hydration mismatch.\n mode: 'all',\n })\n }\n }\n\n // --- Composables -------------------------------------------------------\n if (options.composables) {\n addImports(\n COMPOSABLE_NAMES.map((name) => ({\n name,\n from: '@ansh-ui/vue',\n })),\n )\n }\n\n // --- Theme flash prevention -------------------------------------------\n if (options.themeScript) {\n const key = options.themeStorageKey ?? 'ansh-theme'\n nuxt.options.app.head = nuxt.options.app.head ?? {}\n nuxt.options.app.head.script = nuxt.options.app.head.script ?? []\n nuxt.options.app.head.script.unshift({\n // `tagPosition: 'head'` plus being first means this executes before any stylesheet is\n // applied, which is the only moment at which the theme can be set without a visible flash.\n innerHTML:\n `(function(){try{var t=localStorage.getItem(${JSON.stringify(key)});` +\n `if(t==='light'||t==='dark'){document.documentElement.setAttribute('data-theme',t)}}` +\n `catch(e){}})()`,\n tagPosition: 'head',\n })\n }\n\n // --- Runtime plugin ----------------------------------------------------\n // Generated rather than shipped as a file so the module's options are baked in at build time,\n // which avoids a runtime config read on every request.\n addPluginTemplate({\n filename: 'ansh-motion.client.mjs',\n getContents: () => `\nimport { defineNuxtPlugin } from '#app'\nimport { setReducedMotionMode, getTicker, attachLifecycle } from '@ansh-ui/core'\n\nexport default defineNuxtPlugin(() => {\n setReducedMotionMode(${JSON.stringify(options.reducedMotion ?? 'auto')})\n\n const ticker = getTicker()\n ticker.timeScale = ${JSON.stringify(options.timeScale ?? 1)}\n\n const detach = attachLifecycle(ticker, {\n pauseWhenHidden: ${JSON.stringify(options.pauseWhenHidden ?? true)},\n respectBattery: ${JSON.stringify(options.respectBattery ?? true)},\n })\n\n // Released on HMR dispose so a dev-server reload doesn't accumulate listeners across edits.\n if (import.meta.hot) import.meta.hot.dispose(detach)\n})\n`,\n // Client-only: every one of these touches a browser global.\n mode: 'client',\n })\n },\n})\n\nexport default module\n"]}
|
package/dist/module.d.cts
CHANGED
package/dist/module.d.ts
CHANGED
package/dist/module.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { defineNuxtModule, addComponent, addImports, addPluginTemplate } from '@nuxt/kit';
|
|
2
2
|
|
|
3
3
|
// src/module.ts
|
|
4
|
+
|
|
5
|
+
// src/names.ts
|
|
4
6
|
var COMPONENT_NAMES = [
|
|
5
7
|
// Backgrounds
|
|
6
8
|
"AuroraBackground",
|
|
@@ -16,6 +18,13 @@ var COMPONENT_NAMES = [
|
|
|
16
18
|
"LiquidBlob",
|
|
17
19
|
"NoiseLayer",
|
|
18
20
|
"Spotlight",
|
|
21
|
+
"LightRays",
|
|
22
|
+
"Smoke",
|
|
23
|
+
"PowderExplosion",
|
|
24
|
+
"FloatingGeometry",
|
|
25
|
+
"Orbit",
|
|
26
|
+
"StrangeAttractor",
|
|
27
|
+
"Swarm",
|
|
19
28
|
// Behaviours
|
|
20
29
|
"MagneticButton",
|
|
21
30
|
"TiltCard",
|
|
@@ -26,6 +35,7 @@ var COMPONENT_NAMES = [
|
|
|
26
35
|
// Text
|
|
27
36
|
"GradientText",
|
|
28
37
|
"AnimatedText",
|
|
38
|
+
"ScrambleText",
|
|
29
39
|
// Providers
|
|
30
40
|
"MotionConfig",
|
|
31
41
|
"ThemeProvider",
|
|
@@ -98,6 +108,7 @@ var COMPONENT_NAMES = [
|
|
|
98
108
|
"Meter",
|
|
99
109
|
// Navigation
|
|
100
110
|
"Tabs",
|
|
111
|
+
"Carousel",
|
|
101
112
|
"Breadcrumbs",
|
|
102
113
|
"Stepper",
|
|
103
114
|
"Sidebar",
|
|
@@ -136,8 +147,21 @@ var COMPOSABLE_NAMES = [
|
|
|
136
147
|
"useTheme",
|
|
137
148
|
"useFieldControl",
|
|
138
149
|
"useFieldContext",
|
|
139
|
-
"useControllableState"
|
|
150
|
+
"useControllableState",
|
|
151
|
+
// Headless primitives. `useId` is deliberately absent: Nuxt ships its own auto-imported `useId`,
|
|
152
|
+
// and registering ours would shadow it app-wide.
|
|
153
|
+
"useAutoFocus",
|
|
154
|
+
"useFocusRestore",
|
|
155
|
+
"useFocusTrap",
|
|
156
|
+
"useRovingFocus",
|
|
157
|
+
"useDismiss",
|
|
158
|
+
"useScrollLock",
|
|
159
|
+
"usePresence",
|
|
160
|
+
"useAnchoredPosition",
|
|
161
|
+
"useTypeahead"
|
|
140
162
|
];
|
|
163
|
+
|
|
164
|
+
// src/module.ts
|
|
141
165
|
var module$1 = defineNuxtModule({
|
|
142
166
|
meta: {
|
|
143
167
|
name: "@ansh-ui/nuxt",
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/module.ts"],"names":["module"],"mappings":";;;AA4EA,IAAM,eAAA,GAAkB;AAAA;AAAA,EAEtB,kBAAA;AAAA,EACA,cAAA;AAAA,EACA,kBAAA;AAAA,EACA,eAAA;AAAA,EACA,eAAA;AAAA,EACA,cAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAAA,EACA,WAAA;AAAA,EACA,OAAA;AAAA,EACA,YAAA;AAAA,EACA,YAAA;AAAA,EACA,WAAA;AAAA;AAAA,EAEA,gBAAA;AAAA,EACA,UAAA;AAAA,EACA,QAAA;AAAA,EACA,SAAA;AAAA,EACA,cAAA;AAAA,EACA,UAAA;AAAA;AAAA,EAEA,cAAA;AAAA,EACA,cAAA;AAAA;AAAA,EAEA,cAAA;AAAA,EACA,eAAA;AAAA;AAAA,EAEA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA,MAAA;AAAA,EACA,UAAA;AAAA,EACA,WAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA,aAAA;AAAA,EACA,YAAA;AAAA,EACA,WAAA;AAAA;AAAA,EAEA,OAAA;AAAA,EACA,UAAA;AAAA,EACA,gBAAA;AAAA,EACA,OAAA;AAAA,EACA,aAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA,YAAA;AAAA,EACA,OAAA;AAAA,EACA,YAAA;AAAA,EACA,QAAA;AAAA,EACA,YAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA;AAAA,EACA,QAAA;AAAA,EACA,aAAA;AAAA,EACA,UAAA;AAAA,EACA,WAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA;AAAA,EACA,aAAA;AAAA,EACA,UAAA;AAAA,EACA,YAAA;AAAA,EAC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/kit'\nimport type { NuxtModule } from '@nuxt/schema'\nimport type { ReducedMotionMode } from '@ansh-ui/core'\n\n/**\n * The Ansh Nuxt module.\n *\n * Nuxt gets its own package rather than instructions in the docs because there are four things a\n * Nuxt app needs that a bare Vue app does not, and every one of them is a footgun if left to the\n * consumer:\n *\n * 1. **Auto-imports.** Nuxt users expect `<AuroraBackground />` to work with no import statement.\n * That requires registering each component with `addComponent`, which only a module can do.\n * 2. **Transpilation.** Nuxt's server bundle externalises dependencies by default. Our packages\n * ship ESM that Nitro can consume, but the `'use client'`-free Vue build still needs to be in\n * the transpile list for older Nuxt versions to resolve it consistently.\n * 3. **The theme flash.** A themed app renders server-side with no knowledge of the user's stored\n * preference, so the first paint is the wrong theme. The only fix is a blocking inline script in\n * `<head>`, injected before any stylesheet — which is a `nuxt.options.app.head` concern.\n * 4. **Motion configuration.** `reducedMotion`, `timeScale` and lifecycle pausing need to be applied\n * once, on the client, after hydration. A generated plugin is the right place.\n */\n\nexport interface ModuleOptions {\n /**\n * Register every component for auto-import. Default `true`.\n *\n * Nuxt's component discovery is lazy per-component, so registering all of them does not increase\n * bundle size — only the ones actually used in templates are included.\n */\n components?: boolean\n\n /**\n * Prefix for auto-imported component names. Default `''` (no prefix), giving\n * `<AuroraBackground />`. Set to `'A'` for `<AAuroraBackground />` if you need to avoid a clash\n * with your own components.\n */\n prefix?: string\n\n /** Register the composables (`useMotionValue`, `useInView`, …) for auto-import. Default `true`. */\n composables?: boolean\n\n /**\n * Inject `@ansh-ui/tokens/ansh.css` into the app's global CSS. Default `true`.\n *\n * Set `false` if you import it yourself, or if you are overriding the token layer and need\n * control over cascade order.\n */\n css?: boolean\n\n /**\n * Inject the blocking theme script into `<head>`. Default `true`.\n *\n * Without this a themed app paints the wrong theme for one frame on every cold load. The script\n * is ~150 bytes and runs before the first stylesheet, which is the only point at which the flash\n * can be prevented.\n */\n themeScript?: boolean\n\n /** `localStorage` key the theme script reads. Default `'ansh-theme'`. */\n themeStorageKey?: string\n\n /** Application-level reduced-motion override. Default `'auto'` (follow the OS). */\n reducedMotion?: ReducedMotionMode\n\n /** Global playback rate. `0.5` is slow motion everywhere. Default `1`. */\n timeScale?: number\n\n /** Pause all animation while the document is hidden. Default `true`. */\n pauseWhenHidden?: boolean\n\n /** Reduce quality on low battery where the platform exposes it. Default `true`. */\n respectBattery?: boolean\n}\n\n/** Components exported by `@ansh-ui/vue`, registered individually for lazy auto-import. */\nconst COMPONENT_NAMES = [\n // Backgrounds\n 'AuroraBackground',\n 'MeshGradient',\n 'AnimatedGradient',\n 'ParticleField',\n 'Constellation',\n 'MeteorShower',\n 'Rain',\n 'Snow',\n 'Fireflies',\n 'Waves',\n 'LiquidBlob',\n 'NoiseLayer',\n 'Spotlight',\n // Behaviours\n 'MagneticButton',\n 'TiltCard',\n 'Ripple',\n 'Marquee',\n 'ScrollReveal',\n 'Parallax',\n // Text\n 'GradientText',\n 'AnimatedText',\n // Providers\n 'MotionConfig',\n 'ThemeProvider',\n // Layout\n 'Stack',\n 'HStack',\n 'VStack',\n 'Grid',\n 'GridItem',\n 'Container',\n 'Divider',\n 'Spacer',\n 'Center',\n 'AspectRatio',\n 'ScrollArea',\n 'Resizable',\n // Forms\n 'Field',\n 'Fieldset',\n 'VisuallyHidden',\n 'Input',\n 'NumberInput',\n 'Textarea',\n 'Checkbox',\n 'ChoiceCard',\n 'Radio',\n 'RadioGroup',\n 'Switch',\n 'OptionList',\n 'Select',\n 'Combobox',\n 'Slider',\n 'RangeSlider',\n 'PinInput',\n 'TagsInput',\n 'Rating',\n 'Dropzone',\n 'ColorPicker',\n 'Calendar',\n 'DatePicker',\n 'DateRangePicker',\n // Overlays\n 'Popover',\n 'PopoverTrigger',\n 'PopoverContent',\n 'HoverCard',\n 'Tooltip',\n 'TooltipProvider',\n 'Dialog',\n 'AlertDialog',\n 'DialogFooter',\n 'Drawer',\n 'DropdownMenu',\n 'ContextMenu',\n // Data\n 'Table',\n 'DataTable',\n 'Pagination',\n 'Badge',\n 'Avatar',\n 'AvatarGroup',\n 'Kbd',\n 'Stat',\n 'EmptyState',\n 'DescriptionList',\n 'Timeline',\n 'CodeBlock',\n 'Progress',\n 'CircularProgress',\n 'Meter',\n // Navigation\n 'Tabs',\n 'Breadcrumbs',\n 'Stepper',\n 'Sidebar',\n 'AppShell',\n 'NavigationMenu',\n // Feedback\n 'Alert',\n 'Banner',\n 'Callout',\n // Disclosure\n 'Collapsible',\n 'Accordion',\n 'DisclosureList',\n // Motion\n 'Motion',\n 'AnimatePresence',\n 'Draggable',\n] as const\n\n/** Composables exported by `@ansh-ui/vue`, registered for auto-import. */\nconst COMPOSABLE_NAMES = [\n 'useMotionValue',\n 'useMotionRef',\n 'useMotionStyle',\n 'useSpringValue',\n 'useAnimate',\n 'useAnimatedFrom',\n 'useTicker',\n 'useInView',\n 'useElementSize',\n 'useScrollProgress',\n 'useWindowScroll',\n 'usePointer',\n 'useReducedMotion',\n 'useFrameBudget',\n 'useBehaviour',\n 'useMotionConfig',\n 'useTheme',\n 'useFieldControl',\n 'useFieldContext',\n 'useControllableState',\n] as const\n\n/**\n * The return type is annotated explicitly rather than inferred.\n *\n * Without it TypeScript emits a declaration referencing `@nuxt/schema` by its resolved pnpm path,\n * which is not portable — the generated `.d.ts` would only typecheck on a machine with an\n * identically-hashed store directory.\n */\nconst module: NuxtModule<ModuleOptions> = defineNuxtModule<ModuleOptions>({\n meta: {\n name: '@ansh-ui/nuxt',\n configKey: 'ansh',\n compatibility: {\n nuxt: '>=3.10.0',\n },\n },\n\n defaults: {\n components: true,\n prefix: '',\n composables: true,\n css: true,\n themeScript: true,\n themeStorageKey: 'ansh-theme',\n reducedMotion: 'auto',\n timeScale: 1,\n pauseWhenHidden: true,\n respectBattery: true,\n },\n\n setup(options, nuxt) {\n // --- Transpile ---------------------------------------------------------\n // Nuxt externalises dependencies for the server build. Our packages are ESM-only and reference\n // browser globals inside functions (never at module scope), so they are SSR-safe — but Vite's\n // SSR resolver needs them in `noExternal` to consistently pick the ESM entry across the Nuxt\n // versions we support.\n nuxt.options.build.transpile.push('@ansh-ui/vue', '@ansh-ui/core', '@ansh-ui/tokens')\n\n // --- Global CSS --------------------------------------------------------\n if (options.css) {\n // Unshifted rather than pushed so the token layer lands *before* the application's own CSS.\n // Tokens are defaults meant to be overridden; if they came last they would win against the\n // consumer's overrides, which is the opposite of what a token layer should do.\n nuxt.options.css.unshift('@ansh-ui/tokens/ansh.css')\n }\n\n // --- Components --------------------------------------------------------\n if (options.components) {\n for (const name of COMPONENT_NAMES) {\n addComponent({\n name: `${options.prefix ?? ''}${name}`,\n export: name,\n filePath: '@ansh-ui/vue',\n // Every component mounts its effect in `onMounted`, so the server renders only the host\n // element. That is intentional and correct: the canvas has no meaningful server\n // representation, and rendering one would guarantee a hydration mismatch.\n mode: 'all',\n })\n }\n }\n\n // --- Composables -------------------------------------------------------\n if (options.composables) {\n addImports(\n COMPOSABLE_NAMES.map((name) => ({\n name,\n from: '@ansh-ui/vue',\n })),\n )\n }\n\n // --- Theme flash prevention -------------------------------------------\n if (options.themeScript) {\n const key = options.themeStorageKey ?? 'ansh-theme'\n nuxt.options.app.head = nuxt.options.app.head ?? {}\n nuxt.options.app.head.script = nuxt.options.app.head.script ?? []\n nuxt.options.app.head.script.unshift({\n // `tagPosition: 'head'` plus being first means this executes before any stylesheet is\n // applied, which is the only moment at which the theme can be set without a visible flash.\n innerHTML:\n `(function(){try{var t=localStorage.getItem(${JSON.stringify(key)});` +\n `if(t==='light'||t==='dark'){document.documentElement.setAttribute('data-theme',t)}}` +\n `catch(e){}})()`,\n tagPosition: 'head',\n })\n }\n\n // --- Runtime plugin ----------------------------------------------------\n // Generated rather than shipped as a file so the module's options are baked in at build time,\n // which avoids a runtime config read on every request.\n addPluginTemplate({\n filename: 'ansh-motion.client.mjs',\n getContents: () => `\nimport { defineNuxtPlugin } from '#app'\nimport { setReducedMotionMode, getTicker, attachLifecycle } from '@ansh-ui/core'\n\nexport default defineNuxtPlugin(() => {\n setReducedMotionMode(${JSON.stringify(options.reducedMotion ?? 'auto')})\n\n const ticker = getTicker()\n ticker.timeScale = ${JSON.stringify(options.timeScale ?? 1)}\n\n const detach = attachLifecycle(ticker, {\n pauseWhenHidden: ${JSON.stringify(options.pauseWhenHidden ?? true)},\n respectBattery: ${JSON.stringify(options.respectBattery ?? true)},\n })\n\n // Released on HMR dispose so a dev-server reload doesn't accumulate listeners across edits.\n if (import.meta.hot) import.meta.hot.dispose(detach)\n})\n`,\n // Client-only: every one of these touches a browser global.\n mode: 'client',\n })\n },\n})\n\nexport default module\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/names.ts","../src/module.ts"],"names":["module"],"mappings":";;;;;AAUO,IAAM,eAAA,GAAkB;AAAA;AAAA,EAE7B,kBAAA;AAAA,EACA,cAAA;AAAA,EACA,kBAAA;AAAA,EACA,eAAA;AAAA,EACA,eAAA;AAAA,EACA,cAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAAA,EACA,WAAA;AAAA,EACA,OAAA;AAAA,EACA,YAAA;AAAA,EACA,YAAA;AAAA,EACA,WAAA;AAAA,EACA,WAAA;AAAA,EACA,OAAA;AAAA,EACA,iBAAA;AAAA,EACA,kBAAA;AAAA,EACA,OAAA;AAAA,EACA,kBAAA;AAAA,EACA,OAAA;AAAA;AAAA,EAEA,gBAAA;AAAA,EACA,UAAA;AAAA,EACA,QAAA;AAAA,EACA,SAAA;AAAA,EACA,cAAA;AAAA,EACA,UAAA;AAAA;AAAA,EAEA,cAAA;AAAA,EACA,cAAA;AAAA,EACA,cAAA;AAAA;AAAA,EAEA,cAAA;AAAA,EACA,eAAA;AAAA;AAAA,EAEA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA,MAAA;AAAA,EACA,UAAA;AAAA,EACA,WAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA,aAAA;AAAA,EACA,YAAA;AAAA,EACA,WAAA;AAAA;AAAA,EAEA,OAAA;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AAA;;AAAA;AAAA,uBAAA,EAKA,IAAA,CAAK,SAAA,CAAU,OAAA,CAAQ,aAAA,IAAiB,MAAM,CAAC,CAAA;;AAAA;AAAA,qBAAA,EAGjD,IAAA,CAAK,SAAA,CAAU,OAAA,CAAQ,SAAA,IAAa,CAAC,CAAC;;AAAA;AAAA,qBAAA,EAGtC,IAAA,CAAK,SAAA,CAAU,OAAA,CAAQ,eAAA,IAAmB,IAAI,CAAC,CAAA;AAAA,oBAAA,EAChD,IAAA,CAAK,SAAA,CAAU,OAAA,CAAQ,cAAA,IAAkB,IAAI,CAAC,CAAA;AAAA;;AAAA;AAAA;AAAA;AAAA,CAAA;AAAA;AAAA,MAQ9D,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AACF,CAAC,CAAA;AAED,IAAO,cAAA,GAAQA","file":"module.js","sourcesContent":["/**\n * What `@ansh-ui/nuxt` registers for auto-import.\n *\n * A static list rather than an enumeration of `@ansh-ui/vue`'s exports, because the module runs in\n * Nuxt's build process and importing the whole Vue package there just to read its keys would load\n * every component at config time. `test/module.test.ts` compares this list against the real exports,\n * so a new component can't be forgotten again (Carousel and seven effects were, until 0.3).\n */\n\n/** Components exported by `@ansh-ui/vue`, registered individually for lazy auto-import. */\nexport const COMPONENT_NAMES = [\n // Backgrounds\n 'AuroraBackground',\n 'MeshGradient',\n 'AnimatedGradient',\n 'ParticleField',\n 'Constellation',\n 'MeteorShower',\n 'Rain',\n 'Snow',\n 'Fireflies',\n 'Waves',\n 'LiquidBlob',\n 'NoiseLayer',\n 'Spotlight',\n 'LightRays',\n 'Smoke',\n 'PowderExplosion',\n 'FloatingGeometry',\n 'Orbit',\n 'StrangeAttractor',\n 'Swarm',\n // Behaviours\n 'MagneticButton',\n 'TiltCard',\n 'Ripple',\n 'Marquee',\n 'ScrollReveal',\n 'Parallax',\n // Text\n 'GradientText',\n 'AnimatedText',\n 'ScrambleText',\n // Providers\n 'MotionConfig',\n 'ThemeProvider',\n // Layout\n 'Stack',\n 'HStack',\n 'VStack',\n 'Grid',\n 'GridItem',\n 'Container',\n 'Divider',\n 'Spacer',\n 'Center',\n 'AspectRatio',\n 'ScrollArea',\n 'Resizable',\n // Forms\n 'Field',\n 'Fieldset',\n 'VisuallyHidden',\n 'Input',\n 'NumberInput',\n 'Textarea',\n 'Checkbox',\n 'ChoiceCard',\n 'Radio',\n 'RadioGroup',\n 'Switch',\n 'OptionList',\n 'Select',\n 'Combobox',\n 'Slider',\n 'RangeSlider',\n 'PinInput',\n 'TagsInput',\n 'Rating',\n 'Dropzone',\n 'ColorPicker',\n 'Calendar',\n 'DatePicker',\n 'DateRangePicker',\n // Overlays\n 'Popover',\n 'PopoverTrigger',\n 'PopoverContent',\n 'HoverCard',\n 'Tooltip',\n 'TooltipProvider',\n 'Dialog',\n 'AlertDialog',\n 'DialogFooter',\n 'Drawer',\n 'DropdownMenu',\n 'ContextMenu',\n // Data\n 'Table',\n 'DataTable',\n 'Pagination',\n 'Badge',\n 'Avatar',\n 'AvatarGroup',\n 'Kbd',\n 'Stat',\n 'EmptyState',\n 'DescriptionList',\n 'Timeline',\n 'CodeBlock',\n 'Progress',\n 'CircularProgress',\n 'Meter',\n // Navigation\n 'Tabs',\n 'Carousel',\n 'Breadcrumbs',\n 'Stepper',\n 'Sidebar',\n 'AppShell',\n 'NavigationMenu',\n // Feedback\n 'Alert',\n 'Banner',\n 'Callout',\n // Disclosure\n 'Collapsible',\n 'Accordion',\n 'DisclosureList',\n // Motion\n 'Motion',\n 'AnimatePresence',\n 'Draggable',\n] as const\n\n/** Composables exported by `@ansh-ui/vue`, registered for auto-import. */\nexport const COMPOSABLE_NAMES = [\n 'useMotionValue',\n 'useMotionRef',\n 'useMotionStyle',\n 'useSpringValue',\n 'useAnimate',\n 'useAnimatedFrom',\n 'useTicker',\n 'useInView',\n 'useElementSize',\n 'useScrollProgress',\n 'useWindowScroll',\n 'usePointer',\n 'useReducedMotion',\n 'useFrameBudget',\n 'useBehaviour',\n 'useMotionConfig',\n 'useTheme',\n 'useFieldControl',\n 'useFieldContext',\n 'useControllableState',\n // Headless primitives. `useId` is deliberately absent: Nuxt ships its own auto-imported `useId`,\n // and registering ours would shadow it app-wide.\n 'useAutoFocus',\n 'useFocusRestore',\n 'useFocusTrap',\n 'useRovingFocus',\n 'useDismiss',\n 'useScrollLock',\n 'usePresence',\n 'useAnchoredPosition',\n 'useTypeahead',\n] as const\n\n/** `@ansh-ui/vue` exports intentionally not auto-imported, with the reason. Checked by the tests. */\nexport const NOT_AUTO_IMPORTED: Readonly<Record<string, string>> = {\n useId: 'Nuxt provides its own useId',\n}\n","import { addComponent, addImports, addPluginTemplate, defineNuxtModule } from '@nuxt/kit'\nimport type { NuxtModule } from '@nuxt/schema'\nimport type { ReducedMotionMode } from '@ansh-ui/core'\nimport { COMPONENT_NAMES, COMPOSABLE_NAMES } from './names'\n\n/**\n * The Ansh Nuxt module.\n *\n * Nuxt gets its own package rather than instructions in the docs because there are four things a\n * Nuxt app needs that a bare Vue app does not, and every one of them is a footgun if left to the\n * consumer:\n *\n * 1. **Auto-imports.** Nuxt users expect `<AuroraBackground />` to work with no import statement.\n * That requires registering each component with `addComponent`, which only a module can do.\n * 2. **Transpilation.** Nuxt's server bundle externalises dependencies by default. Our packages\n * ship ESM that Nitro can consume, but the `'use client'`-free Vue build still needs to be in\n * the transpile list for older Nuxt versions to resolve it consistently.\n * 3. **The theme flash.** A themed app renders server-side with no knowledge of the user's stored\n * preference, so the first paint is the wrong theme. The only fix is a blocking inline script in\n * `<head>`, injected before any stylesheet — which is a `nuxt.options.app.head` concern.\n * 4. **Motion configuration.** `reducedMotion`, `timeScale` and lifecycle pausing need to be applied\n * once, on the client, after hydration. A generated plugin is the right place.\n */\n\nexport interface ModuleOptions {\n /**\n * Register every component for auto-import. Default `true`.\n *\n * Nuxt's component discovery is lazy per-component, so registering all of them does not increase\n * bundle size — only the ones actually used in templates are included.\n */\n components?: boolean\n\n /**\n * Prefix for auto-imported component names. Default `''` (no prefix), giving\n * `<AuroraBackground />`. Set to `'A'` for `<AAuroraBackground />` if you need to avoid a clash\n * with your own components.\n */\n prefix?: string\n\n /** Register the composables (`useMotionValue`, `useInView`, …) for auto-import. Default `true`. */\n composables?: boolean\n\n /**\n * Inject `@ansh-ui/tokens/ansh.css` into the app's global CSS. Default `true`.\n *\n * Set `false` if you import it yourself, or if you are overriding the token layer and need\n * control over cascade order.\n */\n css?: boolean\n\n /**\n * Inject the blocking theme script into `<head>`. Default `true`.\n *\n * Without this a themed app paints the wrong theme for one frame on every cold load. The script\n * is ~150 bytes and runs before the first stylesheet, which is the only point at which the flash\n * can be prevented.\n */\n themeScript?: boolean\n\n /** `localStorage` key the theme script reads. Default `'ansh-theme'`. */\n themeStorageKey?: string\n\n /** Application-level reduced-motion override. Default `'auto'` (follow the OS). */\n reducedMotion?: ReducedMotionMode\n\n /** Global playback rate. `0.5` is slow motion everywhere. Default `1`. */\n timeScale?: number\n\n /** Pause all animation while the document is hidden. Default `true`. */\n pauseWhenHidden?: boolean\n\n /** Reduce quality on low battery where the platform exposes it. Default `true`. */\n respectBattery?: boolean\n}\n\n/**\n * The return type is annotated explicitly rather than inferred.\n *\n * Without it TypeScript emits a declaration referencing `@nuxt/schema` by its resolved pnpm path,\n * which is not portable — the generated `.d.ts` would only typecheck on a machine with an\n * identically-hashed store directory.\n */\nconst module: NuxtModule<ModuleOptions> = defineNuxtModule<ModuleOptions>({\n meta: {\n name: '@ansh-ui/nuxt',\n configKey: 'ansh',\n compatibility: {\n nuxt: '>=3.10.0',\n },\n },\n\n defaults: {\n components: true,\n prefix: '',\n composables: true,\n css: true,\n themeScript: true,\n themeStorageKey: 'ansh-theme',\n reducedMotion: 'auto',\n timeScale: 1,\n pauseWhenHidden: true,\n respectBattery: true,\n },\n\n setup(options, nuxt) {\n // --- Transpile ---------------------------------------------------------\n // Nuxt externalises dependencies for the server build. Our packages are ESM-only and reference\n // browser globals inside functions (never at module scope), so they are SSR-safe — but Vite's\n // SSR resolver needs them in `noExternal` to consistently pick the ESM entry across the Nuxt\n // versions we support.\n nuxt.options.build.transpile.push('@ansh-ui/vue', '@ansh-ui/core', '@ansh-ui/tokens')\n\n // --- Global CSS --------------------------------------------------------\n if (options.css) {\n // Unshifted rather than pushed so the token layer lands *before* the application's own CSS.\n // Tokens are defaults meant to be overridden; if they came last they would win against the\n // consumer's overrides, which is the opposite of what a token layer should do.\n nuxt.options.css.unshift('@ansh-ui/tokens/ansh.css')\n }\n\n // --- Components --------------------------------------------------------\n if (options.components) {\n for (const name of COMPONENT_NAMES) {\n addComponent({\n name: `${options.prefix ?? ''}${name}`,\n export: name,\n filePath: '@ansh-ui/vue',\n // Every component mounts its effect in `onMounted`, so the server renders only the host\n // element. That is intentional and correct: the canvas has no meaningful server\n // representation, and rendering one would guarantee a hydration mismatch.\n mode: 'all',\n })\n }\n }\n\n // --- Composables -------------------------------------------------------\n if (options.composables) {\n addImports(\n COMPOSABLE_NAMES.map((name) => ({\n name,\n from: '@ansh-ui/vue',\n })),\n )\n }\n\n // --- Theme flash prevention -------------------------------------------\n if (options.themeScript) {\n const key = options.themeStorageKey ?? 'ansh-theme'\n nuxt.options.app.head = nuxt.options.app.head ?? {}\n nuxt.options.app.head.script = nuxt.options.app.head.script ?? []\n nuxt.options.app.head.script.unshift({\n // `tagPosition: 'head'` plus being first means this executes before any stylesheet is\n // applied, which is the only moment at which the theme can be set without a visible flash.\n innerHTML:\n `(function(){try{var t=localStorage.getItem(${JSON.stringify(key)});` +\n `if(t==='light'||t==='dark'){document.documentElement.setAttribute('data-theme',t)}}` +\n `catch(e){}})()`,\n tagPosition: 'head',\n })\n }\n\n // --- Runtime plugin ----------------------------------------------------\n // Generated rather than shipped as a file so the module's options are baked in at build time,\n // which avoids a runtime config read on every request.\n addPluginTemplate({\n filename: 'ansh-motion.client.mjs',\n getContents: () => `\nimport { defineNuxtPlugin } from '#app'\nimport { setReducedMotionMode, getTicker, attachLifecycle } from '@ansh-ui/core'\n\nexport default defineNuxtPlugin(() => {\n setReducedMotionMode(${JSON.stringify(options.reducedMotion ?? 'auto')})\n\n const ticker = getTicker()\n ticker.timeScale = ${JSON.stringify(options.timeScale ?? 1)}\n\n const detach = attachLifecycle(ticker, {\n pauseWhenHidden: ${JSON.stringify(options.pauseWhenHidden ?? true)},\n respectBattery: ${JSON.stringify(options.respectBattery ?? true)},\n })\n\n // Released on HMR dispose so a dev-server reload doesn't accumulate listeners across edits.\n if (import.meta.hot) import.meta.hot.dispose(detach)\n})\n`,\n // Client-only: every one of these touches a browser global.\n mode: 'client',\n })\n },\n})\n\nexport default module\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ansh-ui/nuxt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Ansh Nuxt module — auto-imports, SSR-safe components and theme setup for Nuxt 3 and 4.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
"./package.json": "./package.json"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@nuxt/kit": "^3.15.0",
|
|
37
|
-
"@ansh-ui/
|
|
38
|
-
"@ansh-ui/
|
|
39
|
-
"@ansh-ui/
|
|
36
|
+
"@nuxt/kit": "^3.15.0 || ^4.0.0",
|
|
37
|
+
"@ansh-ui/core": "0.3.0",
|
|
38
|
+
"@ansh-ui/tokens": "0.3.0",
|
|
39
|
+
"@ansh-ui/vue": "0.3.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@nuxt/schema": "^3.15.0"
|
|
42
|
+
"@nuxt/schema": "^3.15.0 || ^4.0.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"nuxt": "^3.10.0 || ^4.0.0"
|