@absolutejs/absolute 0.20.0-beta.166 → 0.20.0-beta.167

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.
@@ -20,7 +20,7 @@ import {
20
20
  } from "./index-ys2rzqhg.js";
21
21
  import {
22
22
  resolveDevBunExecutable2
23
- } from "./index-1ksy2h3r.js";
23
+ } from "./index-psvsmg0x.js";
24
24
  import"./index-43a1vvb7.js";
25
25
  import {
26
26
  updateLockMetadata,
@@ -15,7 +15,7 @@ var PATCHED_BUN_RELEASE = {
15
15
  bunVersion: "1.4.4",
16
16
  issue: "https://github.com/oven-sh/bun/issues/32919",
17
17
  repo: "absolutejs/patched-bun",
18
- version: "1.4.4+absolute.1"
18
+ version: "1.4.4+absolute.2"
19
19
  };
20
20
  var HOURS_PER_DAY = 24;
21
21
  var MS_PER_HOUR = 3600000;
package/dist/cli/index.js CHANGED
@@ -54,7 +54,7 @@ if (command === "dev") {
54
54
  }
55
55
  const positionalArgs = stripNamedArgs("--config", "--android-device", "--ios-device").filter((arg) => arg !== "--no-mobile" && arg !== "--eager");
56
56
  const serverEntry = positionalArgs[0] ?? DEFAULT_SERVER_ENTRY;
57
- const { dev } = await import("./dev-sxx8zyr6.js");
57
+ const { dev } = await import("./dev-ny2vah78.js");
58
58
  await dev(serverEntry, configPath, {
59
59
  androidDevice,
60
60
  eager: args.includes("--eager"),
@@ -62,7 +62,7 @@ if (command === "dev") {
62
62
  mobile: !args.includes("--no-mobile")
63
63
  });
64
64
  } else if (command === "bun-patch") {
65
- const { bunPatch } = await import("./patchedBun-r3ykvvwz.js");
65
+ const { bunPatch } = await import("./patchedBun-g1d7528q.js");
66
66
  bunPatch(args);
67
67
  } else if (command === "start") {
68
68
  sendTelemetryEvent("cli:command", { command });
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  resolveDevBunExecutable2,
4
4
  bunPatch2
5
- } from "./index-1ksy2h3r.js";
5
+ } from "./index-psvsmg0x.js";
6
6
  export {
7
7
  bunPatch2 as bunPatch,
8
8
  resolveDevBunExecutable2 as resolveDevBunExecutable
@@ -326,14 +326,76 @@ const updateStylesheetLink = (
326
326
  return replaceStylesheetLink(link, replacementHref);
327
327
  };
328
328
 
329
+ /** Static asset edits must invalidate mounted image and favicon URLs too. */
330
+ export const refreshStaticAsset = (assetUrl: string) => {
331
+ const changed = new URL(assetUrl, window.location.href);
332
+ if (changed.origin !== window.location.origin) return;
333
+ for (const element of document.querySelectorAll<
334
+ HTMLImageElement | HTMLLinkElement
335
+ >('img[src], link[rel~="icon"][href]')) {
336
+ const attribute = element instanceof HTMLImageElement ? 'src' : 'href';
337
+ const current = new URL(
338
+ element.getAttribute(attribute) ?? '',
339
+ window.location.href
340
+ );
341
+ if (
342
+ current.origin !== changed.origin ||
343
+ current.pathname !== changed.pathname
344
+ )
345
+ continue;
346
+ current.searchParams.set(
347
+ 'hmr',
348
+ `${Date.now()}-${++styleReloadSequence}`
349
+ );
350
+ element.setAttribute(attribute, current.href);
351
+ }
352
+ };
353
+
354
+ /** Refresh CSS imported by JS as well as linked bundles. Update the original
355
+ * style nodes in place so overrides keep their cascade order. */
356
+ export const reloadImportedStylesheets = async (
357
+ load: (url: string) => Promise<unknown> = (url) => import(url)
358
+ ) => {
359
+ const styles = Array.from(
360
+ document.querySelectorAll<HTMLStyleElement>('style[data-hmr-src]')
361
+ );
362
+ const results = await Promise.all(
363
+ styles.map(async (style) => {
364
+ try {
365
+ const source = style.dataset.hmrSrc;
366
+ if (!source) return false;
367
+ const url = new URL(source, window.location.href);
368
+ if (
369
+ url.origin !== window.location.origin ||
370
+ !url.pathname.startsWith('/@src/')
371
+ )
372
+ return false;
373
+ url.searchParams.set(
374
+ 'hmr',
375
+ `${Date.now()}-${++styleReloadSequence}`
376
+ );
377
+ await load(url.href);
378
+
379
+ return true;
380
+ } catch {
381
+ return false;
382
+ }
383
+ })
384
+ );
385
+
386
+ return results.every(Boolean);
387
+ };
388
+ let styleReloadSequence = 0;
389
+
329
390
  export const reloadCSSStylesheets = (manifest: Record<string, string>) => {
330
391
  const stylesheets = Array.from(
331
392
  document.querySelectorAll('link[rel="stylesheet"]')
332
393
  );
333
394
 
334
- return Promise.all(
335
- stylesheets.map((link) => updateStylesheetLink(link, manifest))
336
- ).then((results) => results.every(Boolean));
395
+ return Promise.all([
396
+ ...stylesheets.map((link) => updateStylesheetLink(link, manifest)),
397
+ reloadImportedStylesheets()
398
+ ]).then((results) => results.every(Boolean));
337
399
  };
338
400
 
339
401
  export const swapCSSStylesheet = (
@@ -32,7 +32,7 @@ import { handleHTMLUpdate, handleScriptUpdate } from './handlers/html';
32
32
  import { handleHTMXUpdate } from './handlers/htmx';
33
33
  import { handleSvelteUpdate } from './handlers/svelte';
34
34
  import { handleVueUpdate } from './handlers/vue';
35
- import { reloadCSSStylesheets } from './cssUtils';
35
+ import { reloadCSSStylesheets, refreshStaticAsset } from './cssUtils';
36
36
  import {
37
37
  handleFullReload,
38
38
  handleManifest,
@@ -201,6 +201,7 @@ const hmrUpdateTypes = new Set([
201
201
 
202
202
  type HMRMessage = {
203
203
  data: {
204
+ assetUrl?: string;
204
205
  affectedFrameworks?: string[];
205
206
  column?: number;
206
207
  error?: string;
@@ -230,6 +231,7 @@ type HMRMessage = {
230
231
  };
231
232
 
232
233
  const handleStylesheetUpdate = (message: HMRMessage) => {
234
+ if (message.data.assetUrl) refreshStaticAsset(message.data.assetUrl);
233
235
  const clientStart = performance.now();
234
236
  void reloadCSSStylesheets(message.data.manifest ?? {}).then((applied) =>
235
237
  sendAbsoluteHmrTiming({
package/dist/index.js CHANGED
@@ -26799,7 +26799,7 @@ ${offenders.map((o) => ` \u2022 ${o}`).join(`
26799
26799
  ...allAngularEntries.map((source) => toDevPageEntry("angular", source)),
26800
26800
  ...allEmberEntries.map((source) => toDevPageEntry("ember", source))
26801
26801
  ] : [];
26802
- const globalCssEntries = isIncremental ? filterToIncrementalEntries(allGlobalCssEntries, (entry) => entry) : allGlobalCssEntries;
26802
+ const globalCssEntries = !isIncremental || incrementalFiles?.some(isStylePath) ? allGlobalCssEntries : filterToIncrementalEntries(allGlobalCssEntries, (entry) => entry);
26803
26803
  const hmrClientBundlePromise = hmr && (htmlDir || htmxDir) ? buildHMRClient() : undefined;
26804
26804
  const allFrameworkDirs = [
26805
26805
  reactDir,
@@ -27084,7 +27084,7 @@ ${offenders.map((o) => ` \u2022 ${o}`).join(`
27084
27084
  generatedRoot: join53(buildPath, "_island_entries")
27085
27085
  };
27086
27086
  const islandClientEntryPoints = islandEntryResult.entries.map((entry) => entry.entryPath);
27087
- if (!deferPageEntries && serverEntryPoints.length === 0 && reactClientEntryPoints.length === 0 && nonReactClientEntryPoints.length === 0 && urlReferencedFiles.length === 0 && islandClientEntryPoints.length === 0 && htmxDir === undefined && htmlDir === undefined) {
27087
+ if (!deferPageEntries && serverEntryPoints.length === 0 && reactClientEntryPoints.length === 0 && nonReactClientEntryPoints.length === 0 && urlReferencedFiles.length === 0 && islandClientEntryPoints.length === 0 && globalCssEntries.length === 0 && htmxDir === undefined && htmlDir === undefined) {
27088
27088
  logWarn("No entry points found, manifest will be empty");
27089
27089
  sendTelemetryEvent("build:empty", {
27090
27090
  configuredDirs: {
@@ -30498,12 +30498,13 @@ ${code}`;
30498
30498
  const raw = readFileSync41(filePath, "utf-8");
30499
30499
  const escaped = raw.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$/g, "\\$");
30500
30500
  return [
30501
- `const style = document.createElement('style');`,
30501
+ `const id = ${JSON.stringify(filePath)};`,
30502
+ `const existing = Array.from(document.querySelectorAll('style[data-hmr-id]')).find(el => el.dataset.hmrId === id);`,
30503
+ `const style = existing || document.createElement('style');`,
30502
30504
  `style.textContent = \`${escaped}\`;`,
30503
- `style.dataset.hmrId = ${JSON.stringify(filePath)};`,
30504
- `const existing = document.querySelector(\`style[data-hmr-id="${filePath}"]\`);`,
30505
- `if (existing) existing.remove();`,
30506
- `document.head.appendChild(style);`
30505
+ `style.dataset.hmrId = id;`,
30506
+ `style.dataset.hmrSrc = import.meta.url;`,
30507
+ `if (!existing) document.head.appendChild(style);`
30507
30508
  ].join(`
30508
30509
  `);
30509
30510
  }, generateSvelteHmrBootstrap = (moduleUrl, vendorPaths, timestamp) => {
@@ -32663,6 +32664,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, clearDevSs
32663
32664
  logHmrUpdate(relative26(process.cwd(), filePath));
32664
32665
  broadcastToClients(state, {
32665
32666
  data: {
32667
+ assetUrl: webPath,
32666
32668
  framework: urlPrefix || "public",
32667
32669
  manifest: state.manifest,
32668
32670
  serverDuration: Math.round(performance.now() - startedAt),
@@ -44204,5 +44206,5 @@ export {
44204
44206
  wrapPageHandlerWithStreamingSlots
44205
44207
  };
44206
44208
 
44207
- //# debugId=0EC9A0E0BF56988964756E2164756E21
44209
+ //# debugId=66B00122B036B41064756E2164756E21
44208
44210
  //# sourceMappingURL=index.js.map