@lolyjs/core 0.3.0-alpha.3 → 0.3.0-alpha.5

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/index.mjs CHANGED
@@ -11371,7 +11371,14 @@ var FilesystemRouteLoader = class {
11371
11371
  if (hasFilesChanged(this.appDir, this.projectRoot, this.cache.fileStats) || this.cache.apiRoutes.length === 0) {
11372
11372
  const files = getRelevantFiles(this.appDir, this.projectRoot);
11373
11373
  const fileStats = buildFileStats(files);
11374
- this.cache.apiRoutes = await loadApiRoutes(this.appDir);
11374
+ const apiRoutes = await loadApiRoutes(this.appDir);
11375
+ if (!this.cache) {
11376
+ await this.loadRoutes();
11377
+ if (!this.cache) {
11378
+ throw new Error("Failed to initialize route cache");
11379
+ }
11380
+ }
11381
+ this.cache.apiRoutes = apiRoutes;
11375
11382
  this.cache.fileStats = fileStats;
11376
11383
  this.cache.timestamp = Date.now();
11377
11384
  }
@@ -11388,7 +11395,14 @@ var FilesystemRouteLoader = class {
11388
11395
  if (hasFilesChanged(this.appDir, this.projectRoot, this.cache.fileStats) || this.cache.wssRoutes.length === 0) {
11389
11396
  const files = getRelevantFiles(this.appDir, this.projectRoot);
11390
11397
  const fileStats = buildFileStats(files);
11391
- this.cache.wssRoutes = await loadWssRoutes(this.appDir);
11398
+ const wssRoutes = await loadWssRoutes(this.appDir);
11399
+ if (!this.cache) {
11400
+ await this.loadRoutes();
11401
+ if (!this.cache) {
11402
+ throw new Error("Failed to initialize route cache");
11403
+ }
11404
+ }
11405
+ this.cache.wssRoutes = wssRoutes;
11392
11406
  this.cache.fileStats = fileStats;
11393
11407
  this.cache.timestamp = Date.now();
11394
11408
  }
@@ -11405,7 +11419,14 @@ var FilesystemRouteLoader = class {
11405
11419
  if (hasFilesChanged(this.appDir, this.projectRoot, this.cache.fileStats) || this.cache.notFoundRoute === void 0) {
11406
11420
  const files = getRelevantFiles(this.appDir, this.projectRoot);
11407
11421
  const fileStats = buildFileStats(files);
11408
- this.cache.notFoundRoute = await loadNotFoundRouteFromFilesystem(this.appDir, this.projectRoot);
11422
+ const notFoundRoute = await loadNotFoundRouteFromFilesystem(this.appDir, this.projectRoot);
11423
+ if (!this.cache) {
11424
+ await this.loadRoutes();
11425
+ if (!this.cache) {
11426
+ throw new Error("Failed to initialize route cache");
11427
+ }
11428
+ }
11429
+ this.cache.notFoundRoute = notFoundRoute;
11409
11430
  this.cache.fileStats = fileStats;
11410
11431
  this.cache.timestamp = Date.now();
11411
11432
  }
@@ -11422,7 +11443,14 @@ var FilesystemRouteLoader = class {
11422
11443
  if (hasFilesChanged(this.appDir, this.projectRoot, this.cache.fileStats) || this.cache.errorRoute === void 0) {
11423
11444
  const files = getRelevantFiles(this.appDir, this.projectRoot);
11424
11445
  const fileStats = buildFileStats(files);
11425
- this.cache.errorRoute = await loadErrorRouteFromFilesystem(this.appDir, this.projectRoot);
11446
+ const errorRoute = await loadErrorRouteFromFilesystem(this.appDir, this.projectRoot);
11447
+ if (!this.cache) {
11448
+ await this.loadRoutes();
11449
+ if (!this.cache) {
11450
+ throw new Error("Failed to initialize route cache");
11451
+ }
11452
+ }
11453
+ this.cache.errorRoute = errorRoute;
11426
11454
  this.cache.fileStats = fileStats;
11427
11455
  this.cache.timestamp = Date.now();
11428
11456
  }
@@ -15630,7 +15658,7 @@ function createDocumentTree(options) {
15630
15658
  }),
15631
15659
  ...extraMetaTags,
15632
15660
  ...linkTags,
15633
- ...entrypointFiles.length > 0 ? entrypointFiles.slice(0, -1).map(
15661
+ ...entrypointFiles.length > 0 ? entrypointFiles.map(
15634
15662
  (file) => React.createElement("link", {
15635
15663
  key: `preload-${file}`,
15636
15664
  rel: "preload",
@@ -15651,6 +15679,13 @@ function createDocumentTree(options) {
15651
15679
  href: faviconPath,
15652
15680
  type: faviconType || (faviconPath.endsWith(".ico") ? "image/x-icon" : "image/png")
15653
15681
  }),
15682
+ // Preload CSS para evitar bloqueo de renderizado
15683
+ React.createElement("link", {
15684
+ key: "preload-css",
15685
+ rel: "preload",
15686
+ href: clientCssPath,
15687
+ as: "style"
15688
+ }),
15654
15689
  React.createElement("link", {
15655
15690
  rel: "stylesheet",
15656
15691
  href: clientCssPath
@@ -19159,132 +19194,134 @@ function getOrCreateLink(rel, href) {
19159
19194
  }
19160
19195
  function applyMetadata(md) {
19161
19196
  if (!md) return;
19162
- if (md.title) {
19163
- document.title = md.title;
19164
- }
19165
- if (md.description) {
19166
- const meta = getOrCreateMeta('meta[name="description"]', { name: "description" });
19167
- meta.content = md.description;
19168
- }
19169
- if (md.robots) {
19170
- const meta = getOrCreateMeta('meta[name="robots"]', { name: "robots" });
19171
- meta.content = md.robots;
19172
- }
19173
- if (md.themeColor) {
19174
- const meta = getOrCreateMeta('meta[name="theme-color"]', { name: "theme-color" });
19175
- meta.content = md.themeColor;
19176
- }
19177
- if (md.viewport) {
19178
- const meta = getOrCreateMeta('meta[name="viewport"]', { name: "viewport" });
19179
- meta.content = md.viewport;
19180
- }
19181
- if (md.canonical) {
19182
- getOrCreateLink("canonical", md.canonical);
19183
- }
19184
- if (md.openGraph) {
19185
- const og = md.openGraph;
19186
- if (og.title) {
19187
- const meta = getOrCreateMeta('meta[property="og:title"]', { property: "og:title" });
19188
- meta.content = og.title;
19189
- }
19190
- if (og.description) {
19191
- const meta = getOrCreateMeta('meta[property="og:description"]', { property: "og:description" });
19192
- meta.content = og.description;
19193
- }
19194
- if (og.type) {
19195
- const meta = getOrCreateMeta('meta[property="og:type"]', { property: "og:type" });
19196
- meta.content = og.type;
19197
- }
19198
- if (og.url) {
19199
- const meta = getOrCreateMeta('meta[property="og:url"]', { property: "og:url" });
19200
- meta.content = og.url;
19201
- }
19202
- if (og.image) {
19203
- if (typeof og.image === "string") {
19204
- const meta = getOrCreateMeta('meta[property="og:image"]', { property: "og:image" });
19205
- meta.content = og.image;
19206
- } else {
19207
- const meta = getOrCreateMeta('meta[property="og:image"]', { property: "og:image" });
19208
- meta.content = og.image.url;
19209
- if (og.image.width) {
19210
- const metaWidth = getOrCreateMeta('meta[property="og:image:width"]', { property: "og:image:width" });
19211
- metaWidth.content = String(og.image.width);
19212
- }
19213
- if (og.image.height) {
19214
- const metaHeight = getOrCreateMeta('meta[property="og:image:height"]', { property: "og:image:height" });
19215
- metaHeight.content = String(og.image.height);
19216
- }
19217
- if (og.image.alt) {
19218
- const metaAlt = getOrCreateMeta('meta[property="og:image:alt"]', { property: "og:image:alt" });
19219
- metaAlt.content = og.image.alt;
19197
+ requestAnimationFrame(() => {
19198
+ if (md.title) {
19199
+ document.title = md.title;
19200
+ }
19201
+ if (md.description) {
19202
+ const meta = getOrCreateMeta('meta[name="description"]', { name: "description" });
19203
+ meta.content = md.description;
19204
+ }
19205
+ if (md.robots) {
19206
+ const meta = getOrCreateMeta('meta[name="robots"]', { name: "robots" });
19207
+ meta.content = md.robots;
19208
+ }
19209
+ if (md.themeColor) {
19210
+ const meta = getOrCreateMeta('meta[name="theme-color"]', { name: "theme-color" });
19211
+ meta.content = md.themeColor;
19212
+ }
19213
+ if (md.viewport) {
19214
+ const meta = getOrCreateMeta('meta[name="viewport"]', { name: "viewport" });
19215
+ meta.content = md.viewport;
19216
+ }
19217
+ if (md.canonical) {
19218
+ getOrCreateLink("canonical", md.canonical);
19219
+ }
19220
+ if (md.openGraph) {
19221
+ const og = md.openGraph;
19222
+ if (og.title) {
19223
+ const meta = getOrCreateMeta('meta[property="og:title"]', { property: "og:title" });
19224
+ meta.content = og.title;
19225
+ }
19226
+ if (og.description) {
19227
+ const meta = getOrCreateMeta('meta[property="og:description"]', { property: "og:description" });
19228
+ meta.content = og.description;
19229
+ }
19230
+ if (og.type) {
19231
+ const meta = getOrCreateMeta('meta[property="og:type"]', { property: "og:type" });
19232
+ meta.content = og.type;
19233
+ }
19234
+ if (og.url) {
19235
+ const meta = getOrCreateMeta('meta[property="og:url"]', { property: "og:url" });
19236
+ meta.content = og.url;
19237
+ }
19238
+ if (og.image) {
19239
+ if (typeof og.image === "string") {
19240
+ const meta = getOrCreateMeta('meta[property="og:image"]', { property: "og:image" });
19241
+ meta.content = og.image;
19242
+ } else {
19243
+ const meta = getOrCreateMeta('meta[property="og:image"]', { property: "og:image" });
19244
+ meta.content = og.image.url;
19245
+ if (og.image.width) {
19246
+ const metaWidth = getOrCreateMeta('meta[property="og:image:width"]', { property: "og:image:width" });
19247
+ metaWidth.content = String(og.image.width);
19248
+ }
19249
+ if (og.image.height) {
19250
+ const metaHeight = getOrCreateMeta('meta[property="og:image:height"]', { property: "og:image:height" });
19251
+ metaHeight.content = String(og.image.height);
19252
+ }
19253
+ if (og.image.alt) {
19254
+ const metaAlt = getOrCreateMeta('meta[property="og:image:alt"]', { property: "og:image:alt" });
19255
+ metaAlt.content = og.image.alt;
19256
+ }
19220
19257
  }
19221
19258
  }
19259
+ if (og.siteName) {
19260
+ const meta = getOrCreateMeta('meta[property="og:site_name"]', { property: "og:site_name" });
19261
+ meta.content = og.siteName;
19262
+ }
19263
+ if (og.locale) {
19264
+ const meta = getOrCreateMeta('meta[property="og:locale"]', { property: "og:locale" });
19265
+ meta.content = og.locale;
19266
+ }
19222
19267
  }
19223
- if (og.siteName) {
19224
- const meta = getOrCreateMeta('meta[property="og:site_name"]', { property: "og:site_name" });
19225
- meta.content = og.siteName;
19226
- }
19227
- if (og.locale) {
19228
- const meta = getOrCreateMeta('meta[property="og:locale"]', { property: "og:locale" });
19229
- meta.content = og.locale;
19230
- }
19231
- }
19232
- if (md.twitter) {
19233
- const twitter = md.twitter;
19234
- if (twitter.card) {
19235
- const meta = getOrCreateMeta('meta[name="twitter:card"]', { name: "twitter:card" });
19236
- meta.content = twitter.card;
19237
- }
19238
- if (twitter.title) {
19239
- const meta = getOrCreateMeta('meta[name="twitter:title"]', { name: "twitter:title" });
19240
- meta.content = twitter.title;
19241
- }
19242
- if (twitter.description) {
19243
- const meta = getOrCreateMeta('meta[name="twitter:description"]', { name: "twitter:description" });
19244
- meta.content = twitter.description;
19245
- }
19246
- if (twitter.image) {
19247
- const meta = getOrCreateMeta('meta[name="twitter:image"]', { name: "twitter:image" });
19248
- meta.content = twitter.image;
19268
+ if (md.twitter) {
19269
+ const twitter = md.twitter;
19270
+ if (twitter.card) {
19271
+ const meta = getOrCreateMeta('meta[name="twitter:card"]', { name: "twitter:card" });
19272
+ meta.content = twitter.card;
19273
+ }
19274
+ if (twitter.title) {
19275
+ const meta = getOrCreateMeta('meta[name="twitter:title"]', { name: "twitter:title" });
19276
+ meta.content = twitter.title;
19277
+ }
19278
+ if (twitter.description) {
19279
+ const meta = getOrCreateMeta('meta[name="twitter:description"]', { name: "twitter:description" });
19280
+ meta.content = twitter.description;
19281
+ }
19282
+ if (twitter.image) {
19283
+ const meta = getOrCreateMeta('meta[name="twitter:image"]', { name: "twitter:image" });
19284
+ meta.content = twitter.image;
19285
+ }
19286
+ if (twitter.imageAlt) {
19287
+ const meta = getOrCreateMeta('meta[name="twitter:image:alt"]', { name: "twitter:image:alt" });
19288
+ meta.content = twitter.imageAlt;
19289
+ }
19290
+ if (twitter.site) {
19291
+ const meta = getOrCreateMeta('meta[name="twitter:site"]', { name: "twitter:site" });
19292
+ meta.content = twitter.site;
19293
+ }
19294
+ if (twitter.creator) {
19295
+ const meta = getOrCreateMeta('meta[name="twitter:creator"]', { name: "twitter:creator" });
19296
+ meta.content = twitter.creator;
19297
+ }
19249
19298
  }
19250
- if (twitter.imageAlt) {
19251
- const meta = getOrCreateMeta('meta[name="twitter:image:alt"]', { name: "twitter:image:alt" });
19252
- meta.content = twitter.imageAlt;
19299
+ if (md.metaTags && Array.isArray(md.metaTags)) {
19300
+ md.metaTags.forEach((tag) => {
19301
+ let selector = "";
19302
+ if (tag.name) {
19303
+ selector = `meta[name="${tag.name}"]`;
19304
+ } else if (tag.property) {
19305
+ selector = `meta[property="${tag.property}"]`;
19306
+ } else if (tag.httpEquiv) {
19307
+ selector = `meta[http-equiv="${tag.httpEquiv}"]`;
19308
+ }
19309
+ if (selector) {
19310
+ const meta = getOrCreateMeta(selector, {
19311
+ name: tag.name,
19312
+ property: tag.property,
19313
+ httpEquiv: tag.httpEquiv
19314
+ });
19315
+ meta.content = tag.content;
19316
+ }
19317
+ });
19253
19318
  }
19254
- if (twitter.site) {
19255
- const meta = getOrCreateMeta('meta[name="twitter:site"]', { name: "twitter:site" });
19256
- meta.content = twitter.site;
19319
+ if (md.links && Array.isArray(md.links)) {
19320
+ md.links.forEach((link) => {
19321
+ getOrCreateLink(link.rel, link.href);
19322
+ });
19257
19323
  }
19258
- if (twitter.creator) {
19259
- const meta = getOrCreateMeta('meta[name="twitter:creator"]', { name: "twitter:creator" });
19260
- meta.content = twitter.creator;
19261
- }
19262
- }
19263
- if (md.metaTags && Array.isArray(md.metaTags)) {
19264
- md.metaTags.forEach((tag) => {
19265
- let selector = "";
19266
- if (tag.name) {
19267
- selector = `meta[name="${tag.name}"]`;
19268
- } else if (tag.property) {
19269
- selector = `meta[property="${tag.property}"]`;
19270
- } else if (tag.httpEquiv) {
19271
- selector = `meta[http-equiv="${tag.httpEquiv}"]`;
19272
- }
19273
- if (selector) {
19274
- const meta = getOrCreateMeta(selector, {
19275
- name: tag.name,
19276
- property: tag.property,
19277
- httpEquiv: tag.httpEquiv
19278
- });
19279
- meta.content = tag.content;
19280
- }
19281
- });
19282
- }
19283
- if (md.links && Array.isArray(md.links)) {
19284
- md.links.forEach((link) => {
19285
- getOrCreateLink(link.rel, link.href);
19286
- });
19287
- }
19324
+ });
19288
19325
  }
19289
19326
 
19290
19327
  // modules/runtime/client/AppShell.tsx