Skip to content

Commit

Permalink
♻️ Move files into #core, #utils to enable tsc typechecking (ampproje…
Browse files Browse the repository at this point in the history
…ct#36277)

* Add #utils path alias

* Move format/analytics/animation/event-hepler/log into #util/core

* update imports of log => #utils/log

* update imports of format => #core/document/format

* Update imports of event-helper

* Update imports of analytics

* Update imports of animation

* lint autofix

* Update forbidden-terms

* Move #core/document-{ready,visibility} to #core/document/{ready,visibility}

* Update imports of #core/document-{ready,visibility}

* Fix imports in #core/document/visibility

* Move test files to reflect new structure

* Lint fixes

* Lint fixes to babel plugins

* Fix babel plugin paths

* Fix babel plugin paths

* Fix dep-check config

* Fix type-check shame

* Typo
  • Loading branch information
rcebulko authored Oct 7, 2021
1 parent 4d1be4e commit b6d1550
Show file tree
Hide file tree
Showing 665 changed files with 1,235 additions and 958 deletions.
4 changes: 2 additions & 2 deletions 3p/3d-gltf/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import {listenParent, nonSensitiveDataPostMessage} from '#3p/messaging';
import {dict} from '#core/types/object';
import {parseJson} from '#core/types/object/json';

import GltfViewer from './viewer';
import {user} from '#utils/log';

import {user} from '../../src/log';
import GltfViewer from './viewer';

