@dropi/ui 0.1.25 → 0.1.27
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/package.json +1 -1
- package/scripts/setup.js +49 -9
package/package.json
CHANGED
package/scripts/setup.js
CHANGED
|
@@ -80,23 +80,27 @@ async function run() {
|
|
|
80
80
|
const pkgMgr = getPkgMgr();
|
|
81
81
|
const installCmd = pkgMgr === 'yarn' ? 'yarn add' : pkgMgr === 'pnpm' ? 'pnpm add' : 'npm install';
|
|
82
82
|
|
|
83
|
-
if ((isReact || isNextJs) && !hasDep('@dropi/ui-react')) {
|
|
84
|
-
|
|
83
|
+
if ((isReact || isNextJs) && (!hasDep('@dropi/ui') || !hasDep('@dropi/ui-react'))) {
|
|
84
|
+
const toInstall = [
|
|
85
|
+
!hasDep('@dropi/ui') ? '@dropi/ui' : null,
|
|
86
|
+
!hasDep('@dropi/ui-react') ? '@dropi/ui-react' : null,
|
|
87
|
+
].filter(Boolean).join(' ');
|
|
88
|
+
log(`Instalando ${toInstall}...`);
|
|
85
89
|
try {
|
|
86
|
-
execSync(`${installCmd}
|
|
87
|
-
log(
|
|
90
|
+
execSync(`${installCmd} ${toInstall}`, { stdio: 'inherit', cwd: projectRoot });
|
|
91
|
+
log(`${toInstall} instalado.`, 'ok');
|
|
88
92
|
} catch (e) {
|
|
89
|
-
log(
|
|
93
|
+
log(`Error instalando ${toInstall}. Intenta instalarlo manualmente.`, 'warn');
|
|
90
94
|
}
|
|
91
95
|
}
|
|
92
96
|
|
|
93
97
|
if (isNextJsSsr && !hasDep('@stencil/ssr')) {
|
|
94
98
|
log('Next.js SSR → Instalando @stencil/ssr...');
|
|
95
99
|
try {
|
|
96
|
-
execSync(`${installCmd} --save-dev @stencil/ssr`, { stdio: 'inherit', cwd: projectRoot });
|
|
100
|
+
execSync(`${installCmd} --save-dev @stencil/ssr --legacy-peer-deps`, { stdio: 'inherit', cwd: projectRoot });
|
|
97
101
|
log('@stencil/ssr instalado.', 'ok');
|
|
98
102
|
} catch (e) {
|
|
99
|
-
log('Error instalando @stencil/ssr. Intenta instalarlo manualmente
|
|
103
|
+
log('Error instalando @stencil/ssr. Intenta instalarlo manualmente: npm install --save-dev @stencil/ssr --legacy-peer-deps', 'warn');
|
|
100
104
|
}
|
|
101
105
|
}
|
|
102
106
|
|
|
@@ -250,14 +254,50 @@ dropi-icon:not(.hydrated) {
|
|
|
250
254
|
const layoutPath = layoutCandidates.find(f => fs.existsSync(f));
|
|
251
255
|
if (layoutPath) {
|
|
252
256
|
let layout = fs.readFileSync(layoutPath, 'utf8');
|
|
257
|
+
let layoutChanged = false;
|
|
258
|
+
|
|
259
|
+
// Agregar suppressHydrationWarning al <body>
|
|
260
|
+
if (!layout.includes('suppressHydrationWarning')) {
|
|
261
|
+
layout = layout.replace(/<body(\s[^>]*)?>/, (_, attrs) => {
|
|
262
|
+
const existing = attrs || '';
|
|
263
|
+
return `<body${existing} suppressHydrationWarning>`;
|
|
264
|
+
});
|
|
265
|
+
layoutChanged = true;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// Agregar Lottie script antes del cierre de </body>
|
|
253
269
|
if (!layout.includes('lottie-player.js')) {
|
|
254
|
-
// Agregar script antes del cierre de </body>
|
|
255
270
|
layout = layout.replace(
|
|
256
271
|
/(<\/body>)/,
|
|
257
272
|
` {/* lottie-player: needed by DropiAlertModal animations */}\n <script src="https://unpkg.com/@lottiefiles/lottie-player@latest/dist/lottie-player.js" async />\n $1`
|
|
258
273
|
);
|
|
274
|
+
layoutChanged = true;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (layoutChanged) {
|
|
259
278
|
fs.writeFileSync(layoutPath, layout);
|
|
260
|
-
log(`${path.relative(projectRoot, layoutPath)}:
|
|
279
|
+
log(`${path.relative(projectRoot, layoutPath)}: layout configurado.`, 'ok');
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// Agregar --webpack a scripts dev/build si Next.js >= 16 (Turbopack incompatible con @stencil/ssr)
|
|
284
|
+
if (isNextJsSsr) {
|
|
285
|
+
const nextVersion = pkg.dependencies?.['next'] || pkg.devDependencies?.['next'] || '';
|
|
286
|
+
const majorVersion = parseInt(nextVersion.replace(/[^0-9]/, ''), 10);
|
|
287
|
+
if (majorVersion >= 16) {
|
|
288
|
+
const pkgPath = path.join(projectRoot, 'package.json');
|
|
289
|
+
let projectPkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
290
|
+
let pkgChanged = false;
|
|
291
|
+
['dev', 'build'].forEach(script => {
|
|
292
|
+
if (projectPkg.scripts?.[script] && !projectPkg.scripts[script].includes('--webpack')) {
|
|
293
|
+
projectPkg.scripts[script] += ' --webpack';
|
|
294
|
+
pkgChanged = true;
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
if (pkgChanged) {
|
|
298
|
+
fs.writeFileSync(pkgPath, JSON.stringify(projectPkg, null, 2) + '\n');
|
|
299
|
+
log('package.json: --webpack agregado a scripts dev/build (Next.js 16+ requiere webpack con @stencil/ssr).', 'ok');
|
|
300
|
+
}
|
|
261
301
|
}
|
|
262
302
|
}
|
|
263
303
|
}
|