@daffodil/core 0.94.1 → 0.95.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.
@@ -1,57 +1,43 @@
1
- import * as i0 from '@angular/core';
2
- import { Injectable } from '@angular/core';
3
- import { throwError, of } from 'rxjs';
4
-
5
- /**
6
- * A service for loading external scripts into the document.
7
- *
8
- * @example Loading an external script into the document
9
- *
10
- * ```ts
11
- * import { DaffExternalScriptTestingService } from '@daffodil/core/external-script/testing';
12
- *
13
- * const externalScriptService = new DaffExternalScriptTestingService();
14
- *
15
- * externalScriptService.load(TestScripts.SUCCESS, {
16
- * src: 'https://example.com/script.js',
17
- * async: true,
18
- * defer: false,
19
- * 'data-custom-attribute': 'value',
20
- * }).subscribe({
21
- * next: (result) => {
22
- * console.log('Script loaded successfully:', result);
23
- * },
24
- * error: (error) => {
25
- * console.error('Error loading script:', error);
26
- * },
27
- * });
28
- * ```
29
- */
30
- class DaffExternalScriptTestingService {
31
- /**
32
- * @inheritdoc
33
- */
34
- load(name, script) {
35
- switch (name) {
36
- case "0" /* TestScripts.SUCCESS */:
37
- return of(true);
38
- default:
39
- return throwError(() => new Error(`Failed to load ${script.src}`));
40
- }
41
- }
42
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffExternalScriptTestingService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
43
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffExternalScriptTestingService, providedIn: 'root' }); }
44
- }
45
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffExternalScriptTestingService, decorators: [{
46
- type: Injectable,
47
- args: [{
48
- providedIn: 'root',
49
- }]
50
- }] });
51
-
52
- /**
53
- * Generated bundle index. Do not edit.
54
- */
55
-
1
+ import * as i0 from "@angular/core";
2
+ import { Injectable } from "@angular/core";
3
+ import { of, throwError } from "rxjs";
4
+ var DaffExternalScriptTestingService = class DaffExternalScriptTestingService {
5
+ load(name, script) {
6
+ switch (name) {
7
+ case "0": return of(true);
8
+ default: return throwError(() => /* @__PURE__ */ new Error(`Failed to load ${script.src}`));
9
+ }
10
+ }
11
+ static {
12
+ this.ɵfac = i0.ɵɵngDeclareFactory({
13
+ minVersion: "12.0.0",
14
+ version: "22.2.4",
15
+ ngImport: i0,
16
+ type: DaffExternalScriptTestingService,
17
+ deps: [],
18
+ target: i0.ɵɵFactoryTarget.Injectable
19
+ });
20
+ }
21
+ static {
22
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
23
+ minVersion: "12.0.0",
24
+ version: "22.2.4",
25
+ ngImport: i0,
26
+ type: DaffExternalScriptTestingService,
27
+ providedIn: "root"
28
+ });
29
+ }
30
+ };
31
+ i0.ɵɵngDeclareClassMetadata({
32
+ minVersion: "12.0.0",
33
+ version: "22.2.4",
34
+ ngImport: i0,
35
+ type: DaffExternalScriptTestingService,
36
+ decorators: [{
37
+ type: Injectable,
38
+ args: [{ providedIn: "root" }]
39
+ }]
40
+ });
56
41
  export { DaffExternalScriptTestingService };
