@primate/angular 0.4.0 → 0.5.0

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.
@@ -1,6 +1,4 @@
1
1
  import Runtime from "#Runtime";
2
- import type NextServe from "@primate/core/NextServe";
3
- import type ServeApp from "@primate/core/ServeApp";
4
2
  export default class Default extends Runtime {
5
3
  root: {
6
4
  create: (depth: number, i18n_active: boolean) => string;
@@ -15,6 +13,5 @@ export default class Default extends Runtime {
15
13
  };
16
14
  server: (text: string) => string;
17
15
  };
18
- serve(app: ServeApp, next: NextServe): Promise<ServeApp>;
19
16
  }
20
17
  //# sourceMappingURL=Default.d.ts.map
@@ -1,6 +1,5 @@
1
1
  import create_root from "#create-root";
2
2
  import Runtime from "#Runtime";
3
- import { enableProdMode } from "@angular/core";
4
3
  import * as ts from "typescript";
5
4
  export default class Default extends Runtime {
6
5
  root = {
@@ -51,9 +50,5 @@ export default class Default extends Runtime {
51
50
  return `import "@angular/compiler";\n${result.outputText}`;
52
51
  },
53
52
  };
54
- async serve(app, next) {
55
- app.mode === "production" && enableProdMode();
56
- return super.serve(app, next);
57
- }
58
53
  }
59
54
  //# sourceMappingURL=Default.js.map
@@ -2,12 +2,14 @@ import "@angular/compiler";
2
2
  import { type Type } from "@angular/core";
3
3
  import FrontendModule from "@primate/core/frontend/Module";
4
4
  import type Render from "@primate/core/frontend/Render";
5
- import "zone.js/node";
5
+ import type NextServe from "@primate/core/NextServe";
6
+ import type ServeApp from "@primate/core/ServeApp";
6
7
  export default class Runtime extends FrontendModule<Type<any>> {
7
8
  name: string;
8
9
  defaultExtensions: string[];
9
10
  layouts: boolean;
10
11
  client: boolean;
11
12
  render: Render<Type<any>>;
13
+ serve(app: ServeApp, next: NextServe): Promise<ServeApp>;
12
14
  }
13
15
  //# sourceMappingURL=Runtime.d.ts.map
@@ -1,11 +1,10 @@
1
1
  import INITIAL_PROPS from "#INITIAL_PROPS";
2
2
  import root from "#root-selector";
3
3
  import "@angular/compiler";
4
- import { importProvidersFrom, provideZoneChangeDetection, } from "@angular/core";
4
+ import { enableProdMode, importProvidersFrom, } from "@angular/core";
5
5
  import { bootstrapApplication, BrowserModule, provideClientHydration, } from "@angular/platform-browser";
6
6
  import { provideServerRendering, renderApplication, } from "@angular/platform-server";
7
7
  import FrontendModule from "@primate/core/frontend/Module";