const seq = (taskA, taskB) => (cb) => taskA(() => taskB(cb));
const parallel = (taskA, taskB) => (cb) => {
Expand Down
2 changes: 1 addition & 1 deletion 3p/3p.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {rethrowAsync} from '#core/error';
import {isArray} from '#core/types';
import {hasOwn, map} from '#core/types/object';

import {devAssert, userAssert} from '../src/log';
import {devAssert, userAssert} from '#utils/log';

/** @typedef {function(!Window, !Object)} */
let ThirdPartyFunctionDef;
Expand Down
4 changes: 2 additions & 2 deletions 3p/ampcontext-integration.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {dict} from '#core/types/object';

import {dev, user, userAssert} from '#utils/log';

import {computeInMasterFrame} from './3p';
import {AbstractAmpContext} from './ampcontext';

import {dev, user, userAssert} from '../src/log';

/**
* Returns the "master frame" for all widgets of a given type.
* This frame should be used to e.g. fetch scripts that can
Expand Down
4 changes: 2 additions & 2 deletions 3p/ampcontext-lib.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// src/polyfills.js must be the first import.
import './polyfills';

import {AmpContext} from './ampcontext';
import {initLogConstructor, setReportError} from '#utils/log';

import {initLogConstructor, setReportError} from '../src/log';
import {AmpContext} from './ampcontext';

initLogConstructor();

Expand Down
3 changes: 2 additions & 1 deletion 3p/ampcontext.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import {isObject} from '#core/types';
import {dict, map} from '#core/types/object';
import {tryParseJson} from '#core/types/object/json';

import {dev, devAssert} from '#utils/log';

import {IframeMessagingClient} from './iframe-messaging-client';

import {dev, devAssert} from '../src/log';
import {parseUrlDeprecated} from '../src/url';

export class AbstractAmpContext {
Expand Down
4 changes: 2 additions & 2 deletions 3p/bodymovinanimation.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import {tryPlay} from '#core/dom/video';
import {dict} from '#core/types/object';
import {parseJson} from '#core/types/object/json';

import {loadScript} from './3p';
import {getData} from '#utils/event-helper';

import {getData} from '../src/event-helper';
import {loadScript} from './3p';

const libSourceUrl = dict({
'canvas':
Expand Down
4 changes: 2 additions & 2 deletions 3p/facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import {isEnumValue} from '#core/types/enum';
import {dict} from '#core/types/object';
import {dashToUnderline} from '#core/types/string';

import {loadScript} from './3p';
import {devAssert} from '#utils/log';

import {devAssert} from '../src/log';
import {loadScript} from './3p';

/** @const @enum {string} */
export const FacebookEmbedType = {
Expand Down
3 changes: 2 additions & 1 deletion 3p/frame-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import {once} from '#core/types/function';
import {dict} from '#core/types/object';
import {parseJson} from '#core/types/object/json';

import {dev} from '../src/log';
import {dev} from '#utils/log';

import {getMode} from '../src/mode';
import {parseUrlDeprecated} from '../src/url';

Expand Down
4 changes: 2 additions & 2 deletions 3p/github.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {writeScript} from './3p';
import {userAssert} from '#utils/log';

import {userAssert} from '../src/log';
import {writeScript} from './3p';

/**
* Get the correct script for the gist.
Expand Down
5 changes: 3 additions & 2 deletions 3p/iframe-messaging-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import {
import {Observable} from '#core/data-structures/observable';
import {dict, map} from '#core/types/object';

import {getData} from '../src/event-helper';
import {dev} from '../src/log';
import {getData} from '#utils/event-helper';
import {dev} from '#utils/log';

import {getMode} from '../src/mode';

export class IframeMessagingClient {
Expand Down
4 changes: 2 additions & 2 deletions 3p/iframe-transport-client-lib.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// src/polyfills.js must be the first import.
import './polyfills';

import {IframeTransportClient} from './iframe-transport-client';
import {initLogConstructor, setReportError} from '#utils/log';

import {initLogConstructor, setReportError} from '../src/log';
import {IframeTransportClient} from './iframe-transport-client';

initLogConstructor();
// TODO(alanorozco): Refactor src/error.reportError so it does not contain big
Expand Down
4 changes: 2 additions & 2 deletions 3p/iframe-transport-client.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {IframeTransportEventDef, MessageType} from '#core/3p-frame-messaging';
import {tryParseJson} from '#core/types/object/json';

import {IframeMessagingClient} from './iframe-messaging-client';
import {dev, devAssert, user, userAssert} from '#utils/log';

import {dev, devAssert, user, userAssert} from '../src/log';
import {IframeMessagingClient} from './iframe-messaging-client';

/** @private @const {string} */
const TAG_ = 'iframe-transport-client';
Expand Down
13 changes: 7 additions & 6 deletions 3p/integration-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ import {dict} from '#core/types/object';
import {parseJson} from '#core/types/object/json';
import {endsWith} from '#core/types/string';

import {
initLogConstructor,
isUserErrorMessage,
setReportError,
userAssert,
} from '#utils/log';

import {run, setExperimentToggles} from './3p';
import {IntegrationAmpContext} from './ampcontext-integration';
import {installEmbedStateListener, manageWin} from './environment';
import {getAmpConfig, getEmbedType, getLocation} from './frame-metadata';

import {urls} from '../src/config';
import {
initLogConstructor,
isUserErrorMessage,
setReportError,
userAssert,
} from '../src/log';
import {getSourceUrl, isProxyOrigin, parseUrlDeprecated} from '../src/url';

/**
Expand Down
2 changes: 1 addition & 1 deletion 3p/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import './polyfills';
import {draw3p, init} from './integration-lib';
import {getMode} from '../src/mode';
import {register} from './3p';
import {user} from 'src/log';
import {user} from '#utils/log';

// 3P - please keep in alphabetic order
import {beopinion} from './beopinion';
Expand Down
4 changes: 2 additions & 2 deletions 3p/mathml.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {setStyle} from '#core/dom/style';

import {writeScript} from './3p';
import {userAssert} from '#utils/log';

import {userAssert} from '../src/log';
import {writeScript} from './3p';

/**
* Get the correct script for the mathml formula.
Expand Down
2 changes: 1 addition & 1 deletion 3p/messaging.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {parseJson} from '#core/types/object/json';

import {getData} from '../src/event-helper';
import {getData} from '#utils/event-helper';

/**
* Send messages to parent frame. These should not contain user data.
Expand Down
9 changes: 5 additions & 4 deletions 3p/recaptcha.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ import './polyfills';
import {dict, hasOwn} from '#core/types/object';
import {parseJson} from '#core/types/object/json';

import {loadScript} from './3p';
import {IframeMessagingClient} from './iframe-messaging-client';

import {
dev,
devAssert,
initLogConstructor,
setReportError,
user,
} from '../src/log';
} from '#utils/log';

import {loadScript} from './3p';
import {IframeMessagingClient} from './iframe-messaging-client';

import {isProxyOrigin, parseUrlDeprecated} from '../src/url';
import ampToolboxCacheUrl from '../third_party/amp-toolbox-cache-url/dist/amp-toolbox-cache-url.esm';

Expand Down
4 changes: 2 additions & 2 deletions 3p/viqeoplayer.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {tryPlay} from '#core/dom/video';
import {tryDecodeUriComponent} from '#core/types/string/url';

import {loadScript} from './3p';
import {getData} from '#utils/event-helper';

import {getData} from '../src/event-helper';
import {loadScript} from './3p';

/**
* @param {Window} global
Expand Down
2 changes: 1 addition & 1 deletion ads/alp/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
parseUrlDeprecated,
} from '../../src/url';
import {closest} from '#core/dom/query';
import {dev} from '../../src/log';
import {dev} from '#utils/log';
import {dict} from '#core/types/object';
import {openWindowDialog} from '../../src/open-window-dialog';
import {parseQueryString} from '#core/types/string/url';
Expand Down
2 changes: 1 addition & 1 deletion ads/alp/install-alp.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Utility file that generates URLs suitable for AMP's impression tracking.

import {initLogConstructor, setReportError} from '../../src/log';
import {initLogConstructor, setReportError} from '#utils/log';
import {installAlpClickHandler, warmupStatic} from './handler';
import {reportError} from '../../src/error-reporting';

Expand Down
2 changes: 1 addition & 1 deletion ads/google/a4a/test/test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {installDocService} from '#service/ampdoc-impl';
import {installExtensionsService} from '#service/extensions-impl';
import {installXhrService} from '#service/xhr-impl';
import {toggleExperiment} from '#experiments';
import {user} from '../../../../src/log';
import {user} from '#utils/log';

function setupForAdTesting(fixture) {
installDocService(fixture.win, /* isSingleDoc */ true);
Expand Down
2 changes: 1 addition & 1 deletion ads/google/a4a/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {DomFingerprint} from '#core/dom/fingerprint';
import {GEO_IN_GROUP} from '../../../extensions/amp-geo/0.1/amp-geo-in-group';
import {Services} from '#service';
import {buildUrl} from './shared/url-builder';
import {dev, devAssert, user} from '../../../src/log';
import {dev, devAssert, user} from '#utils/log';
import {dict} from '#core/types/object';
import {getBinaryType, isExperimentOn, toggleExperiment} from '#experiments';
import {getConsentPolicyState} from '../../../src/consent';
Expand Down
2 changes: 1 addition & 1 deletion ads/google/doubleclick.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {dev} from '../../src/log';
import {dev} from '#utils/log';

const TAG = 'DOUBLECLICK - DEPRECATED';
/**
Expand Down
2 changes: 1 addition & 1 deletion ads/google/ima/ima-video.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {CONSENT_POLICY_STATE} from '#core/constants/consent-state';
import {ImaPlayerData} from './ima-player-data';
import {camelCaseToTitleCase, setStyle, toggle} from '#core/dom/style';
import {getData} from '../../../src/event-helper';
import {getData} from '#utils/event-helper';
import {htmlFor, htmlRefs, svgFor} from '#core/dom/static-template';
import {isArray, isObject} from '#core/types';
import {loadScript} from '#3p/3p';
Expand Down
2 changes: 1 addition & 1 deletion ads/google/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
getAutoConfig,
getPubControlConfig,
} from './a4a/shared/content-recommendation';
import {user} from '../../src/log';
import {user} from '#utils/log';

/**
* Approved height for AdSense full-width responsive ads.
Expand Down
4 changes: 2 additions & 2 deletions ads/inabox/inabox-host.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*/

import {InaboxMessagingHost} from './inabox-messaging-host';
import {dev, initLogConstructor, setReportError, user} from '../../src/log';
import {getData} from '../../src/event-helper';
import {dev, initLogConstructor, setReportError, user} from '#utils/log';
import {getData} from '#utils/event-helper';
import {reportError} from '../../src/error-reporting';

/** @const {string} */
Expand Down
4 changes: 2 additions & 2 deletions ads/inabox/inabox-messaging-host.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import {
serializeMessage,
} from '#core/3p-frame-messaging';
import {canInspectWindow} from '../../src/iframe-helper';
import {dev, devAssert} from '../../src/log';
import {dev, devAssert} from '#utils/log';
import {dict} from '#core/types/object';
import {getData} from '../../src/event-helper';
import {getData} from '#utils/event-helper';
import {getFrameOverlayManager} from './frame-overlay-manager';
import {getPositionObserver} from './position-observer';

Expand Down
2 changes: 1 addition & 1 deletion ads/vendors/_ping_.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {dev, devAssert, userAssert} from '../../src/log';
import {dev, devAssert, userAssert} from '#utils/log';
import {validateData} from '#3p/3p';

/**
Expand Down
2 changes: 1 addition & 1 deletion ads/vendors/criteo.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {dev} from '../../src/log';
import {dev} from '#utils/log';
import {loadScript} from '#3p/3p';

/* global Criteo: false */
Expand Down
2 changes: 1 addition & 1 deletion ads/vendors/csa.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {devAssert} from '../../src/log';
import {devAssert} from '#utils/log';
import {getStyle, setStyle, setStyles} from '#core/dom/style';
import {loadScript, validateData} from '#3p/3p';
import {tryParseJson} from '#core/types/object/json';
Expand Down
2 changes: 1 addition & 1 deletion ads/vendors/netletix.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {addParamsToUrl, assertHttpsUrl} from '../../src/url';
import {dev} from '../../src/log';
import {dev} from '#utils/log';
import {dict} from '#core/types/object';
import {loadScript, validateData, writeScript} from '#3p/3p';

Expand Down
2 changes: 1 addition & 1 deletion ads/vendors/promoteiq.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {loadScript, validateData} from '#3p/3p';
import {parseJson} from '#core/types/object/json';
import {user} from '../../src/log';
import {user} from '#utils/log';

const TAG = 'PROMOTEIQ';
const mandatoryDataFields = ['src', 'params', 'sfcallback'];
Expand Down
2 changes: 1 addition & 1 deletion ads/vendors/yieldbot.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {getMultiSizeDimensions} from '#ads/google/utils';
import {loadScript, validateData} from '#3p/3p';
import {rethrowAsync} from '#core/error';
import {user} from '../../src/log';
import {user} from '#utils/log';

/**
* @param {!Window} global
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ module.exports = function () {
resolve(dirname(state.file.opts.filename), source.value)
);

if (filepath.endsWith('src/log')) {
if (filepath.endsWith('utils/log')) {
const propertyMapped = calleeToPropertiesMap.get(
specifier.imported.name
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import {dev, user} from '../../../../../../../src/log';
import {dev, user} from '#utils/log';
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import { dev, user } from '../../../../../../../src/log';
import { dev, user } from '#utils/log';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {dev, user} from '../../../../../../../src/log';
import {dev, user} from '#utils/log';

dev().info(
TAG,
Expand Down Expand Up @@ -47,4 +47,4 @@ class Foo {
dev().error(TAG, 'Should not be removed');
user().error('Should not be removed');
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { dev, user } from '../../../../../../../src/log';
import { dev, user } from '#utils/log';
dev().info;
user().fine;

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import {dev} from '../../../../../../../src/log';
import {dev} from '#utils/log';
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import { dev } from '../../../../../../../src/log';
import { dev } from '#utils/log';
Loading

0 comments on commit b6d1550

Please sign in to comment.