@nyxwire/astro 0.0.0-stage → 0.1.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.
@@ -0,0 +1,163 @@
1
+ # Vue islands
2
+
3
+ > Render @nyxwire/vue components in Astro pages, hydrate them as islands, and keep them in sync with the page's flavor.
4
+
5
+ Astro renders Vue components to HTML on the server and hydrates only the ones you mark with a `client:*` directive. Nyxwire's Vue components work both ways: without a directive they ship as static HTML, and as islands they become interactive.
6
+
7
+ _Live example: [Vue islands](https://nyxwire.dissidence.ovh/astro/vue-islands/)._
8
+
9
+ The console above is a Vue island on this Starlight page: a switch, a slider and a radio group from `@nyxwire/vue`, plus `useFlavor` reporting the flavor in use. Switch the flavor in the header and it follows; turn the broadcast off and the other controls are disabled.
10
+
11
+ ## Setup
12
+
13
+ 1. Add Vue, the Astro renderer, the components and Tailwind.
14
+
15
+ ```sh
16
+ pnpm add @astrojs/vue vue @nyxwire/astro @nyxwire/vue @nyxwire/tailwind @nyxwire/css
17
+ pnpm add -D tailwindcss @tailwindcss/vite
18
+ ```
19
+
20
+ 2. Register the Vue renderer and the Tailwind Vite plugin next to the integration. Tailwind brings the theme, so the integration imports no CSS.
21
+
22
+ ```js title="astro.config.mjs"
23
+ import { defineConfig } from 'astro/config'
24
+ import vue from '@astrojs/vue'
25
+ import tailwindcss from '@tailwindcss/vite'
26
+ import nyxwire from '@nyxwire/astro'
27
+
28
+ export default defineConfig({
29
+ integrations: [vue(), nyxwire({ styles: false })],
30
+ vite: { plugins: [tailwindcss()] },
31
+ })
32
+ ```
33
+
34
+ 3. Create the global stylesheet and import it in your layout.
35
+
36
+ ```css title="src/styles/global.css"
37
+ @import 'tailwindcss';
38
+ @import '@nyxwire/tailwind';
39
+ @import '@nyxwire/vue/tailwind.css';
40
+ ```
41
+
42
+ The last line makes Tailwind scan the components' build, so the classes they use are generated.
43
+
44
+ On a Starlight site, keep the [Starlight stylesheet](https://nyxwire.dissidence.ovh/starlight/setup/#tailwind-in-starlight) instead and add only `vue()` to the integrations.
45
+
46
+ ## Write an island
47
+
48
+ Each island is its own Vue app, so wrap its content in `NwProvider`: it supplies the Reka UI config (direction, locale and SSR-stable ids), the tooltip and toast providers, and the flavor scope. This is the console above, `src/components/guides/RelayConsole.vue` in this site:
49
+
50
+ ```vue title="src/components/guides/RelayConsole.vue"
51
+ <script setup lang="ts">
52
+ // Island demo for the Vue islands page, which shows this file's source verbatim.
53
+ import { computed, ref } from 'vue'
54
+ import {
55
+ NwLabel,
56
+ NwProvider,
57
+ NwRadioGroup,
58
+ NwRadioGroupItem,
59
+ NwSlider,
60
+ NwSwitch,
61
+ useFlavor,
62
+ } from '@nyxwire/vue'
63
+
64
+ const broadcasting = ref(true)
65
+ const gain = ref([60])
66
+ const band = ref('uplink')
67
+ const bands = [
68
+ { value: 'uplink', label: 'Uplink' },
69
+ { value: 'mesh', label: 'Mesh' },
70
+ { value: 'backhaul', label: 'Backhaul' },
71
+ ]
72
+ const { resolvedFlavor } = useFlavor()
73
+ const status = computed(() =>
74
+ broadcasting.value ? `Broadcasting on ${band.value} at ${gain.value[0]}% gain` : 'Relay idle',
75
+ )
76
+ </script>
77
+
78
+ <template>
79
+ <NwProvider>
80
+ <div class="grid w-full max-w-sm gap-5 rounded-lg border border-line bg-panel p-5 shadow-sm">
81
+ <div class="flex items-center justify-between gap-4">
82
+ <p class="m-0 font-display text-lg font-semibold text-fg">Relay console</p>
83
+ <span class="font-mono text-2xs tracking-wide text-fg-subtle uppercase">
84
+ {{ resolvedFlavor }}
85
+ </span>
86
+ </div>
87
+ <NwSwitch v-model="broadcasting" label="Broadcast" />
88
+ <div class="grid gap-3">
89
+ <div class="flex items-center justify-between gap-4">
90
+ <NwLabel as="span">Signal gain</NwLabel>
91
+ <span class="font-mono text-xs text-fg-muted">{{ gain[0] }}%</span>
92
+ </div>
93
+ <!-- The thumb is the focusable control, so it carries the accessible name. -->
94
+ <NwSlider
95
+ v-model="gain"
96
+ :max="100"
97
+ :step="5"
98
+ :disabled="!broadcasting"
99
+ :thumb-labels="['Signal gain']"
100
+ />
101
+ </div>
102
+ <NwRadioGroup v-model="band" label="Band" :disabled="!broadcasting">
103
+ <NwRadioGroupItem v-for="item in bands" :key="item.value" :value="item.value">
104
+ {{ item.label }}
105
+ </NwRadioGroupItem>
106
+ </NwRadioGroup>
107
+ <p class="m-0 font-mono text-xs text-fg-muted" role="status" data-relay-status>
108
+ {{ status }}
109
+ </p>
110
+ </div>
111
+ </NwProvider>
112
+ </template>
113
+ ```
114
+
115
+ Then render it with a directive:
116
+
117
+ ```astro title="src/pages/relays.astro"
118
+ ---
119
+ import RelayConsole from '../components/RelayConsole.vue'
120
+ ---
121
+ <RelayConsole client:visible />
122
+ ```
123
+
124
+ | Directive | Hydrates | Use for |
125
+ | ---------------- | ------------------------- | ------------------------------------------------ |
126
+ | none | never: static HTML | Components that only display |
127
+ | `client:visible` | when it scrolls into view | Most interactive components |
128
+ | `client:idle` | when the browser is idle | Below-the-fold widgets that should be ready soon |
129
+ | `client:load` | immediately | Controls the visitor uses first, above the fold |
130
+
131
+ Islands do not share Vue state. Pass data through props, or keep shared state outside Vue, such as the flavor runtime.
132
+
133
+ ## Flavors
134
+
135
+ The flavor runtime from the integration (or the Starlight plugin) owns `<html>`. Inside an island, `useFlavor` detects `window.nyxwire`, delegates `setFlavor` to it, and listens to `nyxwire:flavor`, so every island and the page's own selectors agree. The head script applies the flavor before islands hydrate, so nothing flashes. Without a page runtime, `useFlavor` stores the preference under the same `nyxwire-flavor` key and sets the attributes on `<html>` itself.
136
+
137
+ To pin one island to a flavor or an accent, pass it to the provider: `<NwProvider flavor="abyss" accent="volt">` wraps the content in a `data-flavor` and `data-accent` scope. `NwFlavorSelect` inside the island edits that scope through `v-model`:
138
+
139
+ ```vue
140
+ <script setup lang="ts">
141
+ import { ref } from 'vue'
142
+ import type { FlavorName } from '@nyxwire/vue'
143
+ import { NwFlavorSelect, NwProvider } from '@nyxwire/vue'
144
+
145
+ const flavor = ref<FlavorName>('abyss')
146
+ </script>
147
+
148
+ <template>
149
+ <NwProvider v-model:flavor="flavor">
150
+ <NwFlavorSelect v-model="flavor" label="Panel flavor" />
151
+ </NwProvider>
152
+ </template>
153
+ ```
154
+
155
+ > **Note**
156
+ >
157
+ > Select lists, menus, dialogs and other popups render through portals into `<body>`, outside that
158
+ > scope. Their content re-applies the provider's `data-flavor` and `data-accent`, so a scoped
159
+ > island's popups keep its flavor.
160
+
161
+ ## Server rendering
162
+
163
+ Nyxwire's components are safe to render on the server: `NwProvider` hands Vue's `useId` to Reka so ids match after hydration, and `useFlavor` reads nothing from `window` until the component mounts. Avoid `client:only="vue"` unless a component cannot render on the server; it removes the HTML until the script loads.
@@ -0,0 +1,43 @@
1
+ import type { AccentName, FlavorName } from '@nyxwire/palette';
2
+ import type { FlavorConfig, FlavorPreference, NyxwireOptions } from './options.ts';
3
+ export interface FlavorChangeDetail {
4
+ readonly flavor: FlavorPreference;
5
+ readonly resolved: FlavorName;
6
+ readonly theme: 'dark' | 'light';
7
+ readonly accent: AccentName | null;
8
+ }
9
+ export interface FlavorController {
10
+ getFlavor(): FlavorPreference;
11
+ setFlavor(flavor: FlavorPreference): void;
12
+ resolve(): FlavorName;
13
+ }
14
+ export interface NyxwireRuntime extends FlavorController {
15
+ getAccent(): AccentName | null;
16
+ /** `null` removes `data-accent`, restoring the palette default. */
17
+ setAccent(accent: AccentName | null): void;
18
+ }
19
+ declare global {
20
+ interface Window {
21
+ nyxwire?: NyxwireRuntime;
22
+ }
23
+ interface DocumentEventMap {
24
+ 'nyxwire:flavor': CustomEvent<FlavorChangeDetail>;
25
+ }
26
+ }
27
+ export interface FlavorRuntimeConfig {
28
+ readonly defaultFlavor: FlavorPreference;
29
+ readonly accent: AccentName | null;
30
+ readonly persist: boolean;
31
+ readonly flavors: FlavorConfig['flavors'];
32
+ readonly palette: Readonly<Record<FlavorName, {
33
+ readonly dark: boolean;
34
+ readonly base: string;
35
+ }>>;
36
+ readonly accents: readonly AccentName[];
37
+ readonly flavorKey: string;
38
+ readonly accentKey: string;
39
+ readonly event: string;
40
+ }
41
+ export declare function resolveFlavor(stored: unknown, prefersLight: boolean, options?: NyxwireOptions): FlavorName;
42
+ export declare function flavorRuntime(c: FlavorRuntimeConfig): void;
43
+ export declare function buildFlavorScript(options?: NyxwireOptions): string;
@@ -0,0 +1,116 @@
1
+ import { accentNames, flavorMeta, palette } from '@nyxwire/palette';
2
+ import { ACCENT_STORAGE_KEY, FLAVOR_CHANGE_EVENT, FLAVOR_STORAGE_KEY, isFlavorPreference, normalizeOptions, } from "./options.js";
3
+ export function resolveFlavor(stored, prefersLight, options = {}) {
4
+ const { defaultFlavor, flavors } = normalizeOptions(options);
5
+ const preference = isFlavorPreference(stored) ? stored : defaultFlavor;
6
+ return preference === 'auto' ? flavors[prefersLight ? 'light' : 'dark'] : preference;
7
+ }
8
+ // Serialized with Function#toString and inlined in <head>: it must stay self-contained.
9
+ export function flavorRuntime(c) {
10
+ const root = document.documentElement;
11
+ const media = matchMedia('(prefers-color-scheme: light)');
12
+ const isPreference = (v) => v === 'auto' || (typeof v === 'string' && Object.hasOwn(c.palette, v));
13
+ const isAccent = (v) => c.accents.some((a) => a === v);
14
+ // Storage throws a DOMException when disabled (privacy mode, sandboxed frames); the page must still paint.
15
+ const read = (key) => {
16
+ if (!c.persist)
17
+ return null;
18
+ try {
19
+ return localStorage.getItem(key);
20
+ }
21
+ catch (error) {
22
+ if (!(error instanceof DOMException))
23
+ throw error;
24
+ return null;
25
+ }
26
+ };
27
+ const write = (key, value) => {
28
+ if (!c.persist)
29
+ return;
30
+ try {
31
+ if (value === null)
32
+ localStorage.removeItem(key);
33
+ else
34
+ localStorage.setItem(key, value);
35
+ }
36
+ catch (error) {
37
+ if (!(error instanceof DOMException))
38
+ throw error;
39
+ }
40
+ };
41
+ const storedFlavor = read(c.flavorKey);
42
+ const storedAccent = read(c.accentKey);
43
+ const rootAccent = root.getAttribute('data-accent');
44
+ let preference = isPreference(storedFlavor) ? storedFlavor : c.defaultFlavor;
45
+ let accent = isAccent(storedAccent)
46
+ ? storedAccent
47
+ : (c.accent ?? (isAccent(rootAccent) ? rootAccent : null));
48
+ const resolve = () => preference === 'auto' ? c.flavors[media.matches ? 'light' : 'dark'] : preference;
49
+ const apply = () => {
50
+ const resolved = resolve();
51
+ const { dark, base } = c.palette[resolved];
52
+ const theme = dark ? 'dark' : 'light';
53
+ root.setAttribute('data-flavor', resolved);
54
+ root.setAttribute('data-nw-flavor-preference', preference);
55
+ root.setAttribute('data-theme', theme);
56
+ root.style.colorScheme = theme;
57
+ for (const meta of document.querySelectorAll('meta[data-nyxwire-theme-color]')) {
58
+ meta.setAttribute('content', base);
59
+ meta.removeAttribute('media');
60
+ }
61
+ document.dispatchEvent(new CustomEvent(c.event, { detail: { flavor: preference, resolved, theme, accent } }));
62
+ };
63
+ if (accent !== null)
64
+ root.setAttribute('data-accent', accent);
65
+ window.nyxwire = {
66
+ getFlavor: () => preference,
67
+ resolve,
68
+ setFlavor(next) {
69
+ if (!isPreference(next)) {
70
+ throw new TypeError(`Nyxwire: unknown flavor "${String(next)}" (expected auto or ${Object.keys(c.palette).join(', ')}).`);
71
+ }
72
+ preference = next;
73
+ write(c.flavorKey, next);
74
+ apply();
75
+ },
76
+ getAccent: () => accent,
77
+ setAccent(next) {
78
+ if (next !== null && !isAccent(next)) {
79
+ throw new TypeError(`Nyxwire: unknown accent "${String(next)}" (expected ${c.accents.join(', ')}).`);
80
+ }
81
+ accent = next;
82
+ write(c.accentKey, next);
83
+ if (next === null)
84
+ root.removeAttribute('data-accent');
85
+ else
86
+ root.setAttribute('data-accent', next);
87
+ apply();
88
+ },
89
+ };
90
+ media.addEventListener('change', () => {
91
+ if (preference === 'auto')
92
+ apply();
93
+ });
94
+ document.addEventListener('DOMContentLoaded', apply, { once: true });
95
+ apply();
96
+ }
97
+ export function buildFlavorScript(options = {}) {
98
+ const { defaultFlavor, flavors, accent, persist } = normalizeOptions(options);
99
+ const config = {
100
+ defaultFlavor,
101
+ accent,
102
+ persist,
103
+ flavors,
104
+ palette: {
105
+ abyss: { dark: flavorMeta.abyss.dark, base: palette.abyss.base },
106
+ nocturne: { dark: flavorMeta.nocturne.dark, base: palette.nocturne.base },
107
+ twilight: { dark: flavorMeta.twilight.dark, base: palette.twilight.base },
108
+ lumen: { dark: flavorMeta.lumen.dark, base: palette.lumen.base },
109
+ },
110
+ accents: accentNames,
111
+ flavorKey: FLAVOR_STORAGE_KEY,
112
+ accentKey: ACCENT_STORAGE_KEY,
113
+ event: FLAVOR_CHANGE_EVENT,
114
+ };
115
+ return `(${flavorRuntime.toString()})(${JSON.stringify(config).replace(/</g, '\\u003c')});`;
116
+ }
@@ -0,0 +1,6 @@
1
+ import type { AstroIntegration } from 'astro';
2
+ import type { NyxwireOptions } from './options.ts';
3
+ export * from './flavor-script.ts';
4
+ export * from './options.ts';
5
+ export type { AccentName, DarkFlavorName, FlavorName } from '@nyxwire/palette';
6
+ export default function nyxwire(options?: NyxwireOptions): AstroIntegration;
package/dist/index.js ADDED
@@ -0,0 +1,22 @@
1
+ import { buildFlavorScript } from "./flavor-script.js";
2
+ import { normalizeOptions } from "./options.js";
3
+ export * from "./flavor-script.js";
4
+ export * from "./options.js";
5
+ const stylesheet = {
6
+ full: 'import "@nyxwire/css";',
7
+ tokens: 'import "@nyxwire/css/tokens.css";\nimport "@nyxwire/css/fonts.css";',
8
+ };
9
+ export default function nyxwire(options = {}) {
10
+ const config = normalizeOptions(options);
11
+ const script = buildFlavorScript(options);
12
+ return {
13
+ name: '@nyxwire/astro',
14
+ hooks: {
15
+ 'astro:config:setup': ({ injectScript }) => {
16
+ injectScript('head-inline', script);
17
+ if (config.styles !== false)
18
+ injectScript('page-ssr', stylesheet[config.styles]);
19
+ },
20
+ },
21
+ };
22
+ }
@@ -0,0 +1,46 @@
1
+ import type { AccentName, DarkFlavorName, FlavorName } from '@nyxwire/palette';
2
+ export type FlavorPreference = 'auto' | FlavorName;
3
+ export type StyleMode = 'full' | 'tokens' | false;
4
+ export interface NyxwireOptions {
5
+ readonly flavors?: {
6
+ readonly dark?: DarkFlavorName;
7
+ readonly light?: 'lumen';
8
+ };
9
+ /** Preference used when no valid flavor is stored. */
10
+ readonly defaultFlavor?: FlavorPreference;
11
+ /** Accent applied as `data-accent` on `<html>`; omit to keep the palette default (indigo). */
12
+ readonly accent?: AccentName;
13
+ /** Remember the visitor's flavor and accent in localStorage. */
14
+ readonly persist?: boolean;
15
+ readonly styles?: StyleMode;
16
+ /** Existing on/off switch; use `styles` to select tokens alone. */
17
+ readonly css?: boolean;
18
+ }
19
+ export interface NyxwireConfig {
20
+ readonly flavors: {
21
+ readonly dark: DarkFlavorName;
22
+ readonly light: 'lumen';
23
+ };
24
+ readonly defaultFlavor: FlavorPreference;
25
+ readonly accent: AccentName | null;
26
+ readonly persist: boolean;
27
+ readonly css: boolean;
28
+ readonly styles: StyleMode;
29
+ }
30
+ export type FlavorConfig = NyxwireConfig;
31
+ export declare const FLAVOR_STORAGE_KEY = "nyxwire-flavor";
32
+ export declare const ACCENT_STORAGE_KEY = "nyxwire-accent";
33
+ export declare const FLAVOR_CHANGE_EVENT = "nyxwire:flavor";
34
+ export declare const FLAVOR_EVENT = "nyxwire:flavor";
35
+ export declare const flavorIds: readonly FlavorName[];
36
+ export declare const FLAVOR_IDS: readonly ("abyss" | "nocturne" | "twilight" | "lumen")[];
37
+ export declare const darkFlavorIds: readonly DarkFlavorName[];
38
+ export declare class NyxwireOptionsError extends TypeError {
39
+ readonly option: string;
40
+ readonly expected: string;
41
+ constructor(option: string, expected: string, received: unknown);
42
+ }
43
+ export declare function isFlavorName(value: unknown): value is FlavorName;
44
+ export declare function isAccentName(value: unknown): value is AccentName;
45
+ export declare function isFlavorPreference(value: unknown): value is FlavorPreference;
46
+ export declare function normalizeOptions(options?: unknown): NyxwireConfig;
@@ -0,0 +1,93 @@
1
+ import { accentNames, defaultFlavor as paletteDefaultFlavor, flavorNames } from '@nyxwire/palette';
2
+ export const FLAVOR_STORAGE_KEY = 'nyxwire-flavor';
3
+ export const ACCENT_STORAGE_KEY = 'nyxwire-accent';
4
+ export const FLAVOR_CHANGE_EVENT = 'nyxwire:flavor';
5
+ export const FLAVOR_EVENT = FLAVOR_CHANGE_EVENT;
6
+ export const flavorIds = flavorNames;
7
+ export const FLAVOR_IDS = flavorIds;
8
+ export const darkFlavorIds = flavorIds.filter((id) => id !== 'lumen');
9
+ const optionNames = ['flavors', 'defaultFlavor', 'accent', 'persist', 'styles', 'css'];
10
+ export class NyxwireOptionsError extends TypeError {
11
+ option;
12
+ expected;
13
+ constructor(option, expected, received) {
14
+ super(`@nyxwire/astro: ${option} must be ${expected}; received ${describe(received)}.`);
15
+ this.name = 'NyxwireOptionsError';
16
+ this.option = option;
17
+ this.expected = expected;
18
+ }
19
+ }
20
+ function describe(value) {
21
+ if (value === null)
22
+ return 'null';
23
+ if (Array.isArray(value))
24
+ return 'an array';
25
+ if (typeof value === 'string')
26
+ return JSON.stringify(value);
27
+ if (typeof value === 'object')
28
+ return 'an object';
29
+ return String(value);
30
+ }
31
+ const oneOf = (values) => `one of ${values.map((v) => `"${v}"`).join(', ')}`;
32
+ export function isFlavorName(value) {
33
+ return flavorNames.some((name) => name === value);
34
+ }
35
+ export function isAccentName(value) {
36
+ return accentNames.some((name) => name === value);
37
+ }
38
+ export function isFlavorPreference(value) {
39
+ return value === 'auto' || isFlavorName(value);
40
+ }
41
+ function record(value, name) {
42
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
43
+ throw new NyxwireOptionsError(name, 'an object', value);
44
+ }
45
+ return Object.fromEntries(Object.entries(value));
46
+ }
47
+ export function normalizeOptions(options = {}) {
48
+ const input = record(options, 'options');
49
+ for (const key of Object.keys(input)) {
50
+ if (!optionNames.some((name) => name === key)) {
51
+ throw new NyxwireOptionsError(`option "${key}"`, `a known option (${optionNames.join(', ')})`, key);
52
+ }
53
+ }
54
+ const variants = input['flavors'] === undefined ? {} : record(input['flavors'], 'flavors');
55
+ for (const key of Object.keys(variants)) {
56
+ if (key !== 'dark' && key !== 'light') {
57
+ throw new NyxwireOptionsError(`flavors.${key}`, 'dark or light', key);
58
+ }
59
+ }
60
+ const dark = variants['dark'] === undefined ? paletteDefaultFlavor : variants['dark'];
61
+ if (!isFlavorName(dark) || dark === 'lumen') {
62
+ throw new NyxwireOptionsError('flavors.dark', oneOf(darkFlavorIds), dark);
63
+ }
64
+ const light = variants['light'] === undefined ? 'lumen' : variants['light'];
65
+ if (light !== 'lumen')
66
+ throw new NyxwireOptionsError('flavors.light', '"lumen"', light);
67
+ const defaultFlavor = input['defaultFlavor'] === undefined ? 'auto' : input['defaultFlavor'];
68
+ if (!isFlavorPreference(defaultFlavor)) {
69
+ throw new NyxwireOptionsError('defaultFlavor', oneOf(['auto', ...flavorIds]), defaultFlavor);
70
+ }
71
+ const accent = input['accent'];
72
+ if (accent !== undefined && !isAccentName(accent)) {
73
+ throw new NyxwireOptionsError('accent', oneOf(accentNames), accent);
74
+ }
75
+ const persist = input['persist'] === undefined ? true : input['persist'];
76
+ if (typeof persist !== 'boolean')
77
+ throw new NyxwireOptionsError('persist', 'a boolean', persist);
78
+ const css = input['css'] === undefined ? true : input['css'];
79
+ if (typeof css !== 'boolean')
80
+ throw new NyxwireOptionsError('css', 'a boolean', css);
81
+ const styles = input['styles'] === undefined ? (css ? 'full' : false) : input['styles'];
82
+ if (styles !== 'full' && styles !== 'tokens' && styles !== false) {
83
+ throw new NyxwireOptionsError('styles', '"full", "tokens", or false', styles);
84
+ }
85
+ return {
86
+ flavors: { dark, light },
87
+ defaultFlavor,
88
+ accent: accent ?? null,
89
+ persist,
90
+ css: styles !== false,
91
+ styles,
92
+ };
93
+ }
package/package.json CHANGED
@@ -1,6 +1,60 @@
1
1
  {
2
2
  "name": "@nyxwire/astro",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "Nyxwire for Astro: an integration, a page layout and a flavor switcher that never flashes the wrong theme.",
5
+ "keywords": [
6
+ "nyxwire",
7
+ "design-system",
8
+ "astro",
9
+ "astro-integration",
10
+ "withastro",
11
+ "theme"
12
+ ],
13
+ "homepage": "https://nyxwire.dissidence.ovh/astro/integration/",
14
+ "bugs": {
15
+ "url": "https://github.com/fmauNeko/nyxwire/issues"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/fmauNeko/nyxwire.git",
20
+ "directory": "packages/astro"
21
+ },
22
+ "license": "MIT",
23
+ "author": "Florian Maunier",
24
+ "type": "module",
25
+ "files": [
26
+ "dist",
27
+ "src"
28
+ ],
29
+ "skills": [
30
+ "npm:@nyxwire/css"
31
+ ],
32
+ "exports": {
33
+ ".": {
34
+ "types": "./dist/index.d.ts",
35
+ "import": "./dist/index.js"
36
+ },
37
+ "./components/*": "./src/components/*"
38
+ },
39
+ "dependencies": {
40
+ "@nyxwire/css": "0.1.0",
41
+ "@nyxwire/palette": "0.1.0"
42
+ },
43
+ "peerDependencies": {
44
+ "astro": "^7"
45
+ },
46
+ "devDependencies": {
47
+ "@types/node": "^26",
48
+ "astro": "7.4.7",
49
+ "typescript": "6.0.3",
50
+ "vitest": "5.1.0"
51
+ },
52
+ "publishConfig": {
53
+ "access": "public"
54
+ },
55
+ "scripts": {
56
+ "build": "tsc -p tsconfig.build.json && node ../agent-docs/src/run.ts",
57
+ "test": "vitest run",
58
+ "typecheck": "tsc --noEmit -p tsconfig.json"
59
+ }
6
60
  }
@@ -0,0 +1,11 @@
1
+ ---
2
+ // Use this only without the integration (which already injects the same script into every page).
3
+ import { buildFlavorScript } from '../../dist/index.js'
4
+ import type { NyxwireOptions } from '../../dist/index.js'
5
+
6
+ type Props = NyxwireOptions & { slot?: string }
7
+ const { slot: _slot, ...options } = Astro.props
8
+ const script = buildFlavorScript(options)
9
+ ---
10
+
11
+ <script is:inline set:html={script} />