@absolutejs/absolute 0.19.0-beta.852 → 0.19.0-beta.854

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.
Files changed (44) hide show
  1. package/dist/angular/components/core/streamingSlotRegistrar.js +1 -1
  2. package/dist/angular/components/core/streamingSlotRegistry.js +2 -2
  3. package/dist/angular/index.js +52 -76
  4. package/dist/angular/index.js.map +3 -3
  5. package/dist/angular/server.js +53 -77
  6. package/dist/angular/server.js.map +3 -3
  7. package/dist/build.js +2129 -730
  8. package/dist/build.js.map +17 -8
  9. package/dist/dev/client/handlers/angularHmrShim.ts +77 -0
  10. package/dist/dev/client/hmrClient.ts +55 -5
  11. package/dist/index.js +2219 -778
  12. package/dist/index.js.map +18 -9
  13. package/dist/react/index.js +3 -1
  14. package/dist/react/index.js.map +2 -2
  15. package/dist/react/server.js +3 -1
  16. package/dist/react/server.js.map +2 -2
  17. package/dist/src/core/prepare.d.ts +25 -0
  18. package/dist/src/dev/angular/fastHmrCompiler.d.ts +32 -0
  19. package/dist/src/dev/angular/hmrCompiler.d.ts +18 -0
  20. package/dist/src/dev/angular/hmrImportGenerator.d.ts +3 -0
  21. package/dist/src/dev/angular/hmrInjectionPlugin.d.ts +7 -0
  22. package/dist/src/dev/angular/resolveOwningComponents.d.ts +8 -0
  23. package/dist/src/dev/angular/vendor/translator/api/ast_factory.d.ts +363 -0
  24. package/dist/src/dev/angular/vendor/translator/api/import_generator.d.ts +49 -0
  25. package/dist/src/dev/angular/vendor/translator/context.d.ts +18 -0
  26. package/dist/src/dev/angular/vendor/translator/translator.d.ts +75 -0
  27. package/dist/src/dev/angular/vendor/translator/ts_util.d.ts +12 -0
  28. package/dist/src/dev/angular/vendor/translator/typescript_ast_factory.d.ts +66 -0
  29. package/dist/src/dev/angular/vendor/translator/typescript_translator.d.ts +13 -0
  30. package/dist/src/dev/rebuildTrigger.d.ts +1 -0
  31. package/dist/src/plugins/hmr.d.ts +25 -0
  32. package/dist/src/vue/components/Image.d.ts +1 -1
  33. package/dist/svelte/index.js +3 -1
  34. package/dist/svelte/index.js.map +2 -2
  35. package/dist/svelte/server.js +3 -1
  36. package/dist/svelte/server.js.map +2 -2
  37. package/dist/vue/index.js +3 -1
  38. package/dist/vue/index.js.map +2 -2
  39. package/dist/vue/server.js +3 -1
  40. package/dist/vue/server.js.map +2 -2
  41. package/package.json +1 -1
  42. package/dist/dev/client/handlers/angular.ts +0 -684
  43. package/dist/dev/client/handlers/angularRuntime.ts +0 -415
  44. package/dist/src/dev/angular/editTypeDetection.d.ts +0 -8
@@ -0,0 +1,77 @@
1
+ import type {} from '../../../types/globals';
2
+ /* `globalThis.__angularHmr` runtime shim.
3
+ *
4
+ * The HMR injection plugin
5
+ * (`src/dev/angular/hmrInjectionPlugin.ts`) appends per-component
6
+ * `__ng_hmr_load` blocks that subscribe via
7
+ * `globalThis.__angularHmr.on('angular:component-update', cb)`.
8
+ * This file installs that bus.
9
+ *
10
+ * It must run before any component chunk does — the injected blocks
11
+ * `if (… && globalThis.__angularHmr.on)` no-op if the shim isn't
12
+ * defined yet, so a registration would silently miss. We keep the
13
+ * shim setup synchronous + at module scope so it's installed during
14
+ * `hmrClient.ts`'s import-evaluation pass, before page chunks load. */
15
+
16
+ export type AngularHmrEvent = 'angular:component-update';
17
+ export type AngularComponentUpdate = {
18
+ id: string;
19
+ timestamp: number;
20
+ };
21
+ export type AngularHmrListener = (data: AngularComponentUpdate) => void;
22
+
23
+ type AngularHmrBus = {
24
+ on(event: AngularHmrEvent, cb: AngularHmrListener): void;
25
+ off(event: AngularHmrEvent, cb: AngularHmrListener): void;
26
+ dispatch(event: AngularHmrEvent, data: AngularComponentUpdate): void;
27
+ };
28
+
29
+ declare global {
30
+ interface Window {
31
+ __angularHmr?: AngularHmrBus;
32
+ }
33
+ // eslint-disable-next-line no-var
34
+ var __angularHmr: AngularHmrBus | undefined;
35
+ }
36
+
37
+ const installAngularHmrShim = (): AngularHmrBus => {
38
+ const listeners = new Map<AngularHmrEvent, Set<AngularHmrListener>>();
39
+
40
+ const bus: AngularHmrBus = {
41
+ on(event, cb) {
42
+ let set = listeners.get(event);
43
+ if (!set) {
44
+ set = new Set();
45
+ listeners.set(event, set);
46
+ }
47
+ set.add(cb);
48
+ },
49
+ off(event, cb) {
50
+ listeners.get(event)?.delete(cb);
51
+ },
52
+ dispatch(event, data) {
53
+ const set = listeners.get(event);
54
+ if (!set) return;
55
+ // Snapshot before iterating — handlers could remove themselves.
56
+ for (const cb of [...set]) {
57
+ try {
58
+ cb(data);
59
+ } catch (err) {
60
+ console.error('[absolutejs] angular HMR listener threw', err);
61
+ }
62
+ }
63
+ }
64
+ };
65
+
66
+ return bus;
67
+ };
68
+
69
+ if (typeof globalThis !== 'undefined' && !globalThis.__angularHmr) {
70
+ globalThis.__angularHmr = installAngularHmrShim();
71
+ }
72
+
73
+ export const dispatchAngularComponentUpdate = (
74
+ data: AngularComponentUpdate
75
+ ) => {
76
+ globalThis.__angularHmr?.dispatch('angular:component-update', data);
77
+ };
@@ -13,7 +13,7 @@ import {
13
13
  } from './constants';
