@contello/astro 1.4.0 → 1.4.2
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/dist/index.cjs +29 -20
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +29 -20
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -87,6 +87,7 @@ var Contello = class {
|
|
|
87
87
|
_routes;
|
|
88
88
|
_i18nMessages;
|
|
89
89
|
_i18nSubscription;
|
|
90
|
+
_initialized = false;
|
|
90
91
|
_als = new import_node_async_hooks.AsyncLocalStorage();
|
|
91
92
|
media;
|
|
92
93
|
constructor(options) {
|
|
@@ -101,31 +102,39 @@ var Contello = class {
|
|
|
101
102
|
}
|
|
102
103
|
// --- lifecycle ---
|
|
103
104
|
async init(options) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
105
|
+
try {
|
|
106
|
+
await this._store.init();
|
|
107
|
+
this._assets = this._store.defineAssets(this._options.assets);
|
|
108
|
+
this._routes = this._store.defineRoutes(this._options.routes);
|
|
109
|
+
if (this._options.i18n) {
|
|
110
|
+
const { collection, languages } = this._options.i18n;
|
|
111
|
+
const { register = true, load = true } = options?.i18n ?? {};
|
|
112
|
+
this._i18nMessages = this._store.defineI18nMessages({ collection });
|
|
113
|
+
await import_i18n.i18n.configure({ locales: languages });
|
|
114
|
+
if (register) {
|
|
115
|
+
const registrations = buildI18nRegistrations();
|
|
116
|
+
if (registrations.length > 0) {
|
|
117
|
+
await this._i18nMessages.register(registrations);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (load) {
|
|
121
|
+
await applyTranslations(this._i18nMessages);
|
|
122
|
+
const messages = this._i18nMessages;
|
|
123
|
+
this._i18nSubscription = messages.refresh$.subscribe(() => applyTranslations(messages));
|
|
116
124
|
}
|
|
117
125
|
}
|
|
118
|
-
if (load) {
|
|
119
|
-
await
|
|
120
|
-
const messages = this._i18nMessages;
|
|
121
|
-
this._i18nSubscription = messages.refresh$.subscribe(() => applyTranslations(messages));
|
|
126
|
+
if (options?.load) {
|
|
127
|
+
await Promise.all(options.load.map((l) => l.load()));
|
|
122
128
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
await
|
|
129
|
+
this._initialized = true;
|
|
130
|
+
} catch (err) {
|
|
131
|
+
await this.destroy().catch(() => {
|
|
132
|
+
});
|
|
133
|
+
throw err;
|
|
126
134
|
}
|
|
127
135
|
}
|
|
128
136
|
async destroy() {
|
|
137
|
+
this._initialized = false;
|
|
129
138
|
this._i18nSubscription?.unsubscribe();
|
|
130
139
|
this._i18nSubscription = void 0;
|
|
131
140
|
await this._store.destroy();
|
|
@@ -137,7 +146,7 @@ var Contello = class {
|
|
|
137
146
|
return this._store.ping();
|
|
138
147
|
}
|
|
139
148
|
get isReady() {
|
|
140
|
-
return
|
|
149
|
+
return this._initialized;
|
|
141
150
|
}
|
|
142
151
|
// --- pre-wired collections ---
|
|
143
152
|
get assets() {
|
package/dist/index.d.cts
CHANGED
|
@@ -43,6 +43,7 @@ declare class Contello<TOps extends OperationMap | undefined = undefined, TModel
|
|
|
43
43
|
private _routes;
|
|
44
44
|
private _i18nMessages;
|
|
45
45
|
private _i18nSubscription;
|
|
46
|
+
private _initialized;
|
|
46
47
|
private readonly _als;
|
|
47
48
|
readonly media: ContelloMediaConfig;
|
|
48
49
|
constructor(options: ContelloOptions<TOps, TModels>);
|
package/dist/index.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ declare class Contello<TOps extends OperationMap | undefined = undefined, TModel
|
|
|
43
43
|
private _routes;
|
|
44
44
|
private _i18nMessages;
|
|
45
45
|
private _i18nSubscription;
|
|
46
|
+
private _initialized;
|
|
46
47
|
private readonly _als;
|
|
47
48
|
readonly media: ContelloMediaConfig;
|
|
48
49
|
constructor(options: ContelloOptions<TOps, TModels>);
|
package/dist/index.js
CHANGED
|
@@ -50,6 +50,7 @@ var Contello = class {
|
|
|
50
50
|
_routes;
|
|
51
51
|
_i18nMessages;
|
|
52
52
|
_i18nSubscription;
|
|
53
|
+
_initialized = false;
|
|
53
54
|
_als = new AsyncLocalStorage();
|
|
54
55
|
media;
|
|
55
56
|
constructor(options) {
|
|
@@ -64,31 +65,39 @@ var Contello = class {
|
|
|
64
65
|
}
|
|
65
66
|
// --- lifecycle ---
|
|
66
67
|
async init(options) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
68
|
+
try {
|
|
69
|
+
await this._store.init();
|
|
70
|
+
this._assets = this._store.defineAssets(this._options.assets);
|
|
71
|
+
this._routes = this._store.defineRoutes(this._options.routes);
|
|
72
|
+
if (this._options.i18n) {
|
|
73
|
+
const { collection, languages } = this._options.i18n;
|
|
74
|
+
const { register = true, load = true } = options?.i18n ?? {};
|
|
75
|
+
this._i18nMessages = this._store.defineI18nMessages({ collection });
|
|
76
|
+
await i18n.configure({ locales: languages });
|
|
77
|
+
if (register) {
|
|
78
|
+
const registrations = buildI18nRegistrations();
|
|
79
|
+
if (registrations.length > 0) {
|
|
80
|
+
await this._i18nMessages.register(registrations);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (load) {
|
|
84
|
+
await applyTranslations(this._i18nMessages);
|
|
85
|
+
const messages = this._i18nMessages;
|
|
86
|
+
this._i18nSubscription = messages.refresh$.subscribe(() => applyTranslations(messages));
|
|
79
87
|
}
|
|
80
88
|
}
|
|
81
|
-
if (load) {
|
|
82
|
-
await
|
|
83
|
-
const messages = this._i18nMessages;
|
|
84
|
-
this._i18nSubscription = messages.refresh$.subscribe(() => applyTranslations(messages));
|
|
89
|
+
if (options?.load) {
|
|
90
|
+
await Promise.all(options.load.map((l) => l.load()));
|
|
85
91
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
await
|
|
92
|
+
this._initialized = true;
|
|
93
|
+
} catch (err) {
|
|
94
|
+
await this.destroy().catch(() => {
|
|
95
|
+
});
|
|
96
|
+
throw err;
|
|
89
97
|
}
|
|
90
98
|
}
|
|
91
99
|
async destroy() {
|
|
100
|
+
this._initialized = false;
|
|
92
101
|
this._i18nSubscription?.unsubscribe();
|
|
93
102
|
this._i18nSubscription = void 0;
|
|
94
103
|
await this._store.destroy();
|
|
@@ -100,7 +109,7 @@ var Contello = class {
|
|
|
100
109
|
return this._store.ping();
|
|
101
110
|
}
|
|
102
111
|
get isReady() {
|
|
103
|
-
return
|
|
112
|
+
return this._initialized;
|
|
104
113
|
}
|
|
105
114
|
// --- pre-wired collections ---
|
|
106
115
|
get assets() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contello/astro",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "Astro integration for Contello CMS — route middleware and i18n bridge",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
"@astroscope/excludes": ">=0.1.0",
|
|
15
15
|
"@astroscope/i18n": ">=0.3.0",
|
|
16
16
|
"astro": "^6.0.0",
|
|
17
|
-
"@contello/client": "^1.1.
|
|
18
|
-
"@contello/
|
|
19
|
-
"@contello/
|
|
17
|
+
"@contello/client": "^1.1.1",
|
|
18
|
+
"@contello/store": "^1.5.1",
|
|
19
|
+
"@contello/media": "^1.0.0"
|
|
20
20
|
},
|
|
21
21
|
"peerDependenciesMeta": {
|
|
22
22
|
"@astroscope/i18n": {
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"@astroscope/excludes": "^0.3.2",
|
|
28
28
|
"@astroscope/i18n": "^0.4.5",
|
|
29
29
|
"astro": "^6.1.8",
|
|
30
|
-
"@contello/client": "^1.1.
|
|
31
|
-
"@contello/
|
|
32
|
-
"@contello/
|
|
30
|
+
"@contello/client": "^1.1.1",
|
|
31
|
+
"@contello/store": "^1.5.1",
|
|
32
|
+
"@contello/media": "^1.0.0"
|
|
33
33
|
},
|
|
34
34
|
"files": [
|
|
35
35
|
"dist"
|