@geexcode/geex-extensions-settings 0.0.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.
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { signal, InjectionToken, makeEnvironmentProviders } from '@angular/core';
|
|
2
|
+
import { gql, Apollo } from 'apollo-angular';
|
|
3
|
+
import { firstValueFrom } from 'rxjs';
|
|
4
|
+
import { guardedSignal, provideGeexModuleContribution } from '@geexcode/geex-angular';
|
|
5
|
+
|
|
6
|
+
const GQL_ACTIVE_SETTINGS = gql `query activeSettings { activeSettings { id name value } }`;
|
|
7
|
+
function createSettingsModule(injector) {
|
|
8
|
+
const _settingsSignal = signal([], ...(ngDevMode ? [{ debugName: "_settingsSignal" }] : []));
|
|
9
|
+
let _initialized = false;
|
|
10
|
+
let _initPromise = null;
|
|
11
|
+
const module = {
|
|
12
|
+
settings: guardedSignal(_settingsSignal, () => _initialized),
|
|
13
|
+
init: (force = false) => {
|
|
14
|
+
if (force) {
|
|
15
|
+
_initPromise = null;
|
|
16
|
+
_initialized = false;
|
|
17
|
+
}
|
|
18
|
+
if (!_initPromise) {
|
|
19
|
+
_initPromise = (async () => {
|
|
20
|
+
try {
|
|
21
|
+
const res = (await firstValueFrom(injector.get(Apollo).query({ query: GQL_ACTIVE_SETTINGS })));
|
|
22
|
+
_settingsSignal.set(res.data.activeSettings);
|
|
23
|
+
_initialized = true;
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
console.error(err);
|
|
27
|
+
}
|
|
28
|
+
})();
|
|
29
|
+
}
|
|
30
|
+
return _initPromise;
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
return module;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const GEEX_SETTINGS_OPTIONS = new InjectionToken("GEEX_SETTINGS_OPTIONS");
|
|
37
|
+
function provideGeexSettings(options = {}) {
|
|
38
|
+
return makeEnvironmentProviders([
|
|
39
|
+
{ provide: GEEX_SETTINGS_OPTIONS, useValue: options },
|
|
40
|
+
provideGeexModuleContribution({
|
|
41
|
+
createModules: ({ injector }) => ({
|
|
42
|
+
settings: (options.createSettingsModule ?? createSettingsModule)(injector),
|
|
43
|
+
}),
|
|
44
|
+
}),
|
|
45
|
+
]);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Generated bundle index. Do not edit.
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
export { GEEX_SETTINGS_OPTIONS, createSettingsModule, provideGeexSettings };
|
|
53
|
+
//# sourceMappingURL=geexcode-geex-extensions-settings.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geexcode-geex-extensions-settings.mjs","sources":["../../src/settings.module.ts","../../src/provide-geex-settings.ts","../../src/geexcode-geex-extensions-settings.ts"],"sourcesContent":["import { Injector, signal } from \"@angular/core\";\r\nimport { Apollo, gql } from \"apollo-angular\";\r\nimport { firstValueFrom } from \"rxjs\";\r\nimport { guardedSignal } from \"@geexcode/geex-angular\";\r\nimport type { SettingItem, SettingsModule } from \"./settings.types\";\r\n\r\nconst GQL_ACTIVE_SETTINGS = gql`query activeSettings { activeSettings { id name value } }`;\r\n\r\nexport function createSettingsModule(injector: Injector): SettingsModule {\r\n const _settingsSignal = signal<SettingItem[]>([]);\r\n let _initialized = false;\r\n let _initPromise: Promise<void> | null = null;\r\n const module = {\r\n settings: guardedSignal(_settingsSignal, () => _initialized),\r\n init: (force = false) => {\r\n if (force) {\r\n _initPromise = null;\r\n _initialized = false;\r\n }\r\n if (!_initPromise) {\r\n _initPromise = (async () => {\r\n try {\r\n type ActiveSettingsResponse = { data: { activeSettings: SettingItem[] } };\r\n const res = (await firstValueFrom(\r\n injector.get(Apollo).query<ActiveSettingsResponse>({ query: GQL_ACTIVE_SETTINGS }),\r\n )) as unknown as ActiveSettingsResponse;\r\n _settingsSignal.set(res.data.activeSettings);\r\n _initialized = true;\r\n } catch (err) {\r\n console.error(err);\r\n }\r\n })();\r\n }\r\n return _initPromise;\r\n },\r\n };\r\n return module as unknown as SettingsModule;\r\n}\r\n","import { EnvironmentProviders, InjectionToken, Injector, makeEnvironmentProviders } from \"@angular/core\";\r\nimport { provideGeexModuleContribution } from \"@geexcode/geex-angular\";\r\nimport { createSettingsModule } from \"./settings.module\";\r\nimport type { SettingsModule } from \"./settings.types\";\r\n\r\nexport interface GeexSettingsOptions {\r\n readonly createSettingsModule?: (injector: Injector) => SettingsModule;\r\n}\r\n\r\nexport const GEEX_SETTINGS_OPTIONS = new InjectionToken<Readonly<GeexSettingsOptions>>(\r\n \"GEEX_SETTINGS_OPTIONS\",\r\n);\r\n\r\nexport function provideGeexSettings(\r\n options: Readonly<GeexSettingsOptions> = {},\r\n): EnvironmentProviders {\r\n return makeEnvironmentProviders([\r\n { provide: GEEX_SETTINGS_OPTIONS, useValue: options },\r\n provideGeexModuleContribution({\r\n createModules: ({ injector }) => ({\r\n settings: (options.createSettingsModule ?? createSettingsModule)(injector),\r\n }),\r\n }),\r\n ]);\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAMA,MAAM,mBAAmB,GAAG,GAAG,CAAA,2DAA2D;AAEpF,SAAU,oBAAoB,CAAC,QAAkB,EAAA;AACrD,IAAA,MAAM,eAAe,GAAG,MAAM,CAAgB,EAAE,2DAAC;IACjD,IAAI,YAAY,GAAG,KAAK;IACxB,IAAI,YAAY,GAAyB,IAAI;AAC7C,IAAA,MAAM,MAAM,GAAG;QACb,QAAQ,EAAE,aAAa,CAAC,eAAe,EAAE,MAAM,YAAY,CAAC;AAC5D,QAAA,IAAI,EAAE,CAAC,KAAK,GAAG,KAAK,KAAI;YACtB,IAAI,KAAK,EAAE;gBACT,YAAY,GAAG,IAAI;gBACnB,YAAY,GAAG,KAAK;YACtB;YACA,IAAI,CAAC,YAAY,EAAE;AACjB,gBAAA,YAAY,GAAG,CAAC,YAAW;AACzB,oBAAA,IAAI;wBAEF,MAAM,GAAG,IAAI,MAAM,cAAc,CAC/B,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,KAAK,CAAyB,EAAE,KAAK,EAAE,mBAAmB,EAAE,CAAC,CACnF,CAAsC;wBACvC,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC;wBAC5C,YAAY,GAAG,IAAI;oBACrB;oBAAE,OAAO,GAAG,EAAE;AACZ,wBAAA,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC;oBACpB;gBACF,CAAC,GAAG;YACN;AACA,YAAA,OAAO,YAAY;QACrB,CAAC;KACF;AACD,IAAA,OAAO,MAAmC;AAC5C;;MC5Ba,qBAAqB,GAAG,IAAI,cAAc,CACrD,uBAAuB;AAGnB,SAAU,mBAAmB,CACjC,OAAA,GAAyC,EAAE,EAAA;AAE3C,IAAA,OAAO,wBAAwB,CAAC;AAC9B,QAAA,EAAE,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,OAAO,EAAE;AACrD,QAAA,6BAA6B,CAAC;YAC5B,aAAa,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM;gBAChC,QAAQ,EAAE,CAAC,OAAO,CAAC,oBAAoB,IAAI,oBAAoB,EAAE,QAAQ,CAAC;aAC3E,CAAC;SACH,CAAC;AACH,KAAA,CAAC;AACJ;;ACxBA;;AAEG;;;;"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { WritableSignal, Injector, InjectionToken, EnvironmentProviders } from '@angular/core';
|
|
2
|
+
import { GeexModule } from '@geexcode/geex-angular';
|
|
3
|
+
|
|
4
|
+
interface SettingItem {
|
|
5
|
+
name: string;
|
|
6
|
+
value?: any;
|
|
7
|
+
}
|
|
8
|
+
interface SettingsModule extends GeexModule<{
|
|
9
|
+
settings: WritableSignal<SettingItem[]>;
|
|
10
|
+
}> {
|
|
11
|
+
}
|
|
12
|
+
declare module "@geexcode/geex-angular" {
|
|
13
|
+
interface GeexModuleMap {
|
|
14
|
+
settings: SettingsModule;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare function createSettingsModule(injector: Injector): SettingsModule;
|
|
19
|
+
|
|
20
|
+
interface GeexSettingsOptions {
|
|
21
|
+
readonly createSettingsModule?: (injector: Injector) => SettingsModule;
|
|
22
|
+
}
|
|
23
|
+
declare const GEEX_SETTINGS_OPTIONS: InjectionToken<Readonly<GeexSettingsOptions>>;
|
|
24
|
+
declare function provideGeexSettings(options?: Readonly<GeexSettingsOptions>): EnvironmentProviders;
|
|
25
|
+
|
|
26
|
+
export { GEEX_SETTINGS_OPTIONS, createSettingsModule, provideGeexSettings };
|
|
27
|
+
export type { GeexSettingsOptions, SettingItem, SettingsModule };
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sources":["../src/settings.types.ts","../src/settings.module.ts","../src/provide-geex-settings.ts"],"mappings":";;;AAGA,qBAAiB;;;AAGhB;AAED,UAAM,cAAW,SAAe,UAAQ;AACtC,cAAU,cAAc,CAAC,WAAW;;AACjC;AAEL;AACE;kBACY,cAAc;AACzB;AACF;;ACRD,iBAAA,+BAAqC,QAAU,GAAA;;ACH/C,6BAAiB;+CAC4B,QAAQ,KAAK,cAAc;AACvE;AAED,cAAA,qBAAa,EAAA,cAAqB,CAAA,QAAA,CAAA,mBAAA;AAIlC,iBAAA,mBAAgB,WACd,QAAS,CAAA,mBAAS,IAAA,oBACjB;;;;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@geexcode/geex-extensions-settings",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Geex settings extension: headless settings module and domain tokens. Aligns with Geex.Extensions.Settings.",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"peerDependencies": {
|
|
7
|
+
"@angular/core": "^20.0.0",
|
|
8
|
+
"@geexcode/geex-angular": ">=0.0.41",
|
|
9
|
+
"apollo-angular": "^14.0.0",
|
|
10
|
+
"graphql": "^16.8.0",
|
|
11
|
+
"rxjs": "^7.8.0"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"tslib": "^2.6.3"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"module": "dist/fesm2022/geexcode-geex-extensions-settings.mjs",
|
|
20
|
+
"typings": "dist/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
"./package.json": {
|
|
23
|
+
"default": "./package.json"
|
|
24
|
+
},
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"import": "./dist/fesm2022/geexcode-geex-extensions-settings.mjs",
|
|
28
|
+
"default": "./dist/fesm2022/geexcode-geex-extensions-settings.mjs"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"clean": "rimraf dist",
|
|
33
|
+
"build": "ng-packagr -p ng-package.json -c tsconfig.lib.json",
|
|
34
|
+
"test": "node --test src/provide-geex-settings.node-test.mjs",
|
|
35
|
+
"prepublishOnly": "npm run build",
|
|
36
|
+
"publish:public": "npm publish ./dist --access public"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@angular/compiler": "^20.0.0",
|
|
40
|
+
"@angular/compiler-cli": "^20.0.0",
|
|
41
|
+
"@angular/core": "^20.0.0",
|
|
42
|
+
"@geexcode/geex-angular": "workspace:*",
|
|
43
|
+
"apollo-angular": "^14.1.0",
|
|
44
|
+
"graphql": "^16.9.0",
|
|
45
|
+
"ng-packagr": "^20.0.0",
|
|
46
|
+
"rimraf": "^5.0.5",
|
|
47
|
+
"rxjs": "^7.8.2",
|
|
48
|
+
"typescript": "~5.8.3"
|
|
49
|
+
}
|
|
50
|
+
}
|