8
- import "zone.js/node";
9
8
  export default class Runtime extends FrontendModule {
10
9
  name = "angular";
11
10
  defaultExtensions = [".component.ts"];
@@ -16,7 +15,6 @@ export default class Runtime extends FrontendModule {
16
15
  importProvidersFrom(BrowserModule),
17
16
  provideServerRendering(),
18
17
  provideClientHydration(),
19
- provideZoneChangeDetection({ eventCoalescing: true }),
20
18
  {
21
19
  provide: INITIAL_PROPS,
22
20
  useValue: props,
@@ -34,5 +32,9 @@ export default class Runtime extends FrontendModule {
34
32
  head: headMatch?.[1] || "",
35
33
  };
36
34
  };
35
+ async serve(app, next) {
36
+ app.mode === "production" && enableProdMode();
37
+ return super.serve(app, next);
38
+ }
37
39
  }
38
40
  //# sourceMappingURL=Runtime.js.map
@@ -1,10 +1,11 @@
1
- import "zone.js";
2
1
  import "@angular/compiler";
3
2
  import type ClientData from "@primate/core/client/Data";
3
+ import type Mode from "@primate/core/Mode";
4
4
  import type Dict from "@rcompat/type/Dict";
5
5
  type Data = ClientData<{
6
6
  views: string[];
7
7
  props: Dict[];
8
+ mode: Mode;
8
9
  }>;
9
10
  export default class AngularClient {
10
11
  #private;
@@ -1,7 +1,6 @@
1
1
  import INITIAL_PROPS from "#INITIAL_PROPS";
2
- import "zone.js";
3
2
  import "@angular/compiler";
4
- import { NgZone, provideZoneChangeDetection, } from "@angular/core";
3
+ import { enableProdMode, } from "@angular/core";
5
4
  import { bootstrapApplication, provideClientHydration, } from "@angular/platform-browser";
6
5
  import spa from "@primate/core/client/spa";
7
6
  import root from "angular:root";
@@ -18,18 +17,19 @@ const make_props = (data) => ({
18
17
  export default class AngularClient {
19
18
  static #app;
20
19
  static #root;
21
- static #zone;
22
20
  static async mount(_view, data) {
21
+ if (data.mode === "production")
22
+ enableProdMode();
23
23
  const providers = [];
24
- // Add hydration provider for SSR
25
- if (data.ssr) {
24
+ // add hydration provider for SSR
25
+ if (data.ssr)
26
26
  providers.push(provideClientHydration());
27
- }
28
- // Add zone.js change detection
29
- providers.push(provideZoneChangeDetection({ eventCoalescing: true }));
30
- // Create the root view props
27
+ // in non-SSR mode, the HTML won't contain app-root, inject it
28
+ else
29
+ document.body.appendChild(document.createElement("app-root"));
30
+ // create the root view props
31
31
  const props = make_props(data);
32
- // Bootstrap the application
32
+ // bootstrap the application
33
33
  try {
34
34
  this.#app = await bootstrapApplication(root, {
35
35
  providers: [
@@ -54,16 +54,13 @@ export default class AngularClient {
54
54
  catch (error) {
55
55
  console.error("Failed to bootstrap Angular application:", error);
56
56
  }
57
- this.#zone = this.#root.injector.get(NgZone);
58
57
  }
59
58
  static #spa() {
60
59
  window.addEventListener("DOMContentLoaded", () => {
61
60
  spa((next, update) => {
62
61
  const props = { ...make_props(next), update };
63
- this.#zone.run(() => {
64
- this.#root.instance.p = props;
65
- this.#app.tick();
66
- });
62
+ this.#root.instance.p = props;
63
+ this.#app.tick();
67
64
  update?.();
68
65
  });
69
66
  });
@@ -1,6 +1,6 @@
1
1
  import root_selector from "#root-selector";
2
2
  export default (depth, i18n_active) => {
3
- const n = depth - 1;
3
+ const n = depth;
4
4
  const layer = (i, child) => {
5
5
  const slot = `slot_${i}`;
6
6
  const childTemplate = child
@@ -72,7 +72,7 @@ export default class RootComponent implements OnDestroy {
72
72
  @Input({ required: true })
73
73
  set p(value: RootProps) {
74
74
  this.#p = value;
75
- this.#cdr.markForCheck(); // root on default CD, zone ticks traverse
75
+ this.#cdr.markForCheck(); // root on default CD
76
76
  }
77
77
  get p(): RootProps { return this.#p; }
78
78
  get P(): RootProps { return this.#p; }
@@ -94,9 +94,9 @@ export default class RootComponent implements OnDestroy {
94
94
  return { ...base, slot };
95
95
  }
96
96
 
97
- ngAfterViewInit() {
97
+ ${i18n_active ? `ngAfterViewInit() {
98
98
  t[sInternal].restore();
99
- }
99
+ }` : ""}
100
100
 
101
101
  ngOnDestroy() { this.#off?.(); }
102
102
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primate/angular",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Primate Angular frontend",
5
5
  "homepage": "https://primate.run/docs/frontend/angular",
6
6
  "bugs": "https://github.com/primate-run/primate/issues",
@@ -16,23 +16,22 @@
16
16
  "directory": "packages/angular"
17
17
  },
18
18
  "dependencies": {
19
- "@angular/common": "^20.3.2",
20
- "@angular/compiler": "^20.3.2",
21
- "@angular/core": "^20.3.2",
22
- "@angular/platform-browser": "^20.3.2",
23
- "@angular/platform-server": "^20.3.2",
24
- "@angular/ssr": "^20.3.3",
19
+ "@angular/common": "^21.0.0",
20
+ "@angular/compiler": "^21.0.0",
21
+ "@angular/core": "^21.0.0",
22
+ "@angular/platform-browser": "^21.0.0",
23
+ "@angular/platform-server": "^21.0.0",
24
+ "@angular/ssr": "^21.0.0",
25
25
  "@rcompat/assert": "^0.3.1",
26
- "@rcompat/build": "^0.14.0",
27
- "@rcompat/crypto": "^0.10.0",
28
- "@rcompat/fs": "^0.21.1",
26
+ "@rcompat/build": "^0.15.0",
27
+ "@rcompat/crypto": "^0.11.0",
28
+ "@rcompat/fs": "^0.22.3",
29
29
  "@rcompat/record": "^0.9.1",
30
30
  "typescript": "^5.9.2",
31
- "zone.js": "^0.15.1",
32
- "@primate/core": "^0.3.0"
31
+ "@primate/core": "^0.4.0"
33
32
  },
34
33
  "peerDependencies": {
35
- "primate": "^0.34.0"
34
+ "primate": "^0.35.0"
36
35
  },
37
36
  "type": "module",
38
37
  "imports": {