@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.cjs CHANGED
@@ -11407,7 +11407,14 @@ var FilesystemRouteLoader = class {
11407
11407
  if (hasFilesChanged(this.appDir, this.projectRoot, this.cache.fileStats) || this.cache.apiRoutes.length === 0) {
11408
11408
  const files = getRelevantFiles(this.appDir, this.projectRoot);
11409
11409
  const fileStats = buildFileStats(files);
11410
- this.cache.apiRoutes = await loadApiRoutes(this.appDir);
11410
+ const apiRoutes = await loadApiRoutes(this.appDir);
11411
+ if (!this.cache) {
11412
+ await this.loadRoutes();
11413
+ if (!this.cache) {
11414
+ throw new Error("Failed to initialize route cache");
11415
+ }
11416
+ }
11417
+ this.cache.apiRoutes = apiRoutes;
11411
11418
  this.cache.fileStats = fileStats;
11412
11419
  this.cache.timestamp = Date.now();
11413
11420
  }
@@ -11424,7 +11431,14 @@ var FilesystemRouteLoader = class {
11424
11431
  if (hasFilesChanged(this.appDir, this.projectRoot, this.cache.fileStats) || this.cache.wssRoutes.length === 0) {
11425
11432
  const files = getRelevantFiles(this.appDir, this.projectRoot);
11426
11433
  const fileStats = buildFileStats(files);
11427
- this.cache.wssRoutes = await loadWssRoutes(this.appDir);
11434
+ const wssRoutes = await loadWssRoutes(this.appDir);
11435
+ if (!this.cache) {
11436
+ await this.loadRoutes();
11437
+ if (!this.cache) {
11438
+ throw new Error("Failed to initialize route cache");
11439
+ }
11440
+ }
11441
+ this.cache.wssRoutes = wssRoutes;
11428
11442
  this.cache.fileStats = fileStats;
11429
11443
  this.cache.timestamp = Date.now();
11430
11444
  }
@@ -11441,7 +11455,14 @@ var FilesystemRouteLoader = class {
11441
11455
  if (hasFilesChanged(this.appDir, this.projectRoot, this.cache.fileStats) || this.cache.notFoundRoute === void 0) {
11442
11456
  const files = getRelevantFiles(this.appDir, this.projectRoot);
11443
11457
  const fileStats = buildFileStats(files);
11444
- this.cache.notFoundRoute = await loadNotFoundRouteFromFilesystem(this.appDir, this.projectRoot);
11458
+ const notFoundRoute = await loadNotFoundRouteFromFilesystem(this.appDir, this.projectRoot);
11459
+ if (!this.cache) {
11460
+ await this.loadRoutes();
11461
+ if (!this.cache) {
11462
+ throw new Error("Failed to initialize route cache");
11463
+ }
11464
+ }
11465
+ this.cache.notFoundRoute = notFoundRoute;
11445
11466
  this.cache.fileStats = fileStats;
11446
11467
  this.cache.timestamp = Date.now();
11447
11468
  }
@@ -11458,7 +11479,14 @@ var FilesystemRouteLoader = class {
11458
11479
  if (hasFilesChanged(this.appDir, this.projectRoot, this.cache.fileStats) || this.cache.errorRoute === void 0) {
11459
11480
  const files = getRelevantFiles(this.appDir, this.projectRoot);
11460
11481
  const fileStats = buildFileStats(files);
11461
- this.cache.errorRoute = await loadErrorRouteFromFilesystem(this.appDir, this.projectRoot);
11482
+ const errorRoute = await loadErrorRouteFromFilesystem(this.appDir, this.projectRoot);
11483
+ if (!this.cache) {
11484
+ await this.loadRoutes();
11485
+ if (!this.cache) {
11486
+ throw new Error("Failed to initialize route cache");
11487
+ }
11488
+ }
11489
+ this.cache.errorRoute = errorRoute;
11462
11490
  this.cache.fileStats = fileStats;
11463
11491
  this.cache.timestamp = Date.now();
11464
11492
  }
@@ -15666,7 +15694,7 @@ function createDocumentTree(options) {
15666
15694
  }),
15667
15695
  ...extraMetaTags,
15668
15696
  ...linkTags,
15669
- ...entrypointFiles.length > 0 ? entrypointFiles.slice(0, -1).map(
15697
+ ...entrypointFiles.length > 0 ? entrypointFiles.map(
15670
15698
  (file) => import_react.default.createElement("link", {
15671
15699
  key: `preload-${file}`,
15672
15700
  rel: "preload",
@@ -15687,6 +15715,13 @@ function createDocumentTree(options) {
15687
15715
  href: faviconPath,
15688
15716
  type: faviconType || (faviconPath.endsWith(".ico") ? "image/x-icon" : "image/png")
15689
15717
  }),
15718
+ // Preload CSS para evitar bloqueo de renderizado
15719
+ import_react.default.createElement("link", {
15720
+ key: "preload-css",
15721
+ rel: "preload",
15722
+ href: clientCssPath,
15723
+ as: "style"
15724
+ }),
15690
15725
  import_react.default.createElement("link", {
15691
15726
  rel: "stylesheet",
15692
15727
  href: clientCssPath
@@ -19195,132 +19230,134 @@ function getOrCreateLink(rel, href) {
19195
19230
  }
19196
19231
  function applyMetadata(md) {
19197
19232
  if (!md) return;
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;
19233
+ requestAnimationFrame(() => {
19234
+ if (md.title) {
19235
+ document.title = md.title;
19236
+ }
19237
+ if (md.description) {
19238
+ const meta = getOrCreateMeta('meta[name="description"]', { name: "description" });
19239
+ meta.content = md.description;
19240
+ }
19241
+ if (md.robots) {
19242
+ const meta = getOrCreateMeta('meta[name="robots"]', { name: "robots" });
19243
+ meta.content = md.robots;
19244
+ }
19245
+ if (md.themeColor) {
19246
+ const meta = getOrCreateMeta('meta[name="theme-color"]', { name: "theme-color" });
19247
+ meta.content = md.themeColor;
19248
+ }
19249
+ if (md.viewport) {
19250
+ const meta = getOrCreateMeta('meta[name="viewport"]', { name: "viewport" });
19251
+ meta.content = md.viewport;
19252
+ }
19253
+ if (md.canonical) {
19254
+ getOrCreateLink("canonical", md.canonical);
19255
+ }
19256
+ if (md.openGraph) {
19257
+ const og = md.openGraph;
19258
+ if (og.title) {
19259
+ const meta = getOrCreateMeta('meta[property="og:title"]', { property: "og:title" });
19260
+ meta.content = og.title;
19261
+ }
19262
+ if (og.description) {
19263
+ const meta = getOrCreateMeta('meta[property="og:description"]', { property: "og:description" });
19264
+ meta.content = og.description;
19265
+ }
19266
+ if (og.type) {
19267
+ const meta = getOrCreateMeta('meta[property="og:type"]', { property: "og:type" });
19268
+ meta.content = og.type;
19269
+ }
19270
+ if (og.url) {
19271
+ const meta = getOrCreateMeta('meta[property="og:url"]', { property: "og:url" });
19272
+ meta.content = og.url;
19273
+ }
19274
+ if (og.image) {
19275
+ if (typeof og.image === "string") {
19276
+ const meta = getOrCreateMeta('meta[property="og:image"]', { property: "og:image" });
19277
+ meta.content = og.image;
19278
+ } else {
19279
+ const meta = getOrCreateMeta('meta[property="og:image"]', { property: "og:image" });
19280
+ meta.content = og.image.url;
19281
+ if (og.image.width) {
19282
+ const metaWidth = getOrCreateMeta('meta[property="og:image:width"]', { property: "og:image:width" });
19283
+ metaWidth.content = String(og.image.width);
19284
+ }
19285
+ if (og.image.height) {
19286
+ const metaHeight = getOrCreateMeta('meta[property="og:image:height"]', { property: "og:image:height" });
19287
+ metaHeight.content = String(og.image.height);
19288
+ }
19289
+ if (og.image.alt) {
19290
+ const metaAlt = getOrCreateMeta('meta[property="og:image:alt"]', { property: "og:image:alt" });
19291
+ metaAlt.content = og.image.alt;
19292
+ }
19256
19293
  }
19257
19294
  }
19295
+ if (og.siteName) {
19296
+ const meta = getOrCreateMeta('meta[property="og:site_name"]', { property: "og:site_name" });
19297
+ meta.content = og.siteName;
19298
+ }
19299
+ if (og.locale) {
19300
+ const meta = getOrCreateMeta('meta[property="og:locale"]', { property: "og:locale" });
19301
+ meta.content = og.locale;
19302
+ }
19258
19303
  }
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
- }
19267
- }
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;
19304
+ if (md.twitter) {
19305
+ const twitter = md.twitter;
19306
+ if (twitter.card) {
19307
+ const meta = getOrCreateMeta('meta[name="twitter:card"]', { name: "twitter:card" });
19308
+ meta.content = twitter.card;
19309
+ }
19310
+ if (twitter.title) {
19311
+ const meta = getOrCreateMeta('meta[name="twitter:title"]', { name: "twitter:title" });
19312
+ meta.content = twitter.title;
19313
+ }
19314
+ if (twitter.description) {
19315
+ const meta = getOrCreateMeta('meta[name="twitter:description"]', { name: "twitter:description" });
19316
+ meta.content = twitter.description;
19317
+ }
19318
+ if (twitter.image) {
19319
+ const meta = getOrCreateMeta('meta[name="twitter:image"]', { name: "twitter:image" });
19320
+ meta.content = twitter.image;
19321
+ }
19322
+ if (twitter.imageAlt) {
19323
+ const meta = getOrCreateMeta('meta[name="twitter:image:alt"]', { name: "twitter:image:alt" });
19324
+ meta.content = twitter.imageAlt;
19325
+ }
19326
+ if (twitter.site) {
19327
+ const meta = getOrCreateMeta('meta[name="twitter:site"]', { name: "twitter:site" });
19328
+ meta.content = twitter.site;
19329
+ }
19330
+ if (twitter.creator) {
19331
+ const meta = getOrCreateMeta('meta[name="twitter:creator"]', { name: "twitter:creator" });
19332
+ meta.content = twitter.creator;
19333
+ }
19285
19334
  }
19286
- if (twitter.imageAlt) {
19287
- const meta = getOrCreateMeta('meta[name="twitter:image:alt"]', { name: "twitter:image:alt" });
19288
- meta.content = twitter.imageAlt;
19335
+ if (md.metaTags && Array.isArray(md.metaTags)) {
19336
+ md.metaTags.forEach((tag) => {
19337
+ let selector = "";
19338
+ if (tag.name) {
19339
+ selector = `meta[name="${tag.name}"]`;
19340
+ } else if (tag.property) {
19341
+ selector = `meta[property="${tag.property}"]`;
19342
+ } else if (tag.httpEquiv) {
19343
+ selector = `meta[http-equiv="${tag.httpEquiv}"]`;
19344
+ }
19345
+ if (selector) {
19346
+ const meta = getOrCreateMeta(selector, {
19347
+ name: tag.name,
19348
+ property: tag.property,
19349
+ httpEquiv: tag.httpEquiv
19350
+ });
19351
+ meta.content = tag.content;
19352
+ }
19353
+ });
19289
19354
  }
19290
- if (twitter.site) {
19291
- const meta = getOrCreateMeta('meta[name="twitter:site"]', { name: "twitter:site" });
19292
- meta.content = twitter.site;
19355
+ if (md.links && Array.isArray(md.links)) {
19356
+ md.links.forEach((link) => {
19357
+ getOrCreateLink(link.rel, link.href);
19358
+ });
19293
19359
  }
19294
- if (twitter.creator) {
19295
- const meta = getOrCreateMeta('meta[name="twitter:creator"]', { name: "twitter:creator" });
19296
- meta.content = twitter.creator;
19297
- }
19298
- }
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
- });
19318
- }
19319
- if (md.links && Array.isArray(md.links)) {
19320
- md.links.forEach((link) => {
19321
- getOrCreateLink(link.rel, link.href);
19322
- });
19323
- }
19360
+ });
19324
19361
  }
19325
19362
 
19326
19363
  // modules/runtime/client/AppShell.tsx