57
- //# sourceMappingURL=daffodil-core-external-script-testing.mjs.map
42
+
43
+ //# sourceMappingURL=daffodil-core-external-script-testing.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"daffodil-core-external-script-testing.mjs","sources":["../../../libs/core/external-script/testing/src/external-script.service.ts","../../../libs/core/external-script/testing/src/daffodil-core-external-script-testing.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport {\n Observable,\n of,\n throwError,\n} from 'rxjs';\n\nimport {\n DaffExternalScriptServiceInterface ,\n DaffExternalScript,\n} from '@daffodil/core/external-script';\n\nimport { TestScripts } from './constants';\n\n/**\n * A service for loading external scripts into the document.\n *\n * @example Loading an external script into the document\n *\n * ```ts\n * import { DaffExternalScriptTestingService } from '@daffodil/core/external-script/testing';\n *\n * const externalScriptService = new DaffExternalScriptTestingService();\n *\n * externalScriptService.load(TestScripts.SUCCESS, {\n * src: 'https://example.com/script.js',\n * async: true,\n * defer: false,\n * 'data-custom-attribute': 'value',\n * }).subscribe({\n * next: (result) => {\n * console.log('Script loaded successfully:', result);\n * },\n * error: (error) => {\n * console.error('Error loading script:', error);\n * },\n * });\n * ```\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffExternalScriptTestingService implements DaffExternalScriptServiceInterface {\n\n /**\n * @inheritdoc\n */\n load(name: string, script: DaffExternalScript): Observable<boolean> {\n switch(name) {\n case TestScripts.SUCCESS:\n return of(true);\n default:\n return throwError(() => new Error(`Failed to load ${ script.src }`));\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAcA;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;MAIU,gCAAgC,CAAA;AAE3C;;AAEG;IACH,IAAI,CAAC,IAAY,EAAE,MAA0B,EAAA;QAC3C,QAAO,IAAI;AACT,YAAA,KAAA,GAAA;AACE,gBAAA,OAAO,EAAE,CAAC,IAAI,CAAC;AACjB,YAAA;AACE,gBAAA,OAAO,UAAU,CAAC,MAAM,IAAI,KAAK,CAAC,CAAA,eAAA,EAAmB,MAAM,CAAC,GAAI,CAAA,CAAE,CAAC,CAAC;;IAE1E;iIAZW,gCAAgC,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAhC,uBAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,gCAAgC,cAF/B,MAAM,EAAA,CAAA,CAAA;;2FAEP,gCAAgC,EAAA,UAAA,EAAA,CAAA;kBAH5C,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;;ACzCD;;AAEG;;;;"}
1
+ {"version":3,"file":"daffodil-core-external-script-testing.mjs","names":[],"sources":["../../../libs/core/external-script/testing/src/external-script.service.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport {\n Observable,\n of,\n throwError,\n} from 'rxjs';\n\nimport {\n DaffExternalScriptServiceInterface ,\n DaffExternalScript,\n} from '@daffodil/core/external-script';\n\nimport { TestScripts } from './constants';\n\n/**\n * A service for loading external scripts into the document.\n *\n * @example Loading an external script into the document\n *\n * ```ts\n * import { DaffExternalScriptTestingService } from '@daffodil/core/external-script/testing';\n *\n * const externalScriptService = new DaffExternalScriptTestingService();\n *\n * externalScriptService.load(TestScripts.SUCCESS, {\n * src: 'https://example.com/script.js',\n * async: true,\n * defer: false,\n * 'data-custom-attribute': 'value',\n * }).subscribe({\n * next: (result) => {\n * console.log('Script loaded successfully:', result);\n * },\n * error: (error) => {\n * console.error('Error loading script:', error);\n * },\n * });\n * ```\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffExternalScriptTestingService implements DaffExternalScriptServiceInterface {\n\n /**\n * @inheritdoc\n */\n load(name: string, script: DaffExternalScript): Observable<boolean> {\n switch(name) {\n case TestScripts.SUCCESS:\n return of(true);\n default:\n return throwError(() => new Error(`Failed to load ${ script.src }`));\n }\n }\n}\n"],"mappings":";;;AA0CA,IAAa,mCAAb,MAAa,iCAAgC;CAK3C,KAAK,MAAc,QAA0B;EAC3C,QAAO,MAAP;GACE,KAAA,KACE,OAAO,GAAG,IAAI;GAChB,SACE,OAAO,iCAAiB,IAAI,MAAM,kBAAmB,OAAO,KAAM,CAAC;EACvE;CACF;CAZW;EAAA,KAAA,OAAA,GAAA,mBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAAgC,MAAA,CAAA;GAAA,QAAA,GAAA,gBAAA;EAAA,CAAA;CAAA;CAAhC;EAAA,KAAA,QAAA,GAAA,sBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAAgC,YAF/B;EAAM,CAAA;CAAA;;AAEP,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAgC,YAAA,CAAA;EAH5C,MAAA;EAAW,MAAA,CAAA,EACV,YAAY,OACb,CAAA"}
@@ -1,96 +1,78 @@
1
- import * as i0 from '@angular/core';
2
- import { DOCUMENT, Inject, Injectable } from '@angular/core';
3
- import { BehaviorSubject } from 'rxjs';
4
- import { filter } from 'rxjs/operators';
5
-
6
- /**
7
- * A service for loading external scripts into the document.
8
- *
9
- * ### Usage example
10
- *
11
- * @example Loading an external script into the document
12
- *
13
- * ```ts
14
- * import { DOCUMENT } from '@angular/common';
15
- * import { inject } from '@angular/core';
16
- *
17
- * import { DaffExternalScriptService } from '@daffodil/core/external-script';
18
- *
19
- * const externalScriptService = new DaffExternalScriptService(inject(DOCUMENT));
20
- *
21
- * externalScriptService.load('exampleScript', {
22
- * src: 'https://example.com/script.js',
23
- * async: true,
24
- * defer: false,
25
- * 'data-custom-attribute': 'value',
26
- * }).subscribe({
27
- * next: (result) => {
28
- * console.log('Script loaded successfully:', result);
29
- * },
30
- * error: (error) => {
31
- * console.error('Error loading script:', error);
32
- * },
33
- * });
34
- * ```
35
- */
36
- class DaffExternalScriptService {
37
- constructor(doc) {
38
- this.scriptMap = new Map();
39
- this.doc = doc;
40
- }
41
- /**
42
- * @inheritdoc
43
- */
44
- load(name, script) {
45
- // Don't load the same script twice.
46
- if (this.scriptMap.has(name)) {
47
- return this.scriptMap.get(name).subject;
48
- }
49
- const scriptEl = this.doc.createElement('script');
50
- scriptEl.setAttribute('type', 'text/javascript');
51
- scriptEl.setAttribute('src', script.src);
52
- scriptEl.setAttribute('charset', 'utf-8');
53
- // Set custom attributes prefixed with 'data-'.
54
- Object.keys(script).filter(key => key.startsWith('data-')).map((key) => {
55
- // setAttribute would lowercase the value of "key", which isn't always correct.
56
- // setAttributeNS maintains key casing.
57
- scriptEl.setAttributeNS(null, key, script[key]);
58
- });
59
- if (script.async) {
60
- scriptEl.async = true;
61
- }
62
- if (script.defer) {
63
- scriptEl.defer = true;
64
- }
65
- const readySubject = new BehaviorSubject(undefined);
66
- scriptEl.onload = () => {
67
- this.scriptMap.get(name).ready = true;
68
- readySubject.next(true);
69
- };
70
- scriptEl.onerror = () => {
71
- this.scriptMap.get(name).ready = false;
72
- readySubject.error(new Error(`Failed to load ${script.src}`));
73
- };
74
- this.doc.body.appendChild(scriptEl);
75
- this.scriptMap.set(name, { ...script, ready: undefined, subject: readySubject, el: scriptEl });
76
- return readySubject.pipe(filter((s) => s !== undefined));
77
- }
78
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffExternalScriptService, deps: [{ token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable }); }
79
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffExternalScriptService, providedIn: 'root' }); }
80
- }
81
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffExternalScriptService, decorators: [{
82
- type: Injectable,
83
- args: [{
84
- providedIn: 'root',
85
- }]
86
- }], ctorParameters: () => [{ type: undefined, decorators: [{
87
- type: Inject,
88
- args: [DOCUMENT]
89
- }] }] });
90
-
91
- /**
92
- * Generated bundle index. Do not edit.
93
- */
94
-
1
+ import * as i0 from "@angular/core";
2
+ import { DOCUMENT, Inject, Injectable } from "@angular/core";
3
+ import { BehaviorSubject } from "rxjs";
4
+ import { filter } from "rxjs/operators";
5
+ var DaffExternalScriptService = class DaffExternalScriptService {
6
+ constructor(doc) {
7
+ this.scriptMap = /* @__PURE__ */ new Map();
8
+ this.doc = doc;
9
+ }
10
+ load(name, script) {
11
+ if (this.scriptMap.has(name)) return this.scriptMap.get(name).subject;
12
+ const scriptEl = this.doc.createElement("script");
13
+ scriptEl.setAttribute("type", "text/javascript");
14
+ scriptEl.setAttribute("src", script.src);
15
+ scriptEl.setAttribute("charset", "utf-8");
16
+ Object.keys(script).filter((key) => key.startsWith("data-")).map((key) => {
17
+ scriptEl.setAttributeNS(null, key, script[key]);
18
+ });
19
+ if (script.async) scriptEl.async = true;
20
+ if (script.defer) scriptEl.defer = true;
21
+ const readySubject = new BehaviorSubject(void 0);
22
+ scriptEl.onload = () => {
23
+ this.scriptMap.get(name).ready = true;
24
+ readySubject.next(true);
25
+ };
26
+ scriptEl.onerror = () => {
27
+ this.scriptMap.get(name).ready = false;
28
+ readySubject.error(/* @__PURE__ */ new Error(`Failed to load ${script.src}`));
29
+ };
30
+ this.doc.body.appendChild(scriptEl);
31
+ this.scriptMap.set(name, {
32
+ ...script,
33
+ ready: void 0,
34
+ subject: readySubject,
35
+ el: scriptEl
36
+ });
37
+ return readySubject.pipe(filter((s) => s !== void 0));
38
+ }
39
+ static {
40
+ this.ɵfac = i0.ɵɵngDeclareFactory({
41
+ minVersion: "12.0.0",
42
+ version: "22.2.4",
43
+ ngImport: i0,
44
+ type: DaffExternalScriptService,
45
+ deps: [{ token: DOCUMENT }],
46
+ target: i0.ɵɵFactoryTarget.Injectable
47
+ });
48
+ }
49
+ static {
50
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
51
+ minVersion: "12.0.0",
52
+ version: "22.2.4",
53
+ ngImport: i0,
54
+ type: DaffExternalScriptService,
55
+ providedIn: "root"
56
+ });
57
+ }
58
+ };
59
+ i0.ɵɵngDeclareClassMetadata({
60
+ minVersion: "12.0.0",
61
+ version: "22.2.4",
62
+ ngImport: i0,
63
+ type: DaffExternalScriptService,
64
+ decorators: [{
65
+ type: Injectable,
66
+ args: [{ providedIn: "root" }]
67
+ }],
68
+ ctorParameters: () => [{
69
+ type: void 0,
70
+ decorators: [{
71
+ type: Inject,
72
+ args: [DOCUMENT]
73
+ }]
74
+ }]
75
+ });
95
76
  export { DaffExternalScriptService };
