@absolutejs/absolute 0.20.0-beta.165 → 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
@@ -17018,7 +17018,7 @@ var resolveBuildDevelopmentMode = (mode, nodeEnv) => mode === "development" || m
17018
17018
  __VUE_OPTIONS_API__: "true",
17019
17019
  __VUE_PROD_DEVTOOLS__: development ? "true" : "false",
17020
17020
  __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: development ? "true" : "false"
17021
- });
17021
+ }), resolveClientDefine = (development, define = {}) => development ? define : { ...define, "process.env.NODE_ENV": '"production"' };
17022
17022
 
17023
17023
  // src/utils/commonAncestor.ts
17024
17024
  var commonAncestor = (paths, fallback) => {
@@ -26413,6 +26413,8 @@ ${offenders.map((o) => ` \u2022 ${o}`).join(`
26413
26413
  const buildStart = performance.now();
26414
26414
  const isDev = resolveBuildDevelopmentMode(mode, env3.NODE_ENV);
26415
26415
  const vueFeatureFlags = resolveVueFeatureFlags(isDev);
26416
+ const clientDefine = resolveClientDefine(isDev);
26417
+ const clientDefineWithVue = resolveClientDefine(isDev, vueDirectory ? vueFeatureFlags : {});
26416
26418
  const projectRoot = cwd();
26417
26419
  const devServerExternalsPlugins = isDev ? [
26418
26420
  createDevServerExternalsPlugin({
@@ -26797,7 +26799,7 @@ ${offenders.map((o) => ` \u2022 ${o}`).join(`
26797
26799
  ...allAngularEntries.map((source) => toDevPageEntry("angular", source)),
26798
26800
  ...allEmberEntries.map((source) => toDevPageEntry("ember", source))
26799
26801
  ] : [];
26800
- const globalCssEntries = isIncremental ? filterToIncrementalEntries(allGlobalCssEntries, (entry) => entry) : allGlobalCssEntries;
26802
+ const globalCssEntries = !isIncremental || incrementalFiles?.some(isStylePath) ? allGlobalCssEntries : filterToIncrementalEntries(allGlobalCssEntries, (entry) => entry);
26801
26803
  const hmrClientBundlePromise = hmr && (htmlDir || htmxDir) ? buildHMRClient() : undefined;
26802
26804
  const allFrameworkDirs = [
26803
26805
  reactDir,
@@ -27082,7 +27084,7 @@ ${offenders.map((o) => ` \u2022 ${o}`).join(`
27082
27084
  generatedRoot: join53(buildPath, "_island_entries")
27083
27085
  };
27084
27086
  const islandClientEntryPoints = islandEntryResult.entries.map((entry) => entry.entryPath);
27085
- 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) {
27086
27088
  logWarn("No entry points found, manifest will be empty");
27087
27089
  sendTelemetryEvent("build:empty", {
27088
27090
  configuredDirs: {
@@ -27201,6 +27203,7 @@ ${offenders.map((o) => ` \u2022 ${o}`).join(`
27201
27203
  const htmlScriptPlugin = hmr ? createHTMLScriptHMRPlugin(htmlDir, htmxDir) : undefined;
27202
27204
  const reactBuildConfig = reactClientEntryPoints.length > 0 ? mergeBunBuildConfig({
27203
27205
  banner: pwaArtifacts?.bootstrapBanner,
27206
+ define: clientDefine,
27204
27207
  entrypoints: reactClientEntryPoints,
27205
27208
  external: [
27206
27209
  ...new Set([
@@ -27279,7 +27282,7 @@ ${offenders.map((o) => ` \u2022 ${o}`).join(`
27279
27282
  nonReactClientEntryPoints.length > 0 ? tracePhase("bun/non-react-client", () => bunBuild7(mergeBunBuildConfig({
27280
27283
  banner: pwaArtifacts?.bootstrapBanner,
27281
27284
  conditions: svelteResolveConditions,
27282
- define: vueDirectory ? vueFeatureFlags : undefined,
27285
+ define: clientDefineWithVue,
27283
27286
  entrypoints: nonReactClientEntryPoints,
27284
27287
  external: Object.keys(nonReactExternalPaths),
27285
27288
  format: "esm",
@@ -27308,6 +27311,7 @@ ${offenders.map((o) => ` \u2022 ${o}`).join(`
27308
27311
  }, resolveBunBuildOverride(bunBuildConfig, "nonReactClient")))) : undefined,
27309
27312
  urlReferencedFiles.length > 0 ? tracePhase("bun/worker-client", () => bunBuild7(mergeBunBuildConfig({
27310
27313
  conditions: svelteResolveConditions,
27314
+ define: clientDefine,
27311
27315
  entrypoints: urlReferencedFiles,
27312
27316
  external: Object.keys(nonReactExternalPaths),
27313
27317
  format: "esm",
@@ -27325,7 +27329,7 @@ ${offenders.map((o) => ` \u2022 ${o}`).join(`
27325
27329
  islandClientEntryPoints.length > 0 ? tracePhase("bun/island-client", () => bunBuild7(mergeBunBuildConfig({
27326
27330
  banner: pwaArtifacts?.bootstrapBanner,
27327
27331
  conditions: svelteResolveConditions,
27328
- define: vueDirectory ? vueFeatureFlags : undefined,
27332
+ define: clientDefineWithVue,
27329
27333
  entrypoints: islandClientEntryPoints,
27330
27334
  external: Object.keys(nonReactExternalPaths),
27331
27335
  format: "esm",
@@ -30494,12 +30498,13 @@ ${code}`;
30494
30498
  const raw = readFileSync41(filePath, "utf-8");
30495
30499
  const escaped = raw.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$/g, "\\$");
30496
30500
  return [
30497
- `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');`,
30498
30504
  `style.textContent = \`${escaped}\`;`,
30499
- `style.dataset.hmrId = ${JSON.stringify(filePath)};`,
30500
- `const existing = document.querySelector(\`style[data-hmr-id="${filePath}"]\`);`,
30501
- `if (existing) existing.remove();`,
30502
- `document.head.appendChild(style);`
30505
+ `style.dataset.hmrId = id;`,
30506
+ `style.dataset.hmrSrc = import.meta.url;`,
30507
+ `if (!existing) document.head.appendChild(style);`
30503
30508
  ].join(`
30504
30509
  `);
30505
30510
  }, generateSvelteHmrBootstrap = (moduleUrl, vendorPaths, timestamp) => {
@@ -32659,6 +32664,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, clearDevSs
32659
32664
  logHmrUpdate(relative26(process.cwd(), filePath));
32660
32665
  broadcastToClients(state, {
32661
32666
  data: {
32667
+ assetUrl: webPath,
32662
32668
  framework: urlPrefix || "public",
32663
32669
  manifest: state.manifest,
32664
32670
  serverDuration: Math.round(performance.now() - startedAt),
@@ -44200,5 +44206,5 @@ export {
44200
44206
  wrapPageHandlerWithStreamingSlots
44201
44207
  };
44202
44208
 
44203
- //# debugId=213BD413FC42A0A164756E2164756E21
44209
+ //# debugId=66B00122B036B41064756E2164756E21
44204
44210
  //# sourceMappingURL=index.js.map