@contello/astro 2.2.0 → 2.2.1
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 +2 -12
- package/dist/index.d.cts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +2 -12
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -281,7 +281,6 @@ var Contello = class {
|
|
|
281
281
|
_i18nUnsubscribe;
|
|
282
282
|
_initialized = false;
|
|
283
283
|
_als = new import_node_async_hooks.AsyncLocalStorage();
|
|
284
|
-
_autoEagerRoutes;
|
|
285
284
|
_autoLazyRoutes;
|
|
286
285
|
media;
|
|
287
286
|
constructor(options) {
|
|
@@ -324,8 +323,7 @@ var Contello = class {
|
|
|
324
323
|
})();
|
|
325
324
|
}
|
|
326
325
|
}
|
|
327
|
-
|
|
328
|
-
await Promise.all(loadables.map((l) => l.load()));
|
|
326
|
+
await Promise.all((options?.load ?? []).map((l) => l.load()));
|
|
329
327
|
this._initialized = true;
|
|
330
328
|
} catch (err) {
|
|
331
329
|
await this.destroy().catch(() => {
|
|
@@ -406,15 +404,7 @@ var Contello = class {
|
|
|
406
404
|
}
|
|
407
405
|
// --- middleware factories (arrow fields so destructuring works) ---
|
|
408
406
|
createRoutingMiddleware = (options) => {
|
|
409
|
-
const
|
|
410
|
-
let routes;
|
|
411
|
-
if (routesOption === "eager") {
|
|
412
|
-
routes = this._autoEagerRoutes ??= this.defineRoutesSync();
|
|
413
|
-
} else if (routesOption === "lazy") {
|
|
414
|
-
routes = this._autoLazyRoutes ??= this.defineLazyRoutes();
|
|
415
|
-
} else {
|
|
416
|
-
routes = routesOption;
|
|
417
|
-
}
|
|
407
|
+
const routes = options?.routes ?? (this._autoLazyRoutes ??= this.defineLazyRoutes());
|
|
418
408
|
return createBoundRoutingMiddleware(this, routes, options?.exclude, options?.resolveRoutePath);
|
|
419
409
|
};
|
|
420
410
|
createAssetsMiddleware = (options) => {
|
package/dist/index.d.cts
CHANGED
|
@@ -31,11 +31,13 @@ type AnyRoutes = Routes | RoutesSync | LazyRoutes;
|
|
|
31
31
|
type RoutePathResolver = (ctx: APIContext) => string;
|
|
32
32
|
type ContelloRoutingMiddlewareOptions = {
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
34
|
+
* Routes instance backing the middleware.
|
|
35
|
+
*
|
|
36
|
+
* Defaults to a `LazyRoutes` instance managed by contello (fetched on demand, no init-time load).
|
|
37
|
+
* For eager routing, create a `RoutesSync` via `contello.defineRoutesSync()`, add it to
|
|
38
|
+
* `contello.init({ load: [routes] })`, and pass that same instance here.
|
|
37
39
|
*/
|
|
38
|
-
routes?:
|
|
40
|
+
routes?: AnyRoutes | undefined;
|
|
39
41
|
exclude?: ExcludePattern[] | undefined;
|
|
40
42
|
resolveRoutePath?: RoutePathResolver | undefined;
|
|
41
43
|
};
|
|
@@ -85,7 +87,6 @@ declare class Contello<TSchema extends Schema | undefined = undefined> {
|
|
|
85
87
|
private _i18nUnsubscribe;
|
|
86
88
|
private _initialized;
|
|
87
89
|
private readonly _als;
|
|
88
|
-
private _autoEagerRoutes?;
|
|
89
90
|
private _autoLazyRoutes?;
|
|
90
91
|
readonly media: ContelloMediaConfig;
|
|
91
92
|
constructor(options: ContelloOptions<TSchema>);
|
package/dist/index.d.ts
CHANGED
|
@@ -31,11 +31,13 @@ type AnyRoutes = Routes | RoutesSync | LazyRoutes;
|
|
|
31
31
|
type RoutePathResolver = (ctx: APIContext) => string;
|
|
32
32
|
type ContelloRoutingMiddlewareOptions = {
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
34
|
+
* Routes instance backing the middleware.
|
|
35
|
+
*
|
|
36
|
+
* Defaults to a `LazyRoutes` instance managed by contello (fetched on demand, no init-time load).
|
|
37
|
+
* For eager routing, create a `RoutesSync` via `contello.defineRoutesSync()`, add it to
|
|
38
|
+
* `contello.init({ load: [routes] })`, and pass that same instance here.
|
|
37
39
|
*/
|
|
38
|
-
routes?:
|
|
40
|
+
routes?: AnyRoutes | undefined;
|
|
39
41
|
exclude?: ExcludePattern[] | undefined;
|
|
40
42
|
resolveRoutePath?: RoutePathResolver | undefined;
|
|
41
43
|
};
|
|
@@ -85,7 +87,6 @@ declare class Contello<TSchema extends Schema | undefined = undefined> {
|
|
|
85
87
|
private _i18nUnsubscribe;
|
|
86
88
|
private _initialized;
|
|
87
89
|
private readonly _als;
|
|
88
|
-
private _autoEagerRoutes?;
|
|
89
90
|
private _autoLazyRoutes?;
|
|
90
91
|
readonly media: ContelloMediaConfig;
|
|
91
92
|
constructor(options: ContelloOptions<TSchema>);
|
package/dist/index.js
CHANGED
|
@@ -248,7 +248,6 @@ var Contello = class {
|
|
|
248
248
|
_i18nUnsubscribe;
|
|
249
249
|
_initialized = false;
|
|
250
250
|
_als = new AsyncLocalStorage();
|
|
251
|
-
_autoEagerRoutes;
|
|
252
251
|
_autoLazyRoutes;
|
|
253
252
|
media;
|
|
254
253
|
constructor(options) {
|
|
@@ -291,8 +290,7 @@ var Contello = class {
|
|
|
291
290
|
})();
|
|
292
291
|
}
|
|
293
292
|
}
|
|
294
|
-
|
|
295
|
-
await Promise.all(loadables.map((l) => l.load()));
|
|
293
|
+
await Promise.all((options?.load ?? []).map((l) => l.load()));
|
|
296
294
|
this._initialized = true;
|
|
297
295
|
} catch (err) {
|
|
298
296
|
await this.destroy().catch(() => {
|
|
@@ -373,15 +371,7 @@ var Contello = class {
|
|
|
373
371
|
}
|
|
374
372
|
// --- middleware factories (arrow fields so destructuring works) ---
|
|
375
373
|
createRoutingMiddleware = (options) => {
|
|
376
|
-
const
|
|
377
|
-
let routes;
|
|
378
|
-
if (routesOption === "eager") {
|
|
379
|
-
routes = this._autoEagerRoutes ??= this.defineRoutesSync();
|
|
380
|
-
} else if (routesOption === "lazy") {
|
|
381
|
-
routes = this._autoLazyRoutes ??= this.defineLazyRoutes();
|
|
382
|
-
} else {
|
|
383
|
-
routes = routesOption;
|
|
384
|
-
}
|
|
374
|
+
const routes = options?.routes ?? (this._autoLazyRoutes ??= this.defineLazyRoutes());
|
|
385
375
|
return createBoundRoutingMiddleware(this, routes, options?.exclude, options?.resolveRoutePath);
|
|
386
376
|
};
|
|
387
377
|
createAssetsMiddleware = (options) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contello/astro",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "Astro integration for Contello CMS — route middleware and i18n bridge",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"@astroscope/i18n": ">=0.3.0",
|
|
16
16
|
"astro": "^6.0.0",
|
|
17
17
|
"@contello/client": "^2.2.0",
|
|
18
|
-
"@contello/
|
|
19
|
-
"@contello/
|
|
18
|
+
"@contello/media": "^1.0.1",
|
|
19
|
+
"@contello/store": "^2.1.0"
|
|
20
20
|
},
|
|
21
21
|
"peerDependenciesMeta": {
|
|
22
22
|
"@astroscope/i18n": {
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"@astroscope/i18n": "^0.4.5",
|
|
29
29
|
"astro": "^6.1.8",
|
|
30
30
|
"@contello/client": "^2.2.0",
|
|
31
|
-
"@contello/
|
|
32
|
-
"@contello/
|
|
31
|
+
"@contello/media": "^1.0.1",
|
|
32
|
+
"@contello/store": "^2.1.0"
|
|
33
33
|
},
|
|
34
34
|
"files": [
|
|
35
35
|
"dist"
|