96
- //# sourceMappingURL=daffodil-core-external-script.mjs.map
77
+
78
+ //# sourceMappingURL=daffodil-core-external-script.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"daffodil-core-external-script.mjs","sources":["../../../libs/core/external-script/src/external-script.service.ts","../../../libs/core/external-script/src/daffodil-core-external-script.ts"],"sourcesContent":["\nimport {\n Inject,\n Injectable,\n DOCUMENT,\n} from '@angular/core';\nimport {\n BehaviorSubject,\n Observable,\n} from 'rxjs';\nimport { filter } from 'rxjs/operators';\n\nimport { DaffExternalScriptServiceInterface } from './interface';\nimport { DaffExternalScript } from './script';\n\nexport interface LoadedExternalScript extends DaffExternalScript {\n ready: boolean | undefined;\n subject: Observable<boolean>;\n el: HTMLElement | undefined;\n}\n\n/**\n * A service for loading external scripts into the document.\n *\n * ### Usage example\n *\n * @example Loading an external script into the document\n *\n * ```ts\n * import { DOCUMENT } from '@angular/common';\n * import { inject } from '@angular/core';\n *\n * import { DaffExternalScriptService } from '@daffodil/core/external-script';\n *\n * const externalScriptService = new DaffExternalScriptService(inject(DOCUMENT));\n *\n * externalScriptService.load('exampleScript', {\n * src: 'https://example.com/script.js',\n * async: true,\n * defer: false,\n * 'data-custom-attribute': 'value',\n * }).subscribe({\n * next: (result) => {\n * console.log('Script loaded successfully:', result);\n * },\n * error: (error) => {\n * console.error('Error loading script:', error);\n * },\n * });\n * ```\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffExternalScriptService implements DaffExternalScriptServiceInterface {\n readonly scriptMap: Map<string, LoadedExternalScript> = new Map();\n private doc: Document;\n\n constructor(\n @Inject(DOCUMENT) doc,\n ) {\n this.doc = doc;\n }\n\n /**\n * @inheritdoc\n */\n load(name: string, script: DaffExternalScript): Observable<boolean> {\n // Don't load the same script twice.\n if(this.scriptMap.has(name)){\n return this.scriptMap.get(name).subject;\n }\n\n const scriptEl = this.doc.createElement('script');\n\n scriptEl.setAttribute('type', 'text/javascript');\n\n scriptEl.setAttribute('src', script.src);\n\n scriptEl.setAttribute('charset', 'utf-8');\n\n // Set custom attributes prefixed with 'data-'.\n Object.keys(script).filter(key => key.startsWith('data-')).map((key) => {\n // setAttribute would lowercase the value of \"key\", which isn't always correct.\n // setAttributeNS maintains key casing.\n scriptEl.setAttributeNS(null, key,script[key]);\n });\n\n if(script.async) {\n scriptEl.async = true;\n }\n\n if(script.defer) {\n scriptEl.defer = true;\n }\n\n const readySubject = new BehaviorSubject<boolean | undefined>(undefined);\n\n scriptEl.onload = () => {\n this.scriptMap.get(name).ready = true;\n readySubject.next(true);\n };\n\n scriptEl.onerror = () => {\n this.scriptMap.get(name).ready = false;\n readySubject.error(new Error(`Failed to load ${ script.src }`));\n };\n\n this.doc.body.appendChild(scriptEl);\n this.scriptMap.set(name, { ...script, ready: undefined, subject: readySubject, el: scriptEl });\n\n return readySubject.pipe(\n filter((s) => s !== undefined),\n );\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAqBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BG;MAIU,yBAAyB,CAAA;AAIpC,IAAA,WAAA,CACoB,GAAG,EAAA;AAJd,QAAA,IAAA,CAAA,SAAS,GAAsC,IAAI,GAAG,EAAE;AAM/D,QAAA,IAAI,CAAC,GAAG,GAAG,GAAG;IAChB;AAEA;;AAEG;IACH,IAAI,CAAC,IAAY,EAAE,MAA0B,EAAA;;QAE3C,IAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAC;YAC1B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,OAAO;QACzC;QAEA,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC;AAEjD,QAAA,QAAQ,CAAC,YAAY,CAAC,MAAM,EAAE,iBAAiB,CAAC;QAEhD,QAAQ,CAAC,YAAY,C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EAAE,YAAY,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC;AAE9F,QAAA,OAAO,YAAY,CAAC,IAAI,CACtB,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,SAAS,CAAC,CAC/B;IACH;AA5DW,uBAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,kBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,yBAAyB,kBAK1B,QAAQ,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AALP,uBAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,yBAAyB,cAFxB,MAAM,EAAA,CAAA,CAAA;;2FAEP,yBAAyB,EAAA,UAAA,EAAA,CAAA;kBAHrC,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;0BAMI,MAAM;2BAAC,QAAQ;;;AC3DpB;;AAEG;;;;"}
1
+ {"version":3,"file":"daffodil-core-external-script.mjs","names":[],"sources":["../../../libs/core/external-script/src/external-script.service.ts"],"sourcesContent":["\nimport {\n Inject,\n Injectable,\n DOCUMENT,\n} from '@angular/core';\nimport {\n BehaviorSubject,\n Observable,\n} from 'rxjs';\nimport { filter } from 'rxjs/operators';\n\nimport { DaffExternalScriptServiceInterface } from './interface';\nimport { DaffExternalScript } from './script';\n\nexport interface LoadedExternalScript extends DaffExternalScript {\n ready: boolean | undefined;\n subject: Observable<boolean>;\n el: HTMLElement | undefined;\n}\n\n/**\n * A service for loading external scripts into the document.\n *\n * ### Usage example\n *\n * @example Loading an external script into the document\n *\n * ```ts\n * import { DOCUMENT } from '@angular/common';\n * import { inject } from '@angular/core';\n *\n * import { DaffExternalScriptService } from '@daffodil/core/external-script';\n *\n * const externalScriptService = new DaffExternalScriptService(inject(DOCUMENT));\n *\n * externalScriptService.load('exampleScript', {\n * src: 'https://example.com/script.js',\n * async: true,\n * defer: false,\n * 'data-custom-attribute': 'value',\n * }).subscribe({\n * next: (result) => {\n * console.log('Script loaded successfully:', result);\n * },\n * error: (error) => {\n * console.error('Error loading script:', error);\n * },\n * });\n * ```\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffExternalScriptService implements DaffExternalScriptServiceInterface {\n readonly scriptMap: Map<string, LoadedExternalScript> = new Map();\n private doc: Document;\n\n constructor(\n @Inject(DOCUMENT) doc,\n ) {\n this.doc = doc;\n }\n\n /**\n * @inheritdoc\n */\n load(name: string, script: DaffExternalScript): Observable<boolean> {\n // Don't load the same script twice.\n if(this.scriptMap.has(name)){\n return this.scriptMap.get(name).subject;\n }\n\n const scriptEl = this.doc.createElement('script');\n\n scriptEl.setAttribute('type', 'text/javascript');\n\n scriptEl.setAttribute('src', script.src);\n\n scriptEl.setAttribute('charset', 'utf-8');\n\n // Set custom attributes prefixed with 'data-'.\n Object.keys(script).filter(key => key.startsWith('data-')).map((key) => {\n // setAttribute would lowercase the value of \"key\", which isn't always correct.\n // setAttributeNS maintains key casing.\n scriptEl.setAttributeNS(null, key,script[key]);\n });\n\n if(script.async) {\n scriptEl.async = true;\n }\n\n if(script.defer) {\n scriptEl.defer = true;\n }\n\n const readySubject = new BehaviorSubject<boolean | undefined>(undefined);\n\n scriptEl.onload = () => {\n this.scriptMap.get(name).ready = true;\n readySubject.next(true);\n };\n\n scriptEl.onerror = () => {\n this.scriptMap.get(name).ready = false;\n readySubject.error(new Error(`Failed to load ${ script.src }`));\n };\n\n this.doc.body.appendChild(scriptEl);\n this.scriptMap.set(name, { ...script, ready: undefined, subject: readySubject, el: scriptEl });\n\n return readySubject.pipe(\n filter((s) => s !== undefined),\n );\n }\n}\n"],"mappings":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;CAAA;CALP;EAAA,KAAA,QAAA,GAAA,sBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAAyB,YAFxB;EAAM,CAAA;CAAA;;AAEP,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAyB,YAAA,CAAA;EAHrC,MAAA;EAAW,MAAA,CAAA,EACV,YAAY,OACb,CAAA;;;;;GAMI,MAAA;GAAO,MAAA,CAAA,QAAQ"}
@@ -1,150 +1,99 @@
1
- import { unique, createMultiInjectionToken } from '@daffodil/core';
2
- import * as i0 from '@angular/core';
3
- import { Injectable, makeEnvironmentProviders, inject, Injector, runInInjectionContext } from '@angular/core';
4
- import * as i1 from 'apollo-angular';
5
- import { Observable } from 'rxjs';
6
- import { HttpHeaders } from '@angular/common/http';
7
-
8
- const getFragmentNames = (fragment) => fragment.definitions.filter(def => def.kind === 'FragmentDefinition').map(def => def.name.value);
9
- /**
10
- * Builds a list of the first fragment name present inside the specified GraphQL document nodes.
11
- * Returns an empty array if no fragments have been defined or if null is passed.
12
- *
13
- * @param fragments The created fragments.
14
- */
1
+ import { createMultiInjectionToken, unique } from "@daffodil/core";
2
+ import * as i0 from "@angular/core";
3
+ import { Injectable, Injector, inject, makeEnvironmentProviders, runInInjectionContext } from "@angular/core";
4
+ import * as i1 from "apollo-angular";
5
+ import { Observable } from "rxjs";
6
+ import { HttpHeaders } from "@angular/common/http";
7
+ const getFragmentNames = (fragment) => fragment.definitions.filter((def) => def.kind === "FragmentDefinition").map((def) => def.name.value);
15
8
  const daffGetFragmentNames = (...fragments) => fragments.reduce((acc, fragment) => {
16
- const names = getFragmentNames(fragment);
17
- if (names[0]) {
18
- acc.push(names[0]);
19
- }
20
- return acc;
9
+ const names = getFragmentNames(fragment);
10
+ if (names[0]) acc.push(names[0]);
11
+ return acc;
21
12
  }, []);
22
- /**
23
- * Builds a string of fragment names that can be interpolated into a GraphQL query.
24
- * Each name is separated by a newline character: '\n'.
25
- * If an empty array is passed, an empty string is returned.
26
- * Only the first fragment name from each passed fragment is returned.
27
- *
28
- * @param fragments A list of GraphQL documents that contain fragments.
29
- */
30
- const daffBuildFragmentNameSpread = (...fragments) => unique(daffGetFragmentNames(...fragments)).reduce((acc, name) => acc.concat(`...${name}\n`), '');
31
-
32
- /**
33
- * Builds a string of fragment definitions that can be interpolated into a GraphQL query.
34
- * Each definition is separated by a newline character: '\n'.
35
- *
36
- * @param documents A list of GraphQL documents that should only contain fragments.
37
- */
38
- const daffBuildFragmentDefinition = (...documents) => documents.reduce((acc, fragment) => acc.concat(`${fragment.loc.source.body}\n`), '');
39
-
40
- /**
41
- * A service that will queue mutate calls to Apollo.
42
- * It will not send subsequent mutate requests until the previous one has been completed.
43
- * This is useful for avoiding race conditions on the backend.
44
- * This should be used alongside Apollo.
45
- */
46
- class DaffQueuedApollo {
47
- constructor(apollo) {
48
- this.apollo = apollo;
49
- this.queue = [];
50
- }
51
- /**
52
- * Queue up a mutate request.
53
- * The request will not actually be queued until the returned observable is subscribed.
54
- * If the queue is empty, the request will be sent when it enters the queue.
55
- * Otherwise, it will be sent when it reaches the front of the queue.
56
- * The observable will complete after it emits once.
57
- *
58
- * @param options Mutation options.
59
- */
60
- mutate(options) {
61
- return new Observable(subscriber => this.addRequestToQueue(subscriber, this.apollo.mutate(options)));
62
- }
63
- addRequestToQueue(subscriber, request) {
64
- this.queue.push(() => {
65
- const sub = request.subscribe({
66
- next: response => {
67
- // emit the outer observable
68
- subscriber.next(response);
69
- subscriber.complete();
70
- this.finishRequestSubscription(sub);
71
- },
72
- error: error => {
73
- subscriber.error(error);
74
- this.finishRequestSubscription(sub);
75
- },
76
- complete: () => {
77
- subscriber.complete();
78
- this.finishRequestSubscription(sub);
79
- },
80
- });
81
- });
82
- // start the queue if previously empty
83
- if (this.queue.length === 1) {
84
- this.queue[0]();
85
- }
86
- }
87
- finishRequestSubscription(requestSubscription) {
88
- requestSubscription.unsubscribe();
89
- // process queue
90
- this.queue.shift();
91
- this.queue[0]?.();
92
- }
93
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffQueuedApollo, deps: [{ token: i1.Apollo }], target: i0.ɵɵFactoryTarget.Injectable }); }
94
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffQueuedApollo, providedIn: 'root' }); }
95
- }
96
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffQueuedApollo, decorators: [{
97
- type: Injectable,
98
- args: [{
99
- providedIn: 'root',
100
- }]
101
- }], ctorParameters: () => [{ type: i1.Apollo }] });
102
-
103
- const {
104
- /**
105
- * Apollo request handlers. Allow custom logic to be injected into the apollo link chain.
106
- */
107
- token: DAFF_APOLLO_REQUEST_HANDLERS,
108
- /**
109
- * Provider for {@link DAFF_APOLLO_REQUEST_HANDLERS}.
110
- */
111
- provider: provideDaffApolloRequestHandlers,
112
- /**
113
- * Factory provider for {@link DAFF_APOLLO_REQUEST_HANDLERS}.
114
- */
115
- factoryProvider: provideDaffApolloRequestHandlerFactories, } = createMultiInjectionToken('DAFF_APOLLO_REQUEST_HANDLERS');
116
-
13
+ const daffBuildFragmentNameSpread = (...fragments) => unique(daffGetFragmentNames(...fragments)).reduce((acc, name) => acc.concat(`...${name}\n`), "");
14
+ const daffBuildFragmentDefinition = (...documents) => documents.reduce((acc, fragment) => acc.concat(`${fragment.loc.source.body}\n`), "");
15
+ var DaffQueuedApollo = class DaffQueuedApollo {
16
+ constructor(apollo) {
17
+ this.apollo = apollo;
18
+ this.queue = [];
19
+ }
20
+ mutate(options) {
21
+ return new Observable((subscriber) => this.addRequestToQueue(subscriber, this.apollo.mutate(options)));
22
+ }
23
+ addRequestToQueue(subscriber, request) {
24
+ this.queue.push(() => {
25
+ const sub = request.subscribe({
26
+ next: (response) => {
27
+ subscriber.next(response);
28
+ subscriber.complete();
29
+ this.finishRequestSubscription(sub);
30
+ },
31
+ error: (error) => {
32
+ subscriber.error(error);
33
+ this.finishRequestSubscription(sub);
34
+ },
35
+ complete: () => {
36
+ subscriber.complete();
37
+ this.finishRequestSubscription(sub);
38
+ }
39
+ });
40
+ });
41
+ if (this.queue.length === 1) this.queue[0]();
42
+ }
43
+ finishRequestSubscription(requestSubscription) {
44
+ requestSubscription.unsubscribe();
45
+ this.queue.shift();
46
+ this.queue[0]?.();
47
+ }
48
+ static {
49
+ this.ɵfac = i0.ɵɵngDeclareFactory({
50
+ minVersion: "12.0.0",
51
+ version: "22.2.4",
52
+ ngImport: i0,
53
+ type: DaffQueuedApollo,
54
+ deps: [{ token: i1.Apollo }],
55
+ target: i0.ɵɵFactoryTarget.Injectable
56
+ });
57
+ }
58
+ static {
59
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
60
+ minVersion: "12.0.0",
61
+ version: "22.2.4",
62
+ ngImport: i0,
63
+ type: DaffQueuedApollo,
64
+ providedIn: "root"
65
+ });
66
+ }
67
+ };
68
+ i0.ɵɵngDeclareClassMetadata({
69
+ minVersion: "12.0.0",
70
+ version: "22.2.4",
71
+ ngImport: i0,
72
+ type: DaffQueuedApollo,
73
+ decorators: [{
74
+ type: Injectable,
75
+ args: [{ providedIn: "root" }]
76
+ }],
77
+ ctorParameters: () => [{ type: i1.Apollo }]
78
+ });
79
+ const { token: DAFF_APOLLO_REQUEST_HANDLERS, provider: provideDaffApolloRequestHandlers, factoryProvider: provideDaffApolloRequestHandlerFactories } = createMultiInjectionToken("DAFF_APOLLO_REQUEST_HANDLERS");
117
80
  function getApolloOperationHeaders(operation) {
118
- return operation.getContext().headers || new HttpHeaders();
81
+ return operation.getContext().headers || new HttpHeaders();
119
82
  }
