@contello/astro 1.0.4 → 1.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020-2026 entwico GmbH
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
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.4",
3
+ "version": "1.1.0",
4
4
  "description": "Astro integration for Contello CMS — route middleware and i18n bridge",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -10,12 +10,6 @@
10
10
  "url": "https://github.com/entwico/contello-js",
11
11
  "directory": "packages/astro"
12
12
  },
13
- "scripts": {
14
- "build": "tsup",
15
- "lint": "eslint .",
16
- "lint:fix": "eslint . --fix",
17
- "typecheck": "tsc --noEmit"
18
- },
19
13
  "peerDependencies": {
20
14
  "@astroscope/excludes": ">=0.1.0",
21
15
  "@astroscope/i18n": ">=0.3.0",
@@ -27,8 +21,8 @@
27
21
  }
28
22
  },
29
23
  "dependencies": {
30
- "@contello/client": "workspace:^",
31
- "@contello/store": "workspace:^"
24
+ "@contello/client": "^1.0.2",
25
+ "@contello/store": "^1.1.0"
32
26
  },
33
27
  "devDependencies": {
34
28
  "@astroscope/excludes": "^0.3.0",
@@ -48,5 +42,11 @@
48
42
  "publishConfig": {
49
43
  "access": "public",
50
44
  "registry": "https://registry.npmjs.org"
45
+ },
46
+ "scripts": {
47
+ "build": "tsup",
48
+ "lint": "eslint .",
49
+ "lint:fix": "eslint . --fix",
50
+ "typecheck": "tsc --noEmit"
51
51
  }
52
- }
52
+ }