@builder.io/mitosis 0.13.0 → 0.13.2
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.
|
@@ -229,7 +229,11 @@ Please add a initial value for every state property even if it's \`undefined\`.`
|
|
|
229
229
|
});
|
|
230
230
|
// Hooks
|
|
231
231
|
if (!emptyOnMount) {
|
|
232
|
-
|
|
232
|
+
// `onMount` runs only in the browser, after view initialization. Guard it
|
|
233
|
+
// so it does not execute during SSR.
|
|
234
|
+
(0, hooks_1.addCodeNgAfterViewInit)(json, `if (typeof window !== 'undefined') {
|
|
235
|
+
${json.hooks.onMount.map((onMount) => onMount.code).join('\n')}
|
|
236
|
+
}`);
|
|
233
237
|
}
|
|
234
238
|
// Angular interfaces
|
|
235
239
|
const angularInterfaces = [];
|
|
@@ -304,23 +308,21 @@ Please add a initial value for every state property even if it's \`undefined\`.`
|
|
|
304
308
|
: `if (typeof window !== 'undefined') {
|
|
305
309
|
${(_3 = json.hooks.onUpdate) === null || _3 === void 0 ? void 0 : _3.map(({ code, depsArray }) =>
|
|
306
310
|
/**
|
|
307
|
-
*
|
|
308
|
-
*
|
|
311
|
+
* `allowSignalWrites` is required for Angular < 19 to permit signal writes
|
|
312
|
+
* inside effects. It was deprecated in Angular 19 (writes are always allowed)
|
|
313
|
+
* and logging it there produces console noise, so we gate it on the runtime
|
|
314
|
+
* Angular version to keep backwards compatibility with v17/v18.
|
|
309
315
|
*/
|
|
310
316
|
`effect(() => {
|
|
311
317
|
${(depsArray === null || depsArray === void 0 ? void 0 : depsArray.length)
|
|
312
318
|
? `
|
|
313
319
|
// --- Mitosis: Workaround to make sure the effect() is triggered ---
|
|
314
320
|
${depsArray.join('\n')}
|
|
315
|
-
// ---
|
|
321
|
+
// ---
|
|
316
322
|
`
|
|
317
323
|
: ''}
|
|
318
324
|
${code}
|
|
319
|
-
},
|
|
320
|
-
{
|
|
321
|
-
allowSignalWrites: true, // Enable writing to signals inside effects
|
|
322
|
-
}
|
|
323
|
-
);`).join('\n')}
|
|
325
|
+
}, Number(VERSION.major) < 19 ? ({ allowSignalWrites: true } as any) : undefined);`).join('\n')}
|
|
324
326
|
}
|
|
325
327
|
`}}
|
|
326
328
|
|
|
@@ -346,9 +348,7 @@ Please add a initial value for every state property even if it's \`undefined\`.`
|
|
|
346
348
|
.filter(([_, value]) => !(0, is_hook_empty_1.isHookEmpty)(value))
|
|
347
349
|
.map(([key, value]) => {
|
|
348
350
|
return `${key}() {
|
|
349
|
-
if (typeof window !== 'undefined') {
|
|
350
351
|
${value.code}
|
|
351
|
-
}
|
|
352
352
|
}`;
|
|
353
353
|
})
|
|
354
354
|
.join('\n')
|