120
-
121
- /**
122
- * Provider function for {@link DaffApolloHeaderProvider}s.
123
- */
124
- const provideDaffApolloHeaderProviders = (...providers) => makeEnvironmentProviders([
125
- provideDaffApolloRequestHandlerFactories(() => {
126
- const injector = inject(Injector);
127
- return (operation, forward) => {
128
- operation.setContext({
129
- headers: providers.reduce((acc, provider) => {
130
- const headers = runInInjectionContext(injector, provider);
131
- return headers.keys().reduce((a, key) => {
132
- const val = headers.getAll(key);
133
- if (val) {
134
- return acc.append(key, val);
135
- }
136
- return a;
137
- }, acc);
138
- }, getApolloOperationHeaders(operation)),
139
- });
140
- return forward(operation);
141
- };
142
- }),
143
- ]);
144
-
145
- /**
146
- * Generated bundle index. Do not edit.
147
- */
148
-
83
+ const provideDaffApolloHeaderProviders = (...providers) => makeEnvironmentProviders([provideDaffApolloRequestHandlerFactories(() => {
84
+ const injector = inject(Injector);
85
+ return (operation, forward) => {
86
+ operation.setContext({ headers: providers.reduce((acc, provider) => {
87
+ const headers = runInInjectionContext(injector, provider);
88
+ return headers.keys().reduce((a, key) => {
89
+ const val = headers.getAll(key);
90
+ if (val) return acc.append(key, val);
91
+ return a;
92
+ }, acc);
93
+ }, getApolloOperationHeaders(operation)) });
94
+ return forward(operation);
95
+ };
96
+ })]);
149
97
  export { DAFF_APOLLO_REQUEST_HANDLERS, DaffQueuedApollo, daffBuildFragmentDefinition, daffBuildFragmentNameSpread, getApolloOperationHeaders, provideDaffApolloHeaderProviders, provideDaffApolloRequestHandlerFactories, provideDaffApolloRequestHandlers };
