MCPcopy
hub / github.com/ampproject/amphtml / constructor

Method constructor

extensions/amp-access/0.1/amp-access.js:42–140  ·  view source on GitHub ↗

* @param {!../../../src/service/ampdoc-impl.AmpDoc} ampdoc

(ampdoc)

Source from the content-addressed store, hash-verified

40 * @param {!../../../src/service/ampdoc-impl.AmpDoc} ampdoc
41 */
42 constructor(ampdoc) {
43 /** @const */
44 this.ampdoc = ampdoc;
45
46 // Install styles.
47 installStylesForDoc(ampdoc, CSS, () => {}, false, TAG);
48
49 const accessElement = ampdoc.getElementById('amp-access');
50
51 /** @private {boolean} */
52 this.enabled_ = !!accessElement;
53 if (!this.enabled_) {
54 return;
55 }
56
57 /** @const @private {!Element} */
58 this.accessElement_ = dev().assertElement(accessElement);
59
60 /** @const @private {string} */
61 this.pubOrigin_ = getSourceOrigin(ampdoc.win.location);
62
63 /** @const @private {!../../../src/service/timer-impl.Timer} */
64 this.timer_ = Services.timerFor(ampdoc.win);
65
66 /** @private @const {!../../../src/service/vsync-impl.Vsync} */
67 this.vsync_ = Services.vsyncFor(ampdoc.win);
68
69 // TODO(dvoytenko, #3742): This will refer to the ampdoc once AccessService
70 // is migrated to ampdoc as well.
71 /** @private @const {!Promise<!../../../src/service/cid-impl.CidDef>} */
72 this.cid_ = Services.cidForDoc(ampdoc);
73
74 /** @private @const {!../../../src/service/viewer-interface.ViewerInterface} */
75 this.viewer_ = Services.viewerForDoc(ampdoc);
76
77 /** @private @const {!../../../src/service/viewport/viewport-interface.ViewportInterface} */
78 this.viewport_ = Services.viewportForDoc(ampdoc);
79
80 /** @private @const {!../../../src/service/template-impl.Templates} */
81 this.templates_ = Services.templatesForDoc(ampdoc);
82
83 /** @private @const {!../../../src/service/mutator-interface.MutatorInterface} */
84 this.mutator_ = Services.mutatorForDoc(ampdoc);
85
86 /** @private @const {?../../../src/service/performance-impl.Performance} */
87 this.performance_ = Services.performanceForOrNull(ampdoc.win);
88
89 /** @private {?Promise<string>} */
90 this.readerIdPromise_ = null;
91
92 /** @private {!./access-expr.AmpAccessEvaluator} */
93 this.evaluator_ = new AmpAccessEvaluator();
94
95 /** @const */
96 this.sources_ = this.parseConfig_();
97
98 const promises = this.sources_.map((source) =>
99 source.whenFirstAuthorized()

Callers

nothing calls this directly

Calls 14

parseConfig_Method · 0.95
analyticsEvent_Method · 0.95
installStylesForDocFunction · 0.90
devFunction · 0.90
getSourceOriginFunction · 0.90
assertElementMethod · 0.80
whenFirstAuthorizedMethod · 0.80
tickMethod · 0.80
tickSinceVisibleMethod · 0.80
flushMethod · 0.80
getElementByIdMethod · 0.45
thenMethod · 0.45

Tested by

no test coverage detected