@contello/astro 1.0.5 → 1.1.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 CHANGED
@@ -88,14 +88,14 @@ var Contello = class {
88
88
  this._store = (0, import_store.createStore)(options);
89
89
  }
90
90
  // --- lifecycle ---
91
- async init() {
91
+ async init(options) {
92
92
  await this._store.init();
93
93
  this._assets = this._store.defineAssets(this._options.assets);
94
94
  this._routes = this._store.defineRoutes(this._options.routes);
95
95
  if (this._options.i18n) {
96
- const { collection, locales, register = true, load = true } = this._options.i18n;
96
+ const { collection, languages, register = true, load = true } = this._options.i18n;
97
97
  this._i18nMessages = this._store.defineI18nMessages({ collection });
98
- await import_i18n.i18n.configure({ locales });
98
+ await import_i18n.i18n.configure({ locales: languages });
99
99
  if (register) {
100
100
  const registrations = buildI18nRegistrations();
101
101
  if (registrations.length > 0) {
@@ -108,6 +108,9 @@ var Contello = class {
108
108
  this._i18nSubscription = messages.refresh$.subscribe(() => applyTranslations(messages));
109
109
  }
110
110
  }
111
+ if (options?.load) {
112
+ await Promise.all(options.load.map((l) => l.load()));
113
+ }
111
114
  }
112
115
  async destroy() {
113
116
  this._i18nSubscription?.unsubscribe();
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { OperationMap } from '@contello/client';
2
- import { CreateStoreOptions, AssetCollectionOptions, RouteCollectionOptions, Assets, Routes, I18nMessages, StoreRoute, SingletonDef, Singleton, SingletonSyncDef, SingletonSync, CollectionDef, Collection, CollectionSyncDef, CollectionSync, LazyCollectionDef, LazyCollection } from '@contello/store';
2
+ import { CreateStoreOptions, AssetCollectionOptions, RouteCollectionOptions, Loadable, Assets, Routes, I18nMessages, StoreRoute, SingletonDef, Singleton, SingletonSyncDef, SingletonSync, CollectionDef, Collection, CollectionSyncDef, CollectionSync, LazyCollectionDef, LazyCollection } from '@contello/store';
3
3
  import * as astro from 'astro';
4
4
  import { ExcludePattern } from '@astroscope/excludes';
5
5
 
@@ -10,7 +10,7 @@ type ContelloRequestContext = {
10
10
  };
11
11
  type ContelloI18nOptions = {
12
12
  collection: string;
13
- locales: string[];
13
+ languages: string[];
14
14
  register?: boolean | undefined;
15
15
  load?: boolean | undefined;
16
16
  };
@@ -29,7 +29,9 @@ declare class Contello<TOps extends OperationMap | undefined = undefined, TModel
29
29
  private _i18nSubscription;
30
30
  private readonly _als;
31
31
  constructor(options: ContelloOptions<TOps, TModels>);
32
- init(): Promise<void>;
32
+ init(options?: {
33
+ load?: Loadable[] | undefined;
34
+ } | undefined): Promise<void>;
33
35
  destroy(): Promise<void>;
34
36
  ping(): Promise<void>;
35
37
  get assets(): Assets;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { OperationMap } from '@contello/client';
2
- import { CreateStoreOptions, AssetCollectionOptions, RouteCollectionOptions, Assets, Routes, I18nMessages, StoreRoute, SingletonDef, Singleton, SingletonSyncDef, SingletonSync, CollectionDef, Collection, CollectionSyncDef, CollectionSync, LazyCollectionDef, LazyCollection } from '@contello/store';
2
+ import { CreateStoreOptions, AssetCollectionOptions, RouteCollectionOptions, Loadable, Assets, Routes, I18nMessages, StoreRoute, SingletonDef, Singleton, SingletonSyncDef, SingletonSync, CollectionDef, Collection, CollectionSyncDef, CollectionSync, LazyCollectionDef, LazyCollection } from '@contello/store';
3
3
  import * as astro from 'astro';
4
4
  import { ExcludePattern } from '@astroscope/excludes';
5
5
 
@@ -10,7 +10,7 @@ type ContelloRequestContext = {
10
10
  };
11
11
  type ContelloI18nOptions = {
12
12
  collection: string;
13
- locales: string[];
13
+ languages: string[];
14
14
  register?: boolean | undefined;
15
15
  load?: boolean | undefined;
16
16
  };
@@ -29,7 +29,9 @@ declare class Contello<TOps extends OperationMap | undefined = undefined, TModel
29
29
  private _i18nSubscription;
30
30
  private readonly _als;
31
31
  constructor(options: ContelloOptions<TOps, TModels>);
32
- init(): Promise<void>;
32
+ init(options?: {
33
+ load?: Loadable[] | undefined;
34
+ } | undefined): Promise<void>;
33
35
  destroy(): Promise<void>;
34
36
  ping(): Promise<void>;
35
37
  get assets(): Assets;
package/dist/index.js CHANGED
@@ -52,14 +52,14 @@ var Contello = class {
52
52
  this._store = createStore(options);
53
53
  }
54
54
  // --- lifecycle ---
55
- async init() {
55
+ async init(options) {
56
56
  await this._store.init();
57
57
  this._assets = this._store.defineAssets(this._options.assets);
58
58
  this._routes = this._store.defineRoutes(this._options.routes);
59
59
  if (this._options.i18n) {
60
- const { collection, locales, register = true, load = true } = this._options.i18n;
60
+ const { collection, languages, register = true, load = true } = this._options.i18n;
61
61
  this._i18nMessages = this._store.defineI18nMessages({ collection });
62
- await i18n.configure({ locales });
62
+ await i18n.configure({ locales: languages });
63
63
  if (register) {
64
64
  const registrations = buildI18nRegistrations();
65
65
  if (registrations.length > 0) {
@@ -72,6 +72,9 @@ var Contello = class {
72
72
  this._i18nSubscription = messages.refresh$.subscribe(() => applyTranslations(messages));
73
73
  }
74
74
  }
75
+ if (options?.load) {
76
+ await Promise.all(options.load.map((l) => l.load()));
77
+ }
75
78
  }
76
79
  async destroy() {
77
80
  this._i18nSubscription?.unsubscribe();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contello/astro",
3
- "version": "1.0.5",
3
+ "version": "1.1.1",
4
4
  "description": "Astro integration for Contello CMS — route middleware and i18n bridge",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -21,8 +21,8 @@
21
21
  }
22
22
  },
23
23
  "dependencies": {
24
- "@contello/client": "^1.0.1",
25
- "@contello/store": "^1.0.5"
24
+ "@contello/client": "^1.0.3",
25
+ "@contello/store": "^1.1.1"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@astroscope/excludes": "^0.3.0",
@@ -39,6 +39,9 @@
39
39
  "require": "./dist/index.cjs"
40
40
  }
41
41
  },
42
+ "astro": {
43
+ "external": true
44
+ },
42
45
  "publishConfig": {
43
46
  "access": "public",
44
47
  "registry": "https://registry.npmjs.org"