@primate/angular 0.3.0 → 0.4.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.
- package/lib/private/Default.d.ts +3 -0
- package/lib/private/Default.js +7 -1
- package/lib/private/INITIAL_PROPS.d.ts +1 -1
- package/lib/private/Runtime.js +2 -2
- package/lib/private/client/index.d.ts +2 -2
- package/lib/private/client/index.js +4 -4
- package/lib/private/create-root.js +5 -5
- package/package.json +3 -3
package/lib/private/Default.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import Runtime from "#Runtime";
|
|
2
|
+
import type NextServe from "@primate/core/NextServe";
|
|
3
|
+
import type ServeApp from "@primate/core/ServeApp";
|
|
2
4
|
export default class Default extends Runtime {
|
|
3
5
|
root: {
|
|
4
6
|
create: (depth: number, i18n_active: boolean) => string;
|
|
@@ -13,5 +15,6 @@ export default class Default extends Runtime {
|
|
|
13
15
|
};
|
|
14
16
|
server: (text: string) => string;
|
|
15
17
|
};
|
|
18
|
+
serve(app: ServeApp, next: NextServe): Promise<ServeApp>;
|
|
16
19
|
}
|
|
17
20
|
//# sourceMappingURL=Default.d.ts.map
|
package/lib/private/Default.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import create_root from "#create-root";
|
|
2
2
|
import Runtime from "#Runtime";
|
|
3
|
+
import { enableProdMode } from "@angular/core";
|
|
3
4
|
import * as ts from "typescript";
|
|
4
5
|
export default class Default extends Runtime {
|
|
5
6
|
root = {
|
|
@@ -46,8 +47,13 @@ export default class Default extends Runtime {
|
|
|
46
47
|
moduleResolution: ts.ModuleResolutionKind.NodeJs,
|
|
47
48
|
},
|
|
48
49
|
});
|
|
49
|
-
|
|
50
|
+
// hinder treeshaking
|
|
51
|
+
return `import "@angular/compiler";\n${result.outputText}`;
|
|
50
52
|
},
|
|
51
53
|
};
|
|
54
|
+
async serve(app, next) {
|
|
55
|
+
app.mode === "production" && enableProdMode();
|
|
56
|
+
return super.serve(app, next);
|
|
57
|
+
}
|
|
52
58
|
}
|
|
53
59
|
//# sourceMappingURL=Default.js.map
|
package/lib/private/Runtime.js
CHANGED
|
@@ -11,7 +11,7 @@ export default class Runtime extends FrontendModule {
|
|
|
11
11
|
defaultExtensions = [".component.ts"];
|
|
12
12
|
layouts = true;
|
|
13
13
|
client = true;
|
|
14
|
-
render = async (
|
|
14
|
+
render = async (view, props) => {
|
|
15
15
|
const providers = [
|
|
16
16
|
importProvidersFrom(BrowserModule),
|
|
17
17
|
provideServerRendering(),
|
|
@@ -22,7 +22,7 @@ export default class Runtime extends FrontendModule {
|
|
|
22
22
|
useValue: props,
|
|
23
23
|
},
|
|
24
24
|
];
|
|
25
|
-
const bootstrap = (context) => bootstrapApplication(
|
|
25
|
+
const bootstrap = (context) => bootstrapApplication(view, { providers }, context);
|
|
26
26
|
const html = await renderApplication(bootstrap, {
|
|
27
27
|
document: `<${root}></${root}>`,
|
|
28
28
|
});
|
|
@@ -3,12 +3,12 @@ import "@angular/compiler";
|
|
|
3
3
|
import type ClientData from "@primate/core/client/Data";
|
|
4
4
|
import type Dict from "@rcompat/type/Dict";
|
|
5
5
|
type Data = ClientData<{
|
|
6
|
-
|
|
6
|
+
views: string[];
|
|
7
7
|
props: Dict[];
|
|
8
8
|
}>;
|
|
9
9
|
export default class AngularClient {
|
|
10
10
|
#private;
|
|
11
|
-
static mount(
|
|
11
|
+
static mount(_view: string, data: ClientData<Data>): Promise<void>;
|
|
12
12
|
}
|
|
13
13
|
export {};
|
|
14
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -4,10 +4,10 @@ import "@angular/compiler";
|
|
|
4
4
|
import { NgZone, provideZoneChangeDetection, } from "@angular/core";
|
|
5
5
|
import { bootstrapApplication, provideClientHydration, } from "@angular/platform-browser";
|
|
6
6
|
import spa from "@primate/core/client/spa";
|
|
7
|
-
import * as components from "angular:components";
|
|
8
7
|
import root from "angular:root";
|
|
8
|
+
import * as views from "angular:views";
|
|
9
9
|
const make_props = (data) => ({
|
|
10
|
-
|
|
10
|
+
views: data.views.map(name => views[name]),
|
|
11
11
|
props: data.props,
|
|
12
12
|
request: {
|
|
13
13
|
...data.request,
|
|
@@ -19,7 +19,7 @@ export default class AngularClient {
|
|
|
19
19
|
static #app;
|
|
20
20
|
static #root;
|
|
21
21
|
static #zone;
|
|
22
|
-
static async mount(
|
|
22
|
+
static async mount(_view, data) {
|
|
23
23
|
const providers = [];
|
|
24
24
|
// Add hydration provider for SSR
|
|
25
25
|
if (data.ssr) {
|
|
@@ -27,7 +27,7 @@ export default class AngularClient {
|
|
|
27
27
|
}
|
|
28
28
|
// Add zone.js change detection
|
|
29
29
|
providers.push(provideZoneChangeDetection({ eventCoalescing: true }));
|
|
30
|
-
// Create the root
|
|
30
|
+
// Create the root view props
|
|
31
31
|
const props = make_props(data);
|
|
32
32
|
// Bootstrap the application
|
|
33
33
|
try {
|
|
@@ -44,7 +44,7 @@ ${i18n_imports}
|
|
|
44
44
|
|
|
45
45
|
type Dict = Record<string, any>;
|
|
46
46
|
type RootProps = {
|
|
47
|
-
|
|
47
|
+
views: any[];
|
|
48
48
|
props: Dict[];
|
|
49
49
|
request: any;
|
|
50
50
|
update?: () => void
|
|
@@ -77,11 +77,11 @@ export default class RootComponent implements OnDestroy {
|
|
|
77
77
|
get p(): RootProps { return this.#p; }
|
|
78
78
|
get P(): RootProps { return this.#p; }
|
|
79
79
|
|
|
80
|
-
// is there a
|
|
81
|
-
has(i: number) { return !!this.P?.
|
|
80
|
+
// is there a view at index i?
|
|
81
|
+
has(i: number) { return !!this.P?.views?.[i]; }
|
|
82
82
|
|
|
83
|
-
//
|
|
84
|
-
comp(i: number) { return this.P?.
|
|
83
|
+
// view type for index i
|
|
84
|
+
comp(i: number) { return this.P?.views?.[i]; }
|
|
85
85
|
|
|
86
86
|
// per-layer inputs without slot
|
|
87
87
|
inputs(i: number) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primate/angular",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.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",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"@rcompat/record": "^0.9.1",
|
|
30
30
|
"typescript": "^5.9.2",
|
|
31
31
|
"zone.js": "^0.15.1",
|
|
32
|
-
"@primate/core": "^0.
|
|
32
|
+
"@primate/core": "^0.3.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"primate": "^0.
|
|
35
|
+
"primate": "^0.34.0"
|
|
36
36
|
},
|
|
37
37
|
"type": "module",
|
|
38
38
|
"imports": {
|