@regle/nuxt 1.19.8 → 1.19.9-beta.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.
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@regle/nuxt",
3
3
  "configKey": "regle",
4
- "version": "1.19.8",
4
+ "version": "1.19.9-beta.1",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -7,12 +7,16 @@ const module = defineNuxtModule({
7
7
  configKey: "regle"
8
8
  },
9
9
  defaults: {},
10
- async setup(options) {
10
+ async setup(options, nuxt) {
11
11
  const { resolve } = createResolver(import.meta.url);
12
12
  addPlugin({
13
13
  src: resolve("runtime/plugins/regle.plugin.js"),
14
14
  mode: "client"
15
15
  });
16
+ addPlugin({
17
+ src: resolve("runtime/plugins/regle-pinia.plugin")
18
+ });
19
+ nuxt.options.build.transpile.push(resolve("runtime/plugins/regle-pinia.plugin"));
16
20
  if (options.setupFile) {
17
21
  try {
18
22
  const setupFilePathOS = await resolvePath(options.setupFile);
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Strips non-serializable properties from Pinia's Regle state.
3
+ * Without this, SSR fails because `r$` contains functions, effect scopes, etc.
4
+ * Uses `enforce: 'post'` to guarantee `$pinia` is available regardless of module order.
5
+ */
6
+ declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
7
+ export default _default;
@@ -0,0 +1,24 @@
1
+ import { defineNuxtPlugin } from "nuxt/app";
2
+ export default defineNuxtPlugin({
3
+ name: "regle-pinia",
4
+ enforce: "post",
5
+ async setup(nuxtApp) {
6
+ const pinia = nuxtApp.$pinia;
7
+ if (!pinia) return;
8
+ const REGLE_SYMBOL = Symbol.for("regle:instance");
9
+ try {
10
+ const { skipHydrate } = await import("pinia");
11
+ pinia.use(({ store }) => {
12
+ const state = pinia.state.value[store.$id];
13
+ if (!state) return;
14
+ for (const key of Object.keys(state)) {
15
+ if (state[key] && typeof state[key] === "object" && REGLE_SYMBOL in state[key]) {
16
+ state[key] = skipHydrate(state[key]);
17
+ }
18
+ }
19
+ });
20
+ } catch (error) {
21
+ console.error("Failed to import skipHydrate from pinia", { cause: error });
22
+ }
23
+ }
24
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@regle/nuxt",
3
- "version": "1.19.8",
3
+ "version": "1.19.9-beta.1",
4
4
  "description": "Regle nuxt module",
5
5
  "homepage": "https://reglejs.dev/",
6
6
  "license": "MIT",
@@ -34,8 +34,8 @@
34
34
  "dependencies": {
35
35
  "@nuxt/kit": "4.3.1",
36
36
  "@nuxt/schema": "4.3.1",
37
- "@regle/core": "1.19.8",
38
- "@regle/rules": "1.19.8"
37
+ "@regle/core": "1.19.9-beta.1",
38
+ "@regle/rules": "1.19.9-beta.1"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@nuxt/module-builder": "1.0.2",
@@ -51,7 +51,8 @@
51
51
  "vue-tsc": "3.2.5"
52
52
  },
53
53
  "optionalDependencies": {
54
- "@regle/schemas": "1.19.8"
54
+ "pinia": ">=2.0.0",
55
+ "@regle/schemas": "1.19.9-beta.1"
55
56
  },
56
57
  "engines": {
57
58
  "node": "^20.19.0 || >=22.12.0"