14
14
  import { detectCurrentFramework } from './frameworkDetect';
15
15
  import { hideErrorOverlay, showErrorOverlay } from './errorOverlay';
16
- import { handleAngularUpdate } from './handlers/angular';
16
+ import { dispatchAngularComponentUpdate } from './handlers/angularHmrShim';
17
17
  import { handleReactUpdate } from './handlers/react';
18
18
  import { handleHTMLUpdate, handleScriptUpdate } from './handlers/html';
19
19
  import { handleHTMXUpdate } from './handlers/htmx';
@@ -68,7 +68,8 @@ window.addEventListener('unhandledrejection', (evt) => {
68
68
  });
69
69
 
70
70
  const hmrUpdateTypes = new Set([
71
- 'angular-update',
71
+ 'angular:component-update',
72
+ 'angular:rebootstrap',
72
73
  'react-update',
73
74
  'html-update',
74
75
  'htmx-update',
@@ -148,10 +149,59 @@ const handleHMRMessage = (message: HMRMessage) => {
148
149
  hideErrorOverlay();
149
150
  handleVueUpdate(message);
150
151
  break;
151
- case 'angular-update':
152
- hideErrorOverlay();
153
- handleAngularUpdate(message);
152
+ case 'angular:component-update': {
153
+ // Surgical-HMR fast path. Server resolved the changed
154
+ // file → owning component classes and emitted one
155
+ // message per affected component. Our injected
156
+ // `__ng_hmr_load` blocks (see hmrInjectionPlugin.ts)
157
+ // listen here and re-fetch the applyMetadata module.
158
+ const data = message.data as
159
+ | { id?: string; timestamp?: number }
160
+ | undefined;
161
+ if (data && typeof data.id === 'string') {
162
+ dispatchAngularComponentUpdate({
163
+ id: data.id,
164
+ timestamp:
165
+ typeof data.timestamp === 'number'
166
+ ? data.timestamp
167
+ : Date.now()
168
+ });
169
+ }
154
170
  break;
171
+ }
172
+ case 'angular:rebootstrap': {
173
+ // Tier 1 fallback. The user's edit changed structure
174
+ // the surgical path can't safely apply
175
+ // (constructor/decorator/imports change, service edit,
176
+ // etc.). The bundle has already been rebuilt server-side
177
+ // and the manifest is updated. Call the chunk's baked-in
178
+ // hook (set by the hydration template in compileAngular.ts)
179
+ // to dynamic-import the fresh bundle URL — re-importing
180
+ // re-runs the destroy + bootstrapApplication block.
181
+ const data = message.data as
182
+ | { manifest?: Record<string, string>; reason?: string }
183
+ | undefined;
184
+ if (data?.manifest) {
185
+ window.__HMR_MANIFEST__ = data.manifest;
186
+ }
187
+ const w = window as Window & {
188
+ __ABS_ANGULAR_REBOOTSTRAP__?: () => Promise<void>;
189
+ };
190
+ if (typeof w.__ABS_ANGULAR_REBOOTSTRAP__ === 'function') {
191
+ w.__ABS_ANGULAR_REBOOTSTRAP__().catch((err) => {
192
+ console.error(
193
+ '[absolutejs] angular:rebootstrap failed',
194
+ err
195
+ );
196
+ });
197
+ } else {
198
+ // No hook = no Angular page loaded, or the hook
199
+ // hasn't run yet. Falling back to a full reload is
200
+ // safe and correct.
201
+ window.location.reload();
202
+ }
203
+ break;
204
+ }
155
205
  case 'rebuild-error':
156
206
  handleRebuildError(message);
157
207
  break;