@dyrected/nuxt 2.5.20 → 2.5.23
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
|
@@ -85,14 +85,73 @@ const module = defineNuxtModule({
|
|
|
85
85
|
filename: "dyrected-load-config.ts",
|
|
86
86
|
write: true
|
|
87
87
|
});
|
|
88
|
-
let dbPluginSrc = resolver.resolve("./runtime/server/plugins/db.ts");
|
|
89
|
-
if (!existsSync(dbPluginSrc)) {
|
|
90
|
-
dbPluginSrc = resolver.resolve("./runtime/server/plugins/db.mjs");
|
|
91
|
-
}
|
|
92
88
|
const dbPluginTemplate = addTemplate({
|
|
93
|
-
src: dbPluginSrc,
|
|
94
89
|
filename: "dyrected-db-plugin.ts",
|
|
95
|
-
write: true
|
|
90
|
+
write: true,
|
|
91
|
+
getContents: () => {
|
|
92
|
+
const escapedConfigPath = configPath.replace(/\\/g, "/");
|
|
93
|
+
return `// @ts-ignore
|
|
94
|
+
import { useRuntimeConfig } from "#imports";
|
|
95
|
+
// @ts-ignore
|
|
96
|
+
import userConfigRaw from "${escapedConfigPath}";
|
|
97
|
+
|
|
98
|
+
const defineNitroPlugin = (def) => def;
|
|
99
|
+
|
|
100
|
+
export default defineNitroPlugin(async (nitroApp) => {
|
|
101
|
+
const runtimeConfig = useRuntimeConfig().dyrected;
|
|
102
|
+
|
|
103
|
+
try {
|
|
104
|
+
const userConfig = userConfigRaw.default || userConfigRaw;
|
|
105
|
+
const configObj = (userConfig.default && (userConfig.default.collections || userConfig.default.globals || userConfig.default.db)) ? userConfig.default : userConfig;
|
|
106
|
+
|
|
107
|
+
if (configObj) {
|
|
108
|
+
globalThis.__dyrected_config = configObj;
|
|
109
|
+
if (configObj.db) {
|
|
110
|
+
globalThis.__dyrected_db = configObj.db;
|
|
111
|
+
console.log("[dyrected/nuxt] Database re-attached to global context");
|
|
112
|
+
}
|
|
113
|
+
if (configObj.storage) {
|
|
114
|
+
globalThis.__dyrected_storage = configObj.storage;
|
|
115
|
+
console.log("[dyrected/nuxt] Storage adapter re-attached to global context");
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (process.env.NODE_ENV !== 'production' && runtimeConfig?.configPath) {
|
|
120
|
+
const { watch } = await import('fs');
|
|
121
|
+
// @ts-ignore
|
|
122
|
+
const { loadDyrectedConfig } = await import("./dyrected-load-config.ts");
|
|
123
|
+
let debounceTimer = null;
|
|
124
|
+
const reload = async () => {
|
|
125
|
+
try {
|
|
126
|
+
const newConfig = await loadDyrectedConfig(runtimeConfig.configPath);
|
|
127
|
+
const newObj = (newConfig.default && (newConfig.default.collections || newConfig.default.globals || newConfig.default.db)) ? newConfig.default : newConfig;
|
|
128
|
+
globalThis.__dyrected_config = newObj;
|
|
129
|
+
globalThis.__dyrected_config_version = (globalThis.__dyrected_config_version || 0) + 1;
|
|
130
|
+
if (newObj.db) {
|
|
131
|
+
globalThis.__dyrected_db = newObj.db;
|
|
132
|
+
console.log('[dyrected/nuxt] Database hot-reloaded');
|
|
133
|
+
}
|
|
134
|
+
if (newObj.storage) {
|
|
135
|
+
globalThis.__dyrected_storage = newObj.storage;
|
|
136
|
+
console.log('[dyrected/nuxt] Storage hot-reloaded');
|
|
137
|
+
}
|
|
138
|
+
} catch (e) {
|
|
139
|
+
console.error('[dyrected/nuxt] Hot-reload failed:', e);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
watch(runtimeConfig.configPath, (eventType) => {
|
|
143
|
+
if (eventType === 'change') {
|
|
144
|
+
if (debounceTimer) clearTimeout(debounceTimer);
|
|
145
|
+
debounceTimer = setTimeout(reload, 200);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
} catch (err) {
|
|
150
|
+
console.error("[dyrected/nuxt] Failed to re-attach database:", err);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
`;
|
|
154
|
+
}
|
|
96
155
|
});
|
|
97
156
|
addServerPlugin(dbPluginTemplate.dst);
|
|
98
157
|
} else {
|
|
@@ -146,6 +205,21 @@ const module = defineNuxtModule({
|
|
|
146
205
|
if (!nuxt.options.vite.optimizeDeps.exclude.includes("@dyrected/vue")) {
|
|
147
206
|
nuxt.options.vite.optimizeDeps.exclude.push("@dyrected/vue");
|
|
148
207
|
}
|
|
208
|
+
nuxt.options.vite.resolve = nuxt.options.vite.resolve || {};
|
|
209
|
+
nuxt.options.vite.resolve.dedupe = nuxt.options.vite.resolve.dedupe || [];
|
|
210
|
+
for (const dep of ["react", "react-dom"]) {
|
|
211
|
+
if (!nuxt.options.vite.resolve.dedupe.includes(dep)) {
|
|
212
|
+
nuxt.options.vite.resolve.dedupe.push(dep);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
nuxt.options.vite.resolve.alias = nuxt.options.vite.resolve.alias || {};
|
|
216
|
+
try {
|
|
217
|
+
const reactMain = _require.resolve("react");
|
|
218
|
+
const reactDomMain = _require.resolve("react-dom");
|
|
219
|
+
nuxt.options.vite.resolve.alias.react = join(reactMain, "..");
|
|
220
|
+
nuxt.options.vite.resolve.alias["react-dom"] = join(reactDomMain, "..");
|
|
221
|
+
} catch {
|
|
222
|
+
}
|
|
149
223
|
}
|
|
150
224
|
nuxt.options.build.transpile.push("@dyrected/sdk", "@dyrected/vue", "@dyrected/admin");
|
|
151
225
|
const optionsAny = nuxt.options;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
<DyrectedAdmin
|
|
3
3
|
:config="config"
|
|
4
4
|
:basename="basename || '/cms-admin'"
|
|
5
|
+
:components="components"
|
|
5
6
|
/>
|
|
6
7
|
</template>
|
|
7
8
|
|
|
@@ -16,6 +17,10 @@ defineProps<{
|
|
|
16
17
|
* @default "/cms-admin"
|
|
17
18
|
*/
|
|
18
19
|
basename?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Custom components to inject into the Admin UI.
|
|
22
|
+
*/
|
|
23
|
+
components?: any;
|
|
19
24
|
}>();
|
|
20
25
|
|
|
21
26
|
const runtimeConfig = useRuntimeConfig();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dyrected/nuxt",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.23",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/module.mjs",
|
|
6
6
|
"types": "./dist/module.d.ts",
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@nuxt/kit": "^3.11.2",
|
|
12
12
|
"h3": "^1.15.0",
|
|
13
|
-
"@dyrected/core": "2.5.
|
|
14
|
-
"@dyrected/sdk": "2.5.
|
|
15
|
-
"@dyrected/
|
|
16
|
-
"@dyrected/
|
|
13
|
+
"@dyrected/core": "2.5.23",
|
|
14
|
+
"@dyrected/sdk": "2.5.23",
|
|
15
|
+
"@dyrected/admin": "2.5.23",
|
|
16
|
+
"@dyrected/vue": "2.5.23"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"nuxt": "^3.0.0",
|