@prosary/nuxt 0.0.0-stage → 0.0.1

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,5 @@
1
+ /**
2
+ * Whether this code is running in the server render. Its own module so the
3
+ * one place that asks can be answered either way under test.
4
+ */
5
+ export declare const onServer: () => boolean;
@@ -0,0 +1,2 @@
1
+ const onServer = () => import.meta.server === true;
2
+ export { onServer };
@@ -0,0 +1,15 @@
1
+ import { AppProsarySelection } from "./types.mjs";
2
+ /**
3
+ * The per-request state and cookies the plugin and composables share. The
4
+ * state is the visitor's selection only — the locale and how values are
5
+ * formatted — so it is all the server render hands the browser; the messages
6
+ * are loaded on each side and never serialized into the page.
7
+ */
8
+ export declare const accessProsary: () => {
9
+ selection: import("vue").Ref<AppProsarySelection, AppProsarySelection>;
10
+ cookies: {
11
+ locale: import("vue").Ref<string | null, string | null>;
12
+ timeZone: import("vue").Ref<string | null, string | null>;
13
+ convention: import("vue").Ref<string | null, string | null>;
14
+ };
15
+ };
@@ -0,0 +1,14 @@
1
+ import { CONVENTION_COOKIE, LOCALE_COOKIE, TIME_ZONE_COOKIE } from "../constant.mjs";
2
+ import { useCookie, useState } from "#imports";
3
+ import { contract } from "#build/prosary/index.mjs";
4
+ const accessProsary = () => {
5
+ return {
6
+ selection: useState("prosary:selection", () => ({ locale: contract.locale })),
7
+ cookies: {
8
+ locale: useCookie(LOCALE_COOKIE),
9
+ timeZone: useCookie(TIME_ZONE_COOKIE),
10
+ convention: useCookie(CONVENTION_COOKIE)
11
+ }
12
+ };
13
+ };
14
+ export { accessProsary };
@@ -0,0 +1,80 @@
1
+ import { Contract, Document } from "#build/prosary/index.mjs";
2
+ import { Bundle, Config, Key, Locale, Message, Prosary, Resolver } from "prosary";
3
+ /**
4
+ * The active contract: the `Contract` the build-time `index` module declares
5
+ * over its locales, messages and formats.
6
+ */
7
+ export type AppProsaryContract = Contract;
8
+ /**
9
+ * A locale the app is built for.
10
+ */
11
+ export type AppProsaryLocale = Locale<AppProsaryContract>;
12
+ /**
13
+ * The key of a message of the app.
14
+ */
15
+ export type AppProsaryKey = Key<AppProsaryContract>;
16
+ /**
17
+ * A message of the app — its key, with the values it takes when it takes
18
+ * any — as data a component can be handed and resolve: `$t(message)`.
19
+ */
20
+ export type AppProsaryMessage = Message<AppProsaryContract>;
21
+ /**
22
+ * A content document the app is built with, by its path.
23
+ */
24
+ export type AppProsaryDocument = Document;
25
+ /**
26
+ * One locale's compiled messages.
27
+ */
28
+ export type AppProsaryBundle = Bundle<AppProsaryContract>;
29
+ /**
30
+ * The caller-owned state container the service operates on.
31
+ */
32
+ export type AppProsaryConfig = Config<AppProsaryContract>;
33
+ /**
34
+ * The runtime translation service bound to the app's contract.
35
+ */
36
+ export type AppProsary = Prosary<AppProsaryContract>;
37
+ /**
38
+ * The app's messages as functions: what `$t` is.
39
+ */
40
+ export type AppProsaryResolver = Resolver<AppProsaryContract>;
41
+ /**
42
+ * What a visitor has chosen, and what travels from the server render to the
43
+ * browser: the locale, and how values are formatted. The messages do not —
44
+ * each side loads the locale's bundle itself.
45
+ */
46
+ export interface AppProsarySelection {
47
+ locale: AppProsaryLocale;
48
+ timeZone?: string | undefined;
49
+ convention?: string | undefined;
50
+ }
51
+ /**
52
+ * Switches the app to a locale: loads its bundle, then applies both in one
53
+ * step. Of calls that overlap, the last one made wins.
54
+ */
55
+ export type SetLocale = (locale: AppProsaryLocale) => Promise<void>;
56
+ /**
57
+ * The runtime hooks the service emits, keyed by event name. Shared between the
58
+ * `#app` augmentation and {@link ProsaryNuxtApp} so the two never drift.
59
+ */
60
+ export interface ProsaryHooks {
61
+ "prosary:ready": (service: AppProsary) => void;
62
+ "prosary:locale": (locale: AppProsaryLocale) => void;
63
+ }
64
+ /**
65
+ * The minimal `nuxtApp` surface the instrumentation needs. Typing against this
66
+ * instead of `NuxtApp` keeps `makeProsary` off the `NuxtApp.$prosary` →
67
+ * `AppProsary` → `makeProsary` cycle that otherwise makes the augmentation
68
+ * recursive.
69
+ */
70
+ export interface ProsaryNuxtApp {
71
+ callHook<H extends keyof ProsaryHooks>(name: H, ...args: Parameters<ProsaryHooks[H]>): unknown;
72
+ }
73
+ declare module "#app" {
74
+ interface NuxtApp {
75
+ $prosary: AppProsary;
76
+ $t: AppProsaryResolver;
77
+ $setLocale: SetLocale;
78
+ }
79
+ interface RuntimeNuxtHooks extends ProsaryHooks {}
80
+ }
@@ -0,0 +1 @@
1
+ export {};
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Alexander Thorwaldson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,28 @@
1
- # Temporary Holding Version
1
+ # @prosary/nuxt
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Nuxt module for prosary — builds the app's messages, loads one locale per visitor, and provides `$t`.
4
+
5
+ ## Rendering content
6
+
7
+ `useDocument(path)` loads a content document as the HTML tree the kit built,
8
+ in the visitor's locale. `<Prose :tree>` renders it through
9
+ [`@prosary/vue`](../vue), with the app's overrides.
10
+
11
+ The overrides are the `.vue` files at the top level of `app/components/prose`
12
+ (or the directory `components` names, relative to `app/`). Each renders the tag or directive its
13
+ file name spells in kebab case: `H2.vue` renders every `h2`, `Callout.vue`
14
+ every `callout` directive. A component in place of a tag receives the
15
+ element's attributes as props and its children in the default slot; one in
16
+ place of a directive receives the directive's attributes by the names they
17
+ were written with. An override that names neither an element nor a directive
18
+ the content builds fails `nuxt typecheck`.
19
+
20
+ ```vue
21
+ <script setup lang="ts">
22
+ const { data: guide } = await useDocument("guide.md");
23
+ </script>
24
+
25
+ <template>
26
+ <Prose v-if="guide" :tree="guide" />
27
+ </template>
28
+ ```
package/package.json CHANGED
@@ -1,6 +1,60 @@
1
1
  {
2
2
  "name": "@prosary/nuxt",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.0.1",
4
+ "description": "Nuxt module for prosary — builds the app's messages, loads one locale per visitor, and provides `$t`",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/zoobzio/prosary.git",
9
+ "directory": "integrations/nuxt"
10
+ },
11
+ "type": "module",
12
+ "main": "./.dist/module.mjs",
13
+ "types": "./.dist/module.d.mts",
14
+ "exports": {
15
+ ".": {
16
+ "types": "./.dist/module.d.mts",
17
+ "import": "./.dist/module.mjs"
18
+ },
19
+ "./config": {
20
+ "types": "./.dist/config.d.mts",
21
+ "import": "./.dist/config.mjs"
22
+ },
23
+ "./constant": {
24
+ "types": "./.dist/constant.d.mts",
25
+ "import": "./.dist/constant.mjs"
26
+ }
27
+ },
28
+ "files": [
29
+ ".dist"
30
+ ],
31
+ "dependencies": {
32
+ "@nuxt/kit": "^4.4.6",
33
+ "@types/hast": "^3.0.5",
34
+ "vue": "^3.5.35",
35
+ "@prosary/vue": "0.0.1",
36
+ "prosary": "0.0.1"
37
+ },
38
+ "peerDependencies": {
39
+ "@prosary/kit": "0.0.1"
40
+ },
41
+ "peerDependenciesMeta": {
42
+ "@prosary/kit": {
43
+ "optional": true
44
+ }
45
+ },
46
+ "devDependencies": {
47
+ "@nuxt/nitro-server": "^4.4.6",
48
+ "@nuxt/schema": "^4.4.6",
49
+ "@types/node": "^25.9.9",
50
+ "nuxt": "^4.4.6",
51
+ "@prosary/kit": "0.0.1"
52
+ },
53
+ "scripts": {
54
+ "build": "obuild",
55
+ "stub": "obuild --stub",
56
+ "lint": "oxlint",
57
+ "typecheck": "tsc --noEmit",
58
+ "test": "vitest run"
59
+ }
6
60
  }