@noy-db/in-nuxt 0.4.0-pre.4 → 0.4.0-pre.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -53,14 +53,14 @@ export default defineNuxtPlugin(async () => {
53
53
  const db = await createNoydb({
54
54
  adapter: browser({ prefix: 'my-app' }),
55
55
  user: 'owner',
56
- secret: () => promptUserForPassphrase(),
56
+ secret: () => promptUserForSecret(),
57
57
  })
58
58
 
59
59
  setActiveNoydb(db)
60
60
  })
61
61
  ```
62
62
 
63
- The reason it's not automatic: `createNoydb` requires a passphrase callback that can't be serialized through Nuxt's runtime config. Eager auto-instantiation is a future enhancement, gated on a real consumer signing off on the bootstrap UX.
63
+ The reason it's not automatic: `createNoydb` requires a secret callback that can't be serialized through Nuxt's runtime config. Eager auto-instantiation is a future enhancement, gated on a real consumer signing off on the bootstrap UX.
64
64
 
65
65
  ## Use it in a component
66
66
 
@@ -115,7 +115,7 @@ A planned CI bundle assertion will verify this property automatically by greppin
115
115
  | `adapter` | `'browser' \| 'memory' \| 'file' \| 'dynamo' \| 's3'` | — | Hint for which built-in adapter to use. Just metadata — your bootstrap code constructs the actual adapter. |
116
116
  | `pinia` | `boolean` | `true` | Auto-import the `@noy-db/in-pinia` helpers. Set to `false` if you don't use Pinia. |
117
117
  | `sync` | `{ adapter, table, region, bucket, mode }` | — | Optional sync configuration metadata, exposed via `runtimeConfig.public.noydb.sync`. |
118
- | `auth` | `{ mode, sessionTimeout }` | — | Optional auth metadata. The actual passphrase callback lives in your bootstrap code. |
118
+ | `auth` | `{ mode, sessionTimeout }` | — | Optional auth metadata. The actual secret callback lives in your bootstrap code. |
119
119
  | `devtools` | `boolean` | `true` | Enable the (planned) devtools tab. Currently a passthrough — the tab itself is a future enhancement. |
120
120
 
121
121
  Every field is fully typed. Open `nuxt.config.ts` in your IDE and you'll get autocomplete on `noydb:`.
package/dist/index.d.ts CHANGED
@@ -26,7 +26,7 @@ import * as _nuxt_schema from '@nuxt/schema';
26
26
  * - Optional Nitro server proxy (`/api/_noydb/...`)
27
27
  * - Optional Nitro scheduled backup task
28
28
  * - `nuxi noydb` CLI extension
29
- * - Eager Noydb instantiation (requires the user's passphrase callback,
29
+ * - Eager Noydb instantiation (requires the user's secret callback,
30
30
  * which can't be serialized through runtime config — better to let
31
31
  * users call setActiveNoydb from their own setup file)
32
32
  */
@@ -71,11 +71,11 @@ interface ModuleOptions {
71
71
  };
72
72
  /**
73
73
  * Optional auth configuration metadata. Same passthrough pattern as
74
- * `sync`. The user provides the actual passphrase / biometric callback
74
+ * `sync`. The user provides the actual secret / biometric callback
75
75
  * in their own setup file.
76
76
  */
77
77
  auth?: {
78
- mode?: 'passphrase' | 'biometric' | 'session';
78
+ mode?: 'secret' | 'biometric' | 'session';
79
79
  sessionTimeout?: string;
80
80
  };
81
81
  /**
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/module.ts","../src/index.ts"],"sourcesContent":["/**\n * Nuxt 4 module for noy-db.\n *\n * Built with `@nuxt/kit`'s `defineNuxtModule`. Targets Nuxt 4+ exclusively\n * (no Nuxt 3 compatibility shim — Nuxt 3 users should consume `@noy-db/vue`\n * and `@noy-db/pinia` directly with a hand-written plugin).\n *\n * Module responsibilities:\n *\n * 1. Auto-import the @noy-db/in-vue composables (`useNoydb`, `useCollection`,\n * `useSync`) and, when `pinia: true` (default), the @noy-db/in-pinia\n * helpers (`defineNoydbStore`, `createNoydbPiniaPlugin`, `setActiveNoydb`).\n *\n * 2. Expose the user's `noydb:` config through `runtimeConfig.public.noydb`\n * so the runtime plugin and downstream composables can read it\n * without re-parsing nuxt.config.ts.\n *\n * 3. Register a CLIENT-ONLY runtime plugin (`runtime/plugin.client.ts`)\n * that sets up the noydb context. The server bundle is never touched —\n * this is the load-bearing SSR-safety property.\n *\n * Deferred to follow-up issues:\n * - Devtools tab via @nuxt/devtools-kit\n * - Optional Nitro server proxy (`/api/_noydb/...`)\n * - Optional Nitro scheduled backup task\n * - `nuxi noydb` CLI extension\n * - Eager Noydb instantiation (requires the user's passphrase callback,\n * which can't be serialized through runtime config — better to let\n * users call setActiveNoydb from their own setup file)\n */\n\nimport { defineNuxtModule, addImports, addPlugin, addServerHandler, createResolver, extendPages } from '@nuxt/kit'\n\n/**\n * Configuration shape for the `noydb:` key in `nuxt.config.ts`.\n *\n * Every field is optional. The defaults give a reasonable bootstrap for\n * a typical Vue/Nuxt app — Pinia helpers auto-imported, `to-browser-idb`\n * as the default store. Users override by passing the relevant fields.\n */\nexport interface ModuleOptions {\n /**\n * Which built-in store package to prefer. The runtime plugin reads this\n * and picks the matching store. Defaults to `'to-browser-idb'` because\n * Nuxt apps run in the browser at runtime.\n *\n * Note: this is just a HINT. Users can always construct their own\n * store and pass it to `createNoydb()` directly — this option exists\n * to keep simple cases simple.\n */\n store?: 'to-browser-idb' | 'to-browser-local' | 'to-memory' | 'to-file' | 'to-aws-dynamo' | 'to-aws-s3'\n\n /**\n * Auto-import the @noy-db/pinia helpers (`defineNoydbStore`,\n * `createNoydbPiniaPlugin`, `setActiveNoydb`). Defaults to `true`\n * because Pinia is the recommended state layer for.\n *\n * Set to `false` if you only want the bare @noy-db/vue composables\n * (saves ~3 KB from the auto-import metadata).\n */\n pinia?: boolean\n\n /**\n * Optional sync configuration. Currently a passthrough — the runtime\n * plugin reads it from `runtimeConfig.public.noydb.sync` and the user\n * is responsible for wiring it into their `createNoydb()` call.\n */\n sync?: {\n store?: 'to-aws-dynamo' | 'to-aws-s3'\n table?: string\n region?: string\n bucket?: string\n mode?: 'auto' | 'manual' | 'off'\n }\n\n /**\n * Optional auth configuration metadata. Same passthrough pattern as\n * `sync`. The user provides the actual passphrase / biometric callback\n * in their own setup file.\n */\n auth?: {\n mode?: 'passphrase' | 'biometric' | 'session'\n sessionTimeout?: string\n }\n\n /**\n * Whether to enable the (planned) devtools tab in `nuxi dev`. Currently\n * a passthrough — the devtools tab itself ships in a follow-up.\n */\n devtools?: boolean\n\n /**\n * Optional REST API integration. When `enabled: true`, mounts a catch-all\n * Nitro server handler at `basePath/**` using `@noy-db/in-rest`.\n *\n * The handler is scaffold-level: it reads `event.context.noydbStore` which\n * a separate Nitro plugin must populate. spec follow-up for the store\n * wiring. The module simply registers the route here.\n */\n rest?: {\n /** Enable the REST API server handler. Default: false. */\n enabled?: boolean\n /** Base path for all REST routes. Default: '/api/noydb'. */\n basePath?: string\n /** User ID forwarded to createRestHandler. */\n user?: string\n /** Session TTL in seconds. Default: 900. */\n ttlSeconds?: number\n }\n}\n\n/**\n * The exported Nuxt module factory.\n *\n * Test-friendly: `defineNuxtModule` returns a NuxtModule object whose\n * `.meta`, `.getOptions`, and `.setup` fields can be inspected without a\n * full Nuxt build. Unit tests use those introspection points instead of\n * spinning up `@nuxt/test-utils`.\n */\nexport default defineNuxtModule<ModuleOptions>({\n meta: {\n name: '@noy-db/in-nuxt',\n configKey: 'noydb',\n compatibility: {\n // Nuxt 4 only — see the module-level docstring for the rationale.\n nuxt: '^4.0.0',\n },\n },\n\n defaults: {\n store: 'to-browser-idb',\n pinia: true,\n devtools: true,\n },\n\n setup(options, nuxt) {\n const resolver = createResolver(import.meta.url)\n\n // ─── 1. Expose the user's options to runtime via runtimeConfig ───\n //\n // We stash the typed options under `runtimeConfig.public.noydb` so\n // the client plugin (and any downstream composable) can read them\n // without re-parsing nuxt.config.ts. `public` is required so the\n // values reach the browser bundle — but EVERY field is metadata\n // (store name, table name, etc.), NEVER a secret. Passphrases\n // and tokens are still provided at runtime via user callbacks.\n nuxt.options.runtimeConfig.public.noydb = {\n // The cast is necessary because Nuxt's runtimeConfig type is\n // structurally `Record<string, any>` — modules are expected to\n // own their own typing via module augmentation (which we do\n // below).\n ...(nuxt.options.runtimeConfig.public.noydb ?? {}),\n ...options,\n }\n\n // ─── 2. Auto-imports for @noy-db/vue composables ────────────────\n //\n // These are the composables shipped by @noy-db/vue. Importing\n // them automatically removes one line of boilerplate per component.\n addImports([\n { name: 'useNoydb', from: '@noy-db/in-vue' },\n { name: 'useCollection', from: '@noy-db/in-vue' },\n { name: 'useSync', from: '@noy-db/in-vue' },\n ])\n\n // ─── 3. Auto-imports for @noy-db/pinia (opt-out) ────────────────\n //\n // Most users want the Pinia helpers — `defineNoydbStore` is the\n // headline API. We default to enabling them and let users\n // opt out via `pinia: false` if they're not using Pinia at all.\n if (options.pinia !== false) {\n addImports([\n { name: 'defineNoydbStore', from: '@noy-db/in-pinia' },\n { name: 'createNoydbPiniaPlugin', from: '@noy-db/in-pinia' },\n { name: 'setActiveNoydb', from: '@noy-db/in-pinia' },\n { name: 'getActiveNoydb', from: '@noy-db/in-pinia' },\n ])\n }\n\n // ─── 4. Register the client-only runtime plugin ─────────────────\n //\n // mode: 'client' is the LOAD-BEARING SSR-safety guarantee. Nuxt\n // skips this plugin entirely on the server, so the server bundle\n // never imports any code that touches `crypto.subtle`. The CI\n // bundle assertion (planned for a follow-up) verifies this by\n // grepping the built nitro output for forbidden symbols.\n //\n // The path resolves to the COMPILED runtime file in `dist/runtime/`.\n // tsup builds this as a separate entry alongside the module index.\n addPlugin({\n src: resolver.resolve('./runtime/plugin.client.js'),\n mode: 'client',\n })\n\n // ─── 5. REST API server handler (opt-in) ────────────────────────\n //\n // When `rest.enabled: true`, mount a catch-all Nitro server handler\n // at `basePath/**`. The handler delegates to `@noy-db/in-rest` via\n // the nitroAdapter. Store wiring (populating event.context.noydbStore)\n // is a follow-up concern tracked separately.\n if (options.rest?.enabled) {\n const basePath = options.rest.basePath ?? '/api/noydb'\n addServerHandler({\n route: `${basePath}/**`,\n handler: resolver.resolve('./runtime/rest'),\n })\n }\n\n // ─── 6. DevTools tab (dev mode only) ────────────────────────\n //\n // Registers a virtual Nuxt page at /_noydb-devtools and exposes it\n // as a tab in the Nuxt DevTools overlay. The page runs inside the\n // user's full Vue app context — no iframe bridge, direct access to\n // getActiveNoydb() and the inspector facade.\n //\n // Guarded on nuxt.options.dev: never ships to production builds.\n // Users can opt out with `noydb: { devtools: false }`.\n if (nuxt.options.dev && options.devtools !== false) {\n const panelFile = resolver.resolve('./runtime/devtools/DevtoolsPanel.vue')\n\n extendPages((pages) => {\n pages.push({\n name: 'noydb-devtools',\n path: '/_noydb-devtools',\n file: panelFile,\n })\n })\n\n // `devtools:customTabs` is not in Nuxt's static HookKeys type but IS\n // dispatched at runtime by @nuxt/devtools. Cast to bypass the type\n // guard while keeping the hook strictly dev-only.\n ;(nuxt as unknown as { hook(event: string, fn: (tabs: unknown[]) => void): void })\n .hook('devtools:customTabs', (tabs: unknown[]) => {\n tabs.push({\n name: 'noy-db',\n title: 'noy-db',\n icon: 'i-carbon-data-base',\n view: { type: 'iframe', src: '/_noydb-devtools' },\n })\n })\n }\n },\n})\n\n/**\n * Module augmentation so the `noydb:` config key in `nuxt.config.ts`\n * is fully typed and autocompleted in the IDE.\n *\n * The augmentation is a side-effect of importing the module — once a\n * project adds `'@noy-db/in-nuxt'` to its `modules` array, TypeScript picks\n * up the typed `noydb` option without requiring an explicit import.\n */\ndeclare module '@nuxt/schema' {\n interface NuxtConfig {\n noydb?: ModuleOptions\n }\n interface NuxtOptions {\n noydb?: ModuleOptions\n }\n interface PublicRuntimeConfig {\n noydb?: ModuleOptions\n }\n}\n","/**\n * @noy-db/nuxt — Nuxt 4 module for noy-db.\n *\n * Public API:\n * - default export: the Nuxt module factory\n * - `ModuleOptions` type: shape of the `noydb:` key in `nuxt.config.ts`\n *\n * The module auto-imports the @noy-db/vue and (optionally) @noy-db/pinia\n * composables, exposes the user's options through Nuxt's runtime config,\n * and registers a CLIENT-ONLY runtime plugin so the SSR bundle never\n * touches `crypto.subtle`. Eager Noydb instantiation is intentionally\n * left to user code — see the README \"Bootstrap\" section.\n */\n\nimport noydbModule, { type ModuleOptions } from './module.js'\n\nexport default noydbModule\nexport type { ModuleOptions }\n"],"mappings":";AA+BA,SAAS,kBAAkB,YAAY,WAAW,kBAAkB,gBAAgB,mBAAmB;AAwFvG,IAAO,iBAAQ,iB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U;AACrB,cAAM,KAAK;AAAA,UACT,MAAM;AAAA,UACN,MAAM;AAAA,UACN,MAAM;AAAA,QACR,CAAC;AAAA,MACH,CAAC;AAKA,MAAC,KACC,KAAK,uBAAuB,CAAC,SAAoB;AAChD,aAAK,KAAK;AAAA,UACR,MAAM;AAAA,UACN,OAAO;AAAA,UACP,MAAM;AAAA,UACN,MAAM,EAAE,MAAM,UAAU,KAAK,mBAAmB;AAAA,QAClD,CAAC;AAAA,MACH,CAAC;AAAA,IACL;AAAA,EACF;AACF,CAAC;;;AClOD,IAAO,gBAAQ;","names":[]}
1
+ {"version":3,"sources":["../src/module.ts","../src/index.ts"],"sourcesContent":["/**\n * Nuxt 4 module for noy-db.\n *\n * Built with `@nuxt/kit`'s `defineNuxtModule`. Targets Nuxt 4+ exclusively\n * (no Nuxt 3 compatibility shim — Nuxt 3 users should consume `@noy-db/vue`\n * and `@noy-db/pinia` directly with a hand-written plugin).\n *\n * Module responsibilities:\n *\n * 1. Auto-import the @noy-db/in-vue composables (`useNoydb`, `useCollection`,\n * `useSync`) and, when `pinia: true` (default), the @noy-db/in-pinia\n * helpers (`defineNoydbStore`, `createNoydbPiniaPlugin`, `setActiveNoydb`).\n *\n * 2. Expose the user's `noydb:` config through `runtimeConfig.public.noydb`\n * so the runtime plugin and downstream composables can read it\n * without re-parsing nuxt.config.ts.\n *\n * 3. Register a CLIENT-ONLY runtime plugin (`runtime/plugin.client.ts`)\n * that sets up the noydb context. The server bundle is never touched —\n * this is the load-bearing SSR-safety property.\n *\n * Deferred to follow-up issues:\n * - Devtools tab via @nuxt/devtools-kit\n * - Optional Nitro server proxy (`/api/_noydb/...`)\n * - Optional Nitro scheduled backup task\n * - `nuxi noydb` CLI extension\n * - Eager Noydb instantiation (requires the user's secret callback,\n * which can't be serialized through runtime config — better to let\n * users call setActiveNoydb from their own setup file)\n */\n\nimport { defineNuxtModule, addImports, addPlugin, addServerHandler, createResolver, extendPages } from '@nuxt/kit'\n\n/**\n * Configuration shape for the `noydb:` key in `nuxt.config.ts`.\n *\n * Every field is optional. The defaults give a reasonable bootstrap for\n * a typical Vue/Nuxt app — Pinia helpers auto-imported, `to-browser-idb`\n * as the default store. Users override by passing the relevant fields.\n */\nexport interface ModuleOptions {\n /**\n * Which built-in store package to prefer. The runtime plugin reads this\n * and picks the matching store. Defaults to `'to-browser-idb'` because\n * Nuxt apps run in the browser at runtime.\n *\n * Note: this is just a HINT. Users can always construct their own\n * store and pass it to `createNoydb()` directly — this option exists\n * to keep simple cases simple.\n */\n store?: 'to-browser-idb' | 'to-browser-local' | 'to-memory' | 'to-file' | 'to-aws-dynamo' | 'to-aws-s3'\n\n /**\n * Auto-import the @noy-db/pinia helpers (`defineNoydbStore`,\n * `createNoydbPiniaPlugin`, `setActiveNoydb`). Defaults to `true`\n * because Pinia is the recommended state layer for.\n *\n * Set to `false` if you only want the bare @noy-db/vue composables\n * (saves ~3 KB from the auto-import metadata).\n */\n pinia?: boolean\n\n /**\n * Optional sync configuration. Currently a passthrough — the runtime\n * plugin reads it from `runtimeConfig.public.noydb.sync` and the user\n * is responsible for wiring it into their `createNoydb()` call.\n */\n sync?: {\n store?: 'to-aws-dynamo' | 'to-aws-s3'\n table?: string\n region?: string\n bucket?: string\n mode?: 'auto' | 'manual' | 'off'\n }\n\n /**\n * Optional auth configuration metadata. Same passthrough pattern as\n * `sync`. The user provides the actual secret / biometric callback\n * in their own setup file.\n */\n auth?: {\n mode?: 'secret' | 'biometric' | 'session'\n sessionTimeout?: string\n }\n\n /**\n * Whether to enable the (planned) devtools tab in `nuxi dev`. Currently\n * a passthrough — the devtools tab itself ships in a follow-up.\n */\n devtools?: boolean\n\n /**\n * Optional REST API integration. When `enabled: true`, mounts a catch-all\n * Nitro server handler at `basePath/**` using `@noy-db/in-rest`.\n *\n * The handler is scaffold-level: it reads `event.context.noydbStore` which\n * a separate Nitro plugin must populate. spec follow-up for the store\n * wiring. The module simply registers the route here.\n */\n rest?: {\n /** Enable the REST API server handler. Default: false. */\n enabled?: boolean\n /** Base path for all REST routes. Default: '/api/noydb'. */\n basePath?: string\n /** User ID forwarded to createRestHandler. */\n user?: string\n /** Session TTL in seconds. Default: 900. */\n ttlSeconds?: number\n }\n}\n\n/**\n * The exported Nuxt module factory.\n *\n * Test-friendly: `defineNuxtModule` returns a NuxtModule object whose\n * `.meta`, `.getOptions`, and `.setup` fields can be inspected without a\n * full Nuxt build. Unit tests use those introspection points instead of\n * spinning up `@nuxt/test-utils`.\n */\nexport default defineNuxtModule<ModuleOptions>({\n meta: {\n name: '@noy-db/in-nuxt',\n configKey: 'noydb',\n compatibility: {\n // Nuxt 4 only — see the module-level docstring for the rationale.\n nuxt: '^4.0.0',\n },\n },\n\n defaults: {\n store: 'to-browser-idb',\n pinia: true,\n devtools: true,\n },\n\n setup(options, nuxt) {\n const resolver = createResolver(import.meta.url)\n\n // ─── 1. Expose the user's options to runtime via runtimeConfig ───\n //\n // We stash the typed options under `runtimeConfig.public.noydb` so\n // the client plugin (and any downstream composable) can read them\n // without re-parsing nuxt.config.ts. `public` is required so the\n // values reach the browser bundle — but EVERY field is metadata\n // (store name, table name, etc.), NEVER a secret. Secrets\n // and tokens are still provided at runtime via user callbacks.\n nuxt.options.runtimeConfig.public.noydb = {\n // The cast is necessary because Nuxt's runtimeConfig type is\n // structurally `Record<string, any>` — modules are expected to\n // own their own typing via module augmentation (which we do\n // below).\n ...(nuxt.options.runtimeConfig.public.noydb ?? {}),\n ...options,\n }\n\n // ─── 2. Auto-imports for @noy-db/vue composables ────────────────\n //\n // These are the composables shipped by @noy-db/vue. Importing\n // them automatically removes one line of boilerplate per component.\n addImports([\n { name: 'useNoydb', from: '@noy-db/in-vue' },\n { name: 'useCollection', from: '@noy-db/in-vue' },\n { name: 'useSync', from: '@noy-db/in-vue' },\n ])\n\n // ─── 3. Auto-imports for @noy-db/pinia (opt-out) ────────────────\n //\n // Most users want the Pinia helpers — `defineNoydbStore` is the\n // headline API. We default to enabling them and let users\n // opt out via `pinia: false` if they're not using Pinia at all.\n if (options.pinia !== false) {\n addImports([\n { name: 'defineNoydbStore', from: '@noy-db/in-pinia' },\n { name: 'createNoydbPiniaPlugin', from: '@noy-db/in-pinia' },\n { name: 'setActiveNoydb', from: '@noy-db/in-pinia' },\n { name: 'getActiveNoydb', from: '@noy-db/in-pinia' },\n ])\n }\n\n // ─── 4. Register the client-only runtime plugin ─────────────────\n //\n // mode: 'client' is the LOAD-BEARING SSR-safety guarantee. Nuxt\n // skips this plugin entirely on the server, so the server bundle\n // never imports any code that touches `crypto.subtle`. The CI\n // bundle assertion (planned for a follow-up) verifies this by\n // grepping the built nitro output for forbidden symbols.\n //\n // The path resolves to the COMPILED runtime file in `dist/runtime/`.\n // tsup builds this as a separate entry alongside the module index.\n addPlugin({\n src: resolver.resolve('./runtime/plugin.client.js'),\n mode: 'client',\n })\n\n // ─── 5. REST API server handler (opt-in) ────────────────────────\n //\n // When `rest.enabled: true`, mount a catch-all Nitro server handler\n // at `basePath/**`. The handler delegates to `@noy-db/in-rest` via\n // the nitroAdapter. Store wiring (populating event.context.noydbStore)\n // is a follow-up concern tracked separately.\n if (options.rest?.enabled) {\n const basePath = options.rest.basePath ?? '/api/noydb'\n addServerHandler({\n route: `${basePath}/**`,\n handler: resolver.resolve('./runtime/rest'),\n })\n }\n\n // ─── 6. DevTools tab (dev mode only) ────────────────────────\n //\n // Registers a virtual Nuxt page at /_noydb-devtools and exposes it\n // as a tab in the Nuxt DevTools overlay. The page runs inside the\n // user's full Vue app context — no iframe bridge, direct access to\n // getActiveNoydb() and the inspector facade.\n //\n // Guarded on nuxt.options.dev: never ships to production builds.\n // Users can opt out with `noydb: { devtools: false }`.\n if (nuxt.options.dev && options.devtools !== false) {\n const panelFile = resolver.resolve('./runtime/devtools/DevtoolsPanel.vue')\n\n extendPages((pages) => {\n pages.push({\n name: 'noydb-devtools',\n path: '/_noydb-devtools',\n file: panelFile,\n })\n })\n\n // `devtools:customTabs` is not in Nuxt's static HookKeys type but IS\n // dispatched at runtime by @nuxt/devtools. Cast to bypass the type\n // guard while keeping the hook strictly dev-only.\n ;(nuxt as unknown as { hook(event: string, fn: (tabs: unknown[]) => void): void })\n .hook('devtools:customTabs', (tabs: unknown[]) => {\n tabs.push({\n name: 'noy-db',\n title: 'noy-db',\n icon: 'i-carbon-data-base',\n view: { type: 'iframe', src: '/_noydb-devtools' },\n })\n })\n }\n },\n})\n\n/**\n * Module augmentation so the `noydb:` config key in `nuxt.config.ts`\n * is fully typed and autocompleted in the IDE.\n *\n * The augmentation is a side-effect of importing the module — once a\n * project adds `'@noy-db/in-nuxt'` to its `modules` array, TypeScript picks\n * up the typed `noydb` option without requiring an explicit import.\n */\ndeclare module '@nuxt/schema' {\n interface NuxtConfig {\n noydb?: ModuleOptions\n }\n interface NuxtOptions {\n noydb?: ModuleOptions\n }\n interface PublicRuntimeConfig {\n noydb?: ModuleOptions\n }\n}\n","/**\n * @noy-db/nuxt — Nuxt 4 module for noy-db.\n *\n * Public API:\n * - default export: the Nuxt module factory\n * - `ModuleOptions` type: shape of the `noydb:` key in `nuxt.config.ts`\n *\n * The module auto-imports the @noy-db/vue and (optionally) @noy-db/pinia\n * composables, exposes the user's options through Nuxt's runtime config,\n * and registers a CLIENT-ONLY runtime plugin so the SSR bundle never\n * touches `crypto.subtle`. Eager Noydb instantiation is intentionally\n * left to user code — see the README \"Bootstrap\" section.\n */\n\nimport noydbModule, { type ModuleOptions } from './module.js'\n\nexport default noydbModule\nexport type { ModuleOptions }\n"],"mappings":";AA+BA,SAAS,kBAAkB,YAAY,WAAW,kBAAkB,gBAAgB,mBAAmB;AAwFvG,IAAO,iBAAQ,iBAAgC;AAAA,EAC7C,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,WAAW;AAAA,IACX,eAAe;AAAA;AAAA,MAEb,MAAM;AAAA,IACR;AAAA,EACF;AAAA,EAEA,UAAU;AAAA,IACR,OAAO;AAAA,IACP,OAAO;AAAA,IACP,UAAU;AAAA,EACZ;AAAA,EAEA,MAAM,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A,UACN,MAAM,EAAE,MAAM,UAAU,KAAK,mBAAmB;AAAA,QAClD,CAAC;AAAA,MACH,CAAC;AAAA,IACL;AAAA,EACF;AACF,CAAC;;;AClOD,IAAO,gBAAQ;","names":[]}
@@ -12,7 +12,7 @@ import * as nuxt_app from 'nuxt/app';
12
12
  * and stash it on the Nuxt app context for later access via the
13
13
  * auto-imported `useRuntimeConfig()` composable.
14
14
  *
15
- * 2. NOT auto-instantiate Noydb. The library requires a passphrase
15
+ * 2. NOT auto-instantiate Noydb. The library requires a secret
16
16
  * callback to derive keys, and that callback can't be serialized
17
17
  * through runtime config. Users call `setActiveNoydb(instance)`
18
18
  * themselves from their app's setup file (the README documents
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/runtime/plugin.client.ts"],"sourcesContent":["/**\n * Client-only runtime plugin for the @noy-db/nuxt module.\n *\n * This file is registered with `mode: 'client'` so Nuxt NEVER imports it\n * into the server bundle. Every line below assumes a browser context.\n *\n * The plugin's job today:\n *\n * 1. Read the user's noydb config from `useRuntimeConfig().public.noydb`\n * and stash it on the Nuxt app context for later access via the\n * auto-imported `useRuntimeConfig()` composable.\n *\n * 2. NOT auto-instantiate Noydb. The library requires a passphrase\n * callback to derive keys, and that callback can't be serialized\n * through runtime config. Users call `setActiveNoydb(instance)`\n * themselves from their app's setup file (the README documents\n * the recommended pattern).\n *\n * Future work:\n * - Read a user-supplied `bootstrap` callback from a Nuxt provide()\n * and call it here to construct Noydb automatically when possible\n * - Wire the devtools tab via @nuxt/devtools-kit\n * - Surface ledger / sync status on the Nuxt app context\n */\n\nimport { defineNuxtPlugin, useRuntimeConfig } from 'nuxt/app'\n\nexport default defineNuxtPlugin({\n name: 'noy-db:client',\n enforce: 'pre',\n setup(_nuxtApp) {\n // Read the typed module options the user passed in nuxt.config.ts.\n // The cast is safe because @noy-db/nuxt's module file augments\n // PublicRuntimeConfig with the noydb shape (see module.ts).\n const config = useRuntimeConfig().public.noydb\n\n // Surface the config on `globalThis` so non-Vue contexts (e.g.,\n // a custom error reporter or a Web Worker) can read it. This is\n // intentionally on `globalThis` rather than the Nuxt provide()\n // map so the helper packages stay framework-agnostic.\n if (config) {\n ;(globalThis as { __NOYDB_NUXT_CONFIG__?: unknown }).__NOYDB_NUXT_CONFIG__ = config\n }\n\n // No return value — the plugin's only side effect is the global\n // assignment above. Future versions will return `provide` keys\n // for first-class composable access.\n },\n})\n"],"mappings":";AAyBA,SAAS,kBAAkB,wBAAwB;AAEnD,IAAO,wBAAQ,iBAAiB;AAAA,EAC9B,MAAM;AAAA,EACN,SAAS;AAAA,EACT,MAAM,UAAU;AAId,UAAM,SAAS,iBAAiB,EAAE,OAAO;AAMzC,QAAI,QAAQ;AACV;AAAC,MAAC,WAAmD,wBAAwB;AAAA,IAC/E;AAAA,EAKF;AACF,CAAC;","names":[]}
1
+ {"version":3,"sources":["../../src/runtime/plugin.client.ts"],"sourcesContent":["/**\n * Client-only runtime plugin for the @noy-db/nuxt module.\n *\n * This file is registered with `mode: 'client'` so Nuxt NEVER imports it\n * into the server bundle. Every line below assumes a browser context.\n *\n * The plugin's job today:\n *\n * 1. Read the user's noydb config from `useRuntimeConfig().public.noydb`\n * and stash it on the Nuxt app context for later access via the\n * auto-imported `useRuntimeConfig()` composable.\n *\n * 2. NOT auto-instantiate Noydb. The library requires a secret\n * callback to derive keys, and that callback can't be serialized\n * through runtime config. Users call `setActiveNoydb(instance)`\n * themselves from their app's setup file (the README documents\n * the recommended pattern).\n *\n * Future work:\n * - Read a user-supplied `bootstrap` callback from a Nuxt provide()\n * and call it here to construct Noydb automatically when possible\n * - Wire the devtools tab via @nuxt/devtools-kit\n * - Surface ledger / sync status on the Nuxt app context\n */\n\nimport { defineNuxtPlugin, useRuntimeConfig } from 'nuxt/app'\n\nexport default defineNuxtPlugin({\n name: 'noy-db:client',\n enforce: 'pre',\n setup(_nuxtApp) {\n // Read the typed module options the user passed in nuxt.config.ts.\n // The cast is safe because @noy-db/nuxt's module file augments\n // PublicRuntimeConfig with the noydb shape (see module.ts).\n const config = useRuntimeConfig().public.noydb\n\n // Surface the config on `globalThis` so non-Vue contexts (e.g.,\n // a custom error reporter or a Web Worker) can read it. This is\n // intentionally on `globalThis` rather than the Nuxt provide()\n // map so the helper packages stay framework-agnostic.\n if (config) {\n ;(globalThis as { __NOYDB_NUXT_CONFIG__?: unknown }).__NOYDB_NUXT_CONFIG__ = config\n }\n\n // No return value — the plugin's only side effect is the global\n // assignment above. Future versions will return `provide` keys\n // for first-class composable access.\n },\n})\n"],"mappings":";AAyBA,SAAS,kBAAkB,wBAAwB;AAEnD,IAAO,wBAAQ,iBAAiB;AAAA,EAC9B,MAAM;AAAA,EACN,SAAS;AAAA,EACT,MAAM,UAAU;AAId,UAAM,SAAS,iBAAiB,EAAE,OAAO;AAMzC,QAAI,QAAQ;AACV;AAAC,MAAC,WAAmD,wBAAwB;AAAA,IAC/E;AAAA,EAKF;AACF,CAAC;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noy-db/in-nuxt",
3
- "version": "0.4.0-pre.4",
3
+ "version": "0.4.0-pre.6",
4
4
  "description": "Nuxt 4 module for noy-db — auto-imports, SSR-safe runtime plugin, and the @noy-db/in-pinia bridge",
5
5
  "license": "MIT",
6
6
  "author": "vLannaAi <vicio@lanna.ai>",
@@ -34,10 +34,10 @@
34
34
  },
35
35
  "peerDependencies": {
36
36
  "nuxt": "^4.0.0",
37
- "@noy-db/in-pinia": "0.4.0-pre.4",
38
- "@noy-db/in-rest": "0.4.0-pre.4",
39
- "@noy-db/hub": "0.4.0-pre.4",
40
- "@noy-db/in-vue": "0.4.0-pre.4"
37
+ "@noy-db/hub": "0.4.0-pre.6",
38
+ "@noy-db/in-vue": "0.4.0-pre.6",
39
+ "@noy-db/in-rest": "0.4.0-pre.6",
40
+ "@noy-db/in-pinia": "0.4.0-pre.6"
41
41
  },
42
42
  "peerDependenciesMeta": {
43
43
  "@noy-db/in-rest": {
@@ -45,7 +45,7 @@
45
45
  }
46
46
  },
47
47
  "dependencies": {
48
- "@noy-db/in-devtools": "0.4.0-pre.4"
48
+ "@noy-db/in-devtools": "0.4.0-pre.6"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@nuxt/kit": "^4.4.2",
@@ -56,10 +56,10 @@
56
56
  "happy-dom": "^17.4.4",
57
57
  "nuxt": "^4.4.2",
58
58
  "vue": "^3.5.32",
59
- "@noy-db/hub": "0.4.0-pre.4",
60
- "@noy-db/in-pinia": "0.4.0-pre.4",
61
- "@noy-db/in-rest": "0.4.0-pre.4",
62
- "@noy-db/in-vue": "0.4.0-pre.4"
59
+ "@noy-db/hub": "0.4.0-pre.6",
60
+ "@noy-db/in-rest": "0.4.0-pre.6",
61
+ "@noy-db/in-vue": "0.4.0-pre.6",
62
+ "@noy-db/in-pinia": "0.4.0-pre.6"
63
63
  },
64
64
  "keywords": [
65
65
  "noy-db",