150
- //# sourceMappingURL=daffodil-core-graphql.mjs.map
98
+
99
+ //# sourceMappingURL=daffodil-core-graphql.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"daffodil-core-graphql.mjs","sources":["../../../libs/core/graphql/src/fragments/build-fragment-name-spread.ts","../../../libs/core/graphql/src/fragments/build-fragment-definition.ts","../../../libs/core/graphql/src/apollo/queued-apollo/queued-apollo.service.ts","../../../libs/core/graphql/src/apollo/request-handler.provider.ts","../../../libs/core/graphql/src/apollo/header/get.ts","../../../libs/core/graphql/src/apollo/header/provider.ts","../../../libs/core/graphql/src/daffodil-core-graphql.ts"],"sourcesContent":["import {\n DocumentNode,\n FragmentDefinitionNode,\n} from 'graphql';\n\nimport { unique } from '@daffodil/core';\n\nexport const getFragmentNames = (fragment: DocumentNode) =>\n fragment.definitions.filter(def =>\n def.kind === 'FragmentDefinition',\n ).map(def =>\n (<FragmentDefinitionNode>def).name.value,\n );\n\n/**\n * Builds a list of the first fragment name present inside the specified GraphQL document nodes.\n * Returns an empty array if no fragments have been defined or if null is passed.\n *\n * @param fragments The created fragments.\n */\nconst daffGetFragmentNames = (...fragments: DocumentNode[]): string[] =>\n fragments.reduce((acc, fragment) => {\n const names = getFragmentNames(fragment);\n if (names[0]) {\n acc.push(names[0]);\n }\n return acc;\n }, []);\n\n/**\n * Builds a string of fragment names that can be interpolated into a GraphQL query.\n * Each name is separated by a newline character: '\\n'.\n * If an empty array is passed, an empty string is returned.\n * Only the first fragment name from each passed fragment is returned.\n *\n * @param fragments A list of GraphQL documents that contain fragments.\n */\nexport const daffBuildFragmentNameSpread = (...fragments: DocumentNode[]): string =>\n unique(daffGetFragmentNames(...fragments)).reduce((acc, name) => acc.concat(`...${name}\\n`), '');\n","import { DocumentNode } from 'graphql';\n\n/**\n * Builds a string of fragment definitions that can be interpolated into a GraphQL query.\n * Each definition is separated by a newline character: '\\n'.\n *\n * @param documents A list of GraphQL documents that should only contain fragments.\n */\nexport const daffBuildFragmentDefinition = (...documents: DocumentNode[]): string =>\n documents.reduce((acc, fragment) => acc.concat(`${fragment.loc.source.body}\\n`), '');\n","import { Injectable } from '@angular/core';\nimport { Apollo } from 'apollo-angular';\nimport {\n Observable,\n Subscriber,\n Subscription,\n} from 'rxjs';\n\n/**\n * A service that will queue mutate calls to Apollo.\n * It will not send subsequent mutate requests until the previous one has been completed.\n * This is useful for avoiding race conditions on the backend.\n * This should be used alongside Apollo.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffQueuedApollo {\n queue: (() => void)[] = [];\n\n constructor(\n private apollo: Apollo,\n ) {}\n\n /**\n * Queue up a mutate request.\n * The request will not actually be queued until the returned observable is subscribed.\n * If the queue is empty, the request will be sent when it enters the queue.\n * Otherwise, it will be sent when it reaches the front of the queue.\n * The observable will complete after it emits once.\n *\n * @param options Mutation options.\n */\n mutate<T, V = Record<string, any>>(options: Apollo.MutateOptions<T, V>): Observable<Apollo.MutateResult<T>> {\n return new Observable(subscriber => this.addRequestToQueue(subscriber, this.apollo.mutate(options)));\n }\n\n private addRequestToQueue(subscriber: Subscriber<any>, request: Observable<any>): void {\n this.queue.push(() => {\n const sub = request.subscribe({\n next: response => {\n // emit the outer observable\n subscriber.next(response);\n subscriber.complete();\n\n this.finishRequestSubscription(sub);\n },\n error: error => {\n subscriber.error(error);\n this.finishRequestSubscription(sub);\n },\n complete: () => {\n subscriber.complete();\n this.finishRequestSubscription(sub);\n },\n });\n });\n\n // start the queue if previously empty\n if (this.queue.length === 1) {\n this.queue[0]();\n }\n }\n\n private finishRequestSubscription(requestSubscription: Subscription): void {\n requestSubscription.unsubscribe();\n\n // process queue\n this.queue.shift();\n this.queue[0]?.();\n }\n}\n","import { ApolloLink } from '@apollo/client';\n\nimport { createMultiInjectionToken } from '@daffodil/core';\n\nexport const {\n /**\n * Apollo request handlers. Allow custom logic to be injected into the apollo link chain.\n */\n token: DAFF_APOLLO_REQUEST_HANDLERS,\n /**\n * Provider for {@link DAFF_APOLLO_REQUEST_HANDLERS}.\n */\n provider: provideDaffApolloRequestHandlers,\n /**\n * Factory provider for {@link DAFF_APOLLO_REQUEST_HANDLERS}.\n */\n factoryProvider: provideDaffApolloRequestHandlerFactories,\n} = createMultiInjectionToken<ApolloLink.RequestHandler>('DAFF_APOLLO_REQUEST_HANDLERS');\n","import { HttpHeaders } from '@angular/common/http';\nimport { ApolloLink } from '@apollo/client';\n\nexport function getApolloOperationHeaders(operation: ApolloLink.Operation): HttpHeaders {\n return operation.getContext().headers || new HttpHeaders();\n}\n","import {\n EnvironmentProviders,\n inject,\n Injector,\n makeEnvironmentProviders,\n runInInjectionContext,\n} from '@angular/core';\n\nimport { DaffApolloHeaderProvider } from './type';\nimport { provideDaffApolloRequestHandlerFactories } from '../request-handler.provider';\nimport { getApolloOperationHeaders } from './get';\n\n/**\n * Provider function for {@link DaffApolloHeaderProvider}s.\n */\nexport const provideDaffApolloHeaderProviders = (...providers: Array<DaffApolloHeaderProvider>): EnvironmentProviders =>\n makeEnvironmentProviders([\n provideDaffApolloRequestHandlerFactories(() => {\n const injector = inject(Injector);\n return (operation, forward) => {\n operation.setContext({\n headers: providers.reduce((acc, provider) => {\n const headers = runInInjectionContext(injector, provider);\n return headers.keys().reduce((a, key) => {\n const val = headers.getAll(key);\n if (val) {\n return acc.append(key, val);\n }\n return a;\n }, acc);\n }, getApolloOperationHeaders(operation)),\n });\n return forward(operation);\n };\n }),\n ]);\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAOO,MAAM,gBAAgB,GAAG,CAAC,QAAsB,KACrD,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,IAC7B,GAAG,CAAC,IAAI,KAAK,oBAAoB,CAClC,CAAC,GAAG,CAAC,GAAG,IACkB,GAAI,CAAC,IAAI,CAAC,KAAK,CACzC;AAEH;;;;;AAKG;AACH,MAAM,oBAAoB,GAAG,CAAC,GAAG,SAAyB,KACxD,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,QAAQ,KAAI;AACjC,IAAA,MAAM,KAAK,GAAG,gBAAgB,CAAC,QAAQ,CAAC;AACxC,IAAA,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE;QACZ,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACpB;AACA,IAAA,OAAO,GAAG;AACZ,CAAC,EAAE,EAAE,CAAC;AAER;;;;;;;AAOG;AACI,MAAM,2BAA2B,GAAG,CAAC,GAAG,SAAyB,KACtE,MAAM,CAAC,oBAAoB,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,KAAK,GA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AC5F,wBAAwB,CAAC;IACvB,wCAAwC,CAAC,MAAK;AAC5C,QAAA,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;AACjC,QAAA,OAAO,CAAC,SAAS,EAAE,OAAO,KAAI;YAC5B,SAAS,CAAC,UAAU,CAAC;gBACnB,OAAO,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,QAAQ,KAAI;oBAC1C,MAAM,OAAO,GAAG,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,CAAC;AACzD,oBAAA,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,KAAI;wBACtC,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC;wBAC/B,IAAI,GAAG,EAAE;4BACP,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC;wBAC7B;AACA,wBAAA,OAAO,CAAC;oBACV,CAAC,EAAE,GAAG,CAAC;AACT,gBAAA,CAAC,EAAE,yBAAyB,CAAC,SAAS,CAAC,CAAC;AACzC,aAAA,CAAC;AACF,YAAA,OAAO,OAAO,CAAC,SAAS,CAAC;AAC3B,QAAA,CAAC;AACH,IAAA,CAAC,CAAC;AACH,CAAA;;ACnCH;;AAEG;;;;"}
1
+ {"version":3,"file":"daffodil-core-graphql.mjs","names":[],"sources":["../../../libs/core/graphql/src/fragments/build-fragment-name-spread.ts","../../../libs/core/graphql/src/fragments/build-fragment-definition.ts","../../../libs/core/graphql/src/apollo/queued-apollo/queued-apollo.service.ts","../../../libs/core/graphql/src/apollo/request-handler.provider.ts","../../../libs/core/graphql/src/apollo/header/get.ts","../../../libs/core/graphql/src/apollo/header/provider.ts"],"sourcesContent":["import {\n DocumentNode,\n FragmentDefinitionNode,\n} from 'graphql';\n\nimport { unique } from '@daffodil/core';\n\nexport const getFragmentNames = (fragment: DocumentNode) =>\n fragment.definitions.filter(def =>\n def.kind === 'FragmentDefinition',\n ).map(def =>\n (<FragmentDefinitionNode>def).name.value,\n );\n\n/**\n * Builds a list of the first fragment name present inside the specified GraphQL document nodes.\n * Returns an empty array if no fragments have been defined or if null is passed.\n *\n * @param fragments The created fragments.\n */\nconst daffGetFragmentNames = (...fragments: DocumentNode[]): string[] =>\n fragments.reduce((acc, fragment) => {\n const names = getFragmentNames(fragment);\n if (names[0]) {\n acc.push(names[0]);\n }\n return acc;\n }, []);\n\n/**\n * Builds a string of fragment names that can be interpolated into a GraphQL query.\n * Each name is separated by a newline character: '\\n'.\n * If an empty array is passed, an empty string is returned.\n * Only the first fragment name from each passed fragment is returned.\n *\n * @param fragments A list of GraphQL documents that contain fragments.\n */\nexport const daffBuildFragmentNameSpread = (...fragments: DocumentNode[]): string =>\n unique(daffGetFragmentNames(...fragments)).reduce((acc, name) => acc.concat(`...${name}\\n`), '');\n","import { DocumentNode } from 'graphql';\n\n/**\n * Builds a string of fragment definitions that can be interpolated into a GraphQL query.\n * Each definition is separated by a newline character: '\\n'.\n *\n * @param documents A list of GraphQL documents that should only contain fragments.\n */\nexport const daffBuildFragmentDefinition = (...documents: DocumentNode[]): string =>\n documents.reduce((acc, fragment) => acc.concat(`${fragment.loc.source.body}\\n`), '');\n","import { Injectable } from '@angular/core';\nimport { Apollo } from 'apollo-angular';\nimport {\n Observable,\n Subscriber,\n Subscription,\n} from 'rxjs';\n\n/**\n * A service that will queue mutate calls to Apollo.\n * It will not send subsequent mutate requests until the previous one has been completed.\n * This is useful for avoiding race conditions on the backend.\n * This should be used alongside Apollo.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffQueuedApollo {\n queue: (() => void)[] = [];\n\n constructor(\n private apollo: Apollo,\n ) {}\n\n /**\n * Queue up a mutate request.\n * The request will not actually be queued until the returned observable is subscribed.\n * If the queue is empty, the request will be sent when it enters the queue.\n * Otherwise, it will be sent when it reaches the front of the queue.\n * The observable will complete after it emits once.\n *\n * @param options Mutation options.\n */\n mutate<T, V = Record<string, any>>(options: Apollo.MutateOptions<T, V>): Observable<Apollo.MutateResult<T>> {\n return new Observable(subscriber => this.addRequestToQueue(subscriber, this.apollo.mutate(options)));\n }\n\n private addRequestToQueue(subscriber: Subscriber<any>, request: Observable<any>): void {\n this.queue.push(() => {\n const sub = request.subscribe({\n next: response => {\n // emit the outer observable\n subscriber.next(response);\n subscriber.complete();\n\n this.finishRequestSubscription(sub);\n },\n error: error => {\n subscriber.error(error);\n this.finishRequestSubscription(sub);\n },\n complete: () => {\n subscriber.complete();\n this.finishRequestSubscription(sub);\n },\n });\n });\n\n // start the queue if previously empty\n if (this.queue.length === 1) {\n this.queue[0]();\n }\n }\n\n private finishRequestSubscription(requestSubscription: Subscription): void {\n requestSubscription.unsubscribe();\n\n // process queue\n this.queue.shift();\n this.queue[0]?.();\n }\n}\n","import { ApolloLink } from '@apollo/client';\n\nimport { createMultiInjectionToken } from '@daffodil/core';\n\nexport const {\n /**\n * Apollo request handlers. Allow custom logic to be injected into the apollo link chain.\n */\n token: DAFF_APOLLO_REQUEST_HANDLERS,\n /**\n * Provider for {@link DAFF_APOLLO_REQUEST_HANDLERS}.\n */\n provider: provideDaffApolloRequestHandlers,\n /**\n * Factory provider for {@link DAFF_APOLLO_REQUEST_HANDLERS}.\n */\n factoryProvider: provideDaffApolloRequestHandlerFactories,\n} = createMultiInjectionToken<ApolloLink.RequestHandler>('DAFF_APOLLO_REQUEST_HANDLERS');\n","import { HttpHeaders } from '@angular/common/http';\nimport { ApolloLink } from '@apollo/client';\n\nexport function getApolloOperationHeaders(operation: ApolloLink.Operation): HttpHeaders {\n return operation.getContext().headers || new HttpHeaders();\n}\n","import {\n EnvironmentProviders,\n inject,\n Injector,\n makeEnvironmentProviders,\n runInInjectionContext,\n} from '@angular/core';\n\nimport { DaffApolloHeaderProvider } from './type';\nimport { provideDaffApolloRequestHandlerFactories } from '../request-handler.provider';\nimport { getApolloOperationHeaders } from './get';\n\n/**\n * Provider function for {@link DaffApolloHeaderProvider}s.\n */\nexport const provideDaffApolloHeaderProviders = (...providers: Array<DaffApolloHeaderProvider>): EnvironmentProviders =>\n makeEnvironmentProviders([\n provideDaffApolloRequestHandlerFactories(() => {\n const injector = inject(Injector);\n return (operation, forward) => {\n operation.setContext({\n headers: providers.reduce((acc, provider) => {\n const headers = runInInjectionContext(injector, provider);\n return headers.keys().reduce((a, key) => {\n const val = headers.getAll(key);\n if (val) {\n return acc.append(key, val);\n }\n return a;\n }, acc);\n }, getApolloOperationHeaders(operation)),\n });\n return forward(operation);\n };\n }),\n ]);\n"],"mappings":";;;;;;AAOA,MAAa,oBAAoB,aAC/B,SAAS,YAAY,QAAO,QAC1B,IAAI,SAAS,oBAAoB,CAClC,CAAC,KAAI,QACqB,IAAK,KAAK,KAAK;AAS5C,MAAM,wBAAwB,GAAG,cAC/B,UAAU,QAAQ,KAAK,aAAY;CACjC,MAAM,QAAQ,iBAAiB,QAAQ;CACvC,IAAI,MAAM,IACR,IAAI,KAAK,MAAM,EAAE;CAEnB,OAAO;AACT,GAAG,CAAA,CAAE;AAUP,MAAa,+BAA+B,GAAG,cAC7C,OAAO,qBAAqB,GAAG,SAAS,CAAC,CAAC,CAAC,QAAQ,KAAK,SAAS,IAAI,OAAO,MAAM,KAAI,GAAI,GAAG,EAAE;AC9BjG,MAAa,+BAA+B,GAAG,cAC7C,UAAU,QAAQ,KAAK,aAAa,IAAI,OAAO,GAAG,SAAS,IAAI,OAAO,KAAI,GAAI,GAAG,EAAE;ACQrF,IAAa,mBAAb,MAAa,iBAAgB;CAG3B,YACU,QAAc;EAAd,KAAA,SAAA;EAHV,KAAA,QAAwB,CAAA;CAIrB;CAWH,OAAmC,SAAmC;EACpE,OAAO,IAAI,YAAW,eAAc,KAAK,kBAAkB,YAAY,KAAK,OAAO,OAAO,OAAO,CAAC,CAAC;CACrG;CAEQ,kBAAkB,YAA6B,SAAwB;EAC7E,KAAK,MAAM,WAAU;GACnB,MAAM,MAAM,QAAQ,UAAU;IAC5B,OAAM,aAAW;KAEf,W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