@regle/nuxt 1.19.9 → 1.19.11
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
package/dist/module.mjs
CHANGED
|
@@ -7,16 +7,15 @@ const module = defineNuxtModule({
|
|
|
7
7
|
configKey: "regle"
|
|
8
8
|
},
|
|
9
9
|
defaults: {},
|
|
10
|
-
async setup(options
|
|
10
|
+
async setup(options) {
|
|
11
11
|
const { resolve } = createResolver(import.meta.url);
|
|
12
12
|
addPlugin({
|
|
13
|
-
src: resolve("runtime/plugins/regle.plugin
|
|
13
|
+
src: resolve("runtime/plugins/regle.plugin"),
|
|
14
14
|
mode: "client"
|
|
15
15
|
});
|
|
16
16
|
addPlugin({
|
|
17
17
|
src: resolve("runtime/plugins/regle-pinia.plugin")
|
|
18
18
|
});
|
|
19
|
-
nuxt.options.build.transpile.push(resolve("runtime/plugins/regle-pinia.plugin"));
|
|
20
19
|
if (options.setupFile) {
|
|
21
20
|
try {
|
|
22
21
|
const setupFilePathOS = await resolvePath(options.setupFile);
|
|
@@ -2,12 +2,12 @@ import type { useCollectScope as defaultUseCollectScope } from '@regle/core';
|
|
|
2
2
|
import {
|
|
3
3
|
type useRegleFn,
|
|
4
4
|
type inferRulesFn,
|
|
5
|
-
type
|
|
5
|
+
type ExtendedRulesDeclarationsOverrides,
|
|
6
6
|
type RegleShortcutDefinition,
|
|
7
7
|
} from '@regle/core';
|
|
8
8
|
|
|
9
9
|
export declare function defineRegleNuxtPlugin<
|
|
10
|
-
TCustomRules extends Partial<
|
|
10
|
+
TCustomRules extends Partial<ExtendedRulesDeclarationsOverrides>,
|
|
11
11
|
TShortcuts extends RegleShortcutDefinition<any>,
|
|
12
12
|
>(
|
|
13
13
|
setup: () => {
|
|
@@ -1,7 +1,2 @@
|
|
|
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
1
|
declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
|
|
7
2
|
export default _default;
|
|
@@ -1,24 +1,34 @@
|
|
|
1
|
-
import { defineNuxtPlugin } from
|
|
1
|
+
import { defineNuxtPlugin } from 'nuxt/app';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Marks Regle instances with Pinia's skipHydrate so SSR payload
|
|
5
|
+
* doesn't try to serialize non-serializable internals.
|
|
6
|
+
*/
|
|
2
7
|
export default defineNuxtPlugin({
|
|
3
|
-
name:
|
|
4
|
-
enforce:
|
|
8
|
+
name: 'regle-pinia',
|
|
9
|
+
enforce: 'post',
|
|
5
10
|
async setup(nuxtApp) {
|
|
6
11
|
const pinia = nuxtApp.$pinia;
|
|
12
|
+
|
|
7
13
|
if (!pinia) return;
|
|
8
|
-
|
|
14
|
+
|
|
15
|
+
const REGLE_SYMBOL = Symbol.for('regle:instance');
|
|
16
|
+
|
|
9
17
|
try {
|
|
10
|
-
const { skipHydrate } = await import(
|
|
18
|
+
const { skipHydrate } = await import('pinia');
|
|
19
|
+
|
|
11
20
|
pinia.use(({ store }) => {
|
|
12
21
|
const state = pinia.state.value[store.$id];
|
|
13
22
|
if (!state) return;
|
|
23
|
+
|
|
14
24
|
for (const key of Object.keys(state)) {
|
|
15
|
-
if (state[key] && typeof state[key] ===
|
|
25
|
+
if (state[key] && typeof state[key] === 'object' && REGLE_SYMBOL in state[key]) {
|
|
16
26
|
state[key] = skipHydrate(state[key]);
|
|
17
27
|
}
|
|
18
28
|
}
|
|
19
29
|
});
|
|
20
30
|
} catch (error) {
|
|
21
|
-
console.error(
|
|
31
|
+
console.error('Failed to import skipHydrate from pinia', { cause: error });
|
|
22
32
|
}
|
|
23
|
-
}
|
|
33
|
+
},
|
|
24
34
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@regle/nuxt",
|
|
3
|
-
"version": "1.19.
|
|
3
|
+
"version": "1.19.11",
|
|
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/
|
|
38
|
-
"@regle/
|
|
37
|
+
"@regle/core": "1.19.11",
|
|
38
|
+
"@regle/rules": "1.19.11"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@nuxt/module-builder": "1.0.2",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
},
|
|
53
53
|
"optionalDependencies": {
|
|
54
54
|
"pinia": ">=2.0.0",
|
|
55
|
-
"@regle/schemas": "1.19.
|
|
55
|
+
"@regle/schemas": "1.19.11"
|
|
56
56
|
},
|
|
57
57
|
"engines": {
|
|
58
58
|
"node": "^20.19.0 || >=22.12.0"
|