Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️ Extract json helpers to core/types/object/json #34367

Merged
merged 15 commits into from
May 14, 2021
2 changes: 1 addition & 1 deletion 3p/3d-gltf/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import {dict} from '../../src/core/types/object';
import {listenParent, nonSensitiveDataPostMessage} from '../messaging';
import {loadScript} from '../3p';
import {parseJson} from '../../src/json';
import {parseJson} from '../../src/core/types/object/json';
import {user} from '../../src/log';

import GltfViewer from './viewer';
Expand Down
2 changes: 1 addition & 1 deletion 3p/ampcontext.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {dev, devAssert} from '../src/log';
import {dict, map} from '../src/core/types/object';
import {isObject} from '../src/core/types';
import {parseUrlDeprecated} from '../src/url';
import {tryParseJson} from '../src/json';
import {tryParseJson} from '../src/core/types/object/json';

export class AbstractAmpContext {
/**
Expand Down
2 changes: 1 addition & 1 deletion 3p/bodymovinanimation.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import {dict} from '../src/core/types/object';
import {getData} from '../src/event-helper';
import {loadScript} from './3p';
import {parseJson} from '../src/json';
import {parseJson} from '../src/core/types/object/json';
import {setStyles} from '../src/style';

const libSourceUrl = dict({
Expand Down
2 changes: 1 addition & 1 deletion 3p/frame-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {dev} from '../src/log';
import {dict} from '../src/core/types/object';
import {getMode} from '../src/mode';
import {once} from '../src/core/types/function';
import {parseJson} from '../src/json';
import {parseJson} from '../src/core/types/object/json';
import {parseUrlDeprecated} from '../src/url';

/**
Expand Down
2 changes: 1 addition & 1 deletion 3p/iframe-transport-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import {IframeMessagingClient} from './iframe-messaging-client';
import {MessageType} from '../src/3p-frame-messaging';
import {dev, devAssert, user, userAssert} from '../src/log';
import {tryParseJson} from '../src/json';
import {tryParseJson} from '../src/core/types/object/json';

/** @private @const {string} */
const TAG_ = 'iframe-transport-client';
Expand Down
2 changes: 1 addition & 1 deletion 3p/integration-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
} from '../src/log';
import {installEmbedStateListener, manageWin} from './environment';
import {internalRuntimeVersion} from '../src/internal-version';
import {parseJson} from '../src/json';
import {parseJson} from '../src/core/types/object/json';
import {run, setExperimentToggles} from './3p';
import {urls} from '../src/config';

Expand Down
2 changes: 1 addition & 1 deletion 3p/messaging.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import {getData} from '../src/event-helper';
import {parseJson} from '../src/json';
import {parseJson} from '../src/core/types/object/json';

/**
* Send messages to parent frame. These should not contain user data.
Expand Down
2 changes: 1 addition & 1 deletion 3p/recaptcha.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
import {dict, hasOwn} from '../src/core/types/object';
import {isProxyOrigin, parseUrlDeprecated} from '../src/url';
import {loadScript} from './3p';
import {parseJson} from '../src/json';
import {parseJson} from '../src/core/types/object/json';

/**
* @fileoverview
Expand Down
2 changes: 1 addition & 1 deletion ads/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import {jsonConfiguration} from '../src/json';
import {jsonConfiguration} from '../src/core/types/object/json';

/**
* @typedef {{
Expand Down
2 changes: 1 addition & 1 deletion ads/google/a4a/line-delimited-response-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import {tryParseJson} from '../../../src/json';
import {tryParseJson} from '../../../src/core/types/object/json';

/**
* Handles an XHR response by calling lineCallback for each line delineation.
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 @@ -33,7 +33,7 @@ import {getOrCreateAdCid} from '../../../src/ad-cid';
import {getPageLayoutBoxBlocking} from '../../../src/utils/page-layout-box';
import {getTimingDataSync} from '../../../src/service/variable-source';
import {internalRuntimeVersion} from '../../../src/internal-version';
import {parseJson} from '../../../src/json';
import {parseJson} from '../../../src/core/types/object/json';
import {whenUpgradedToCustomElement} from '../../../src/dom';

/** @type {string} */
Expand Down
2 changes: 1 addition & 1 deletion ads/google/ima/ima-video.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {htmlFor, htmlRefs, svgFor} from '../../../src/static-template';
import {isArray, isObject} from '../../../src/core/types';
import {loadScript} from '../../../3p/3p';
import {throttle} from '../../../src/core/types/function';
import {tryParseJson} from '../../../src/json';
import {tryParseJson} from '../../../src/core/types/object/json';
// Source for this constant is css/amp-ima-video-iframe.css
import {cssText} from '../../../build/amp-ima-video-iframe.css';

Expand Down
2 changes: 1 addition & 1 deletion ads/vendors/a9.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import {hasOwn} from '../../src/core/types/object';
import {loadScript, validateData, writeScript} from '../../3p/3p';
import {parseJson} from '../../src/json';
import {parseJson} from '../../src/core/types/object/json';

const mandatoryParams = [],
optionalParams = [
Expand Down
2 changes: 1 addition & 1 deletion ads/vendors/admixer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import {tryParseJson} from '../../src/json';
import {tryParseJson} from '../../src/core/types/object/json';
import {validateData, writeScript} from '../../3p/3p';

/**
Expand Down
2 changes: 1 addition & 1 deletion ads/vendors/adocean.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import {CONSENT_POLICY_STATE} from '../../src/core/constants/consent-state';
import {computeInMasterFrame, validateData, writeScript} from '../../3p/3p';
import {parseJson} from '../../src/json';
import {parseJson} from '../../src/core/types/object/json';

/**
* @const {Object<string, string>}
Expand Down
2 changes: 1 addition & 1 deletion ads/vendors/blade.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import {loadScript, validateData} from '../../3p/3p';
import {tryParseJson} from '../../src/json';
import {tryParseJson} from '../../src/core/types/object/json';

/**
* @param {!Window} global
Expand Down
2 changes: 1 addition & 1 deletion ads/vendors/connatix.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import {hasOwn} from '../../src/core/types/object';
import {tryParseJson} from '../../src/json.js';
import {tryParseJson} from '../../src/core/types/object/json';
import {validateData} from '../../3p/3p';

/**
Expand Down
2 changes: 1 addition & 1 deletion ads/vendors/csa.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import {devAssert} from '../../src/log';
import {getStyle, setStyle, setStyles} from '../../src/style';
import {loadScript, validateData} from '../../3p/3p';
import {tryParseJson} from '../../src/json.js';
import {tryParseJson} from '../../src/core/types/object/json';

// Keep track of current height of AMP iframe
let currentAmpHeight = null;
Expand Down
2 changes: 1 addition & 1 deletion ads/vendors/iprom.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import {parseJson} from '../../src/json';
import {parseJson} from '../../src/core/types/object/json';
import {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
Expand Up @@ -15,7 +15,7 @@
*/

import {loadScript, validateData} from '../../3p/3p';
import {parseJson} from '../../src/json';
import {parseJson} from '../../src/core/types/object/json';
import {user} from '../../src/log';

const TAG = 'PROMOTEIQ';
Expand Down
2 changes: 1 addition & 1 deletion ads/vendors/runative.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import {loadScript, validateData} from '../../3p/3p';
import {parseJson} from '../../src/json';
import {parseJson} from '../../src/core/types/object/json';

const requiredParams = ['spot'];
const optionsParams = [
Expand Down
2 changes: 1 addition & 1 deletion ads/vendors/sas.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import {getMultiSizeDimensions} from '../../ads/google/utils';
import {parseJson} from '../../src/json';
import {parseJson} from '../../src/core/types/object/json';
import {validateData, writeScript} from '../../3p/3p';

/**
Expand Down
2 changes: 1 addition & 1 deletion ads/vendors/sona.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import {loadScript, validateData} from '../../3p/3p';
import {parseJson} from '../../src/json';
import {parseJson} from '../../src/core/types/object/json';

/**
* @param {!Window} global
Expand Down
2 changes: 1 addition & 1 deletion ads/vendors/springAds.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import {computeInMasterFrame, loadScript} from '../../3p/3p';
import {parseJson} from '../../src/json';
import {parseJson} from '../../src/core/types/object/json';

/**
* @param context
Expand Down
2 changes: 1 addition & 1 deletion ads/vendors/ssp.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import {computeInMasterFrame, loadScript, validateData} from '../../3p/3p';
import {parseJson} from '../../src/json';
import {parseJson} from '../../src/core/types/object/json';
import {setStyle, setStyles} from '../../src/style';

/*
Expand Down
2 changes: 1 addition & 1 deletion ads/vendors/torimochi.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import {parseJson} from '../../src/json';
import {parseJson} from '../../src/core/types/object/json';
import {validateData, writeScript} from '../../3p/3p';

/**
Expand Down
2 changes: 1 addition & 1 deletion ads/vendors/uzou.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import {loadScript, validateData} from '../../3p/3p';
import {parseJson} from '../../src/json';
import {parseJson} from '../../src/core/types/object/json';

/**
* @param {!Window} global
Expand Down
2 changes: 1 addition & 1 deletion ads/vendors/videonow.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import {loadScript, validateData} from '../../3p/3p';
import {parseJson} from '../../src/json';
import {parseJson} from '../../src/core/types/object/json';
import {tryDecodeUriComponent} from '../../src/url';

/**
Expand Down
2 changes: 1 addition & 1 deletion ads/vendors/viralize.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import {addParamsToUrl} from '../../src/url';
import {loadScript, validateData} from '../../3p/3p';
import {parseJson} from '../../src/json';
import {parseJson} from '../../src/core/types/object/json';

/**
* @param {!Window} global
Expand Down
4 changes: 2 additions & 2 deletions build-system/eslint-rules/json-configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
'use strict';

/**
* Finds the jsonConfiguration helper function from src/json.js, and performs
* validation on its input.
* Finds the jsonConfiguration helper function from src/core/types/object/json,
* and performs validation on its input.
*/

module.exports = function (context) {
Expand Down
2 changes: 1 addition & 1 deletion build-system/eslint-rules/no-has-own-property-method.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = {
node,
message:
'Do not use hasOwnProperty directly. ' +
'Use hasOwn from src/core/types/object.js instead.',
'Use hasOwn from src/core/types/object instead.',
});
}
},
Expand Down
2 changes: 1 addition & 1 deletion build-system/tasks/compile-jison.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const imports = new Map([
[
'bindParser',
"import {AstNode, AstNodeType} from '../../extensions/amp-bind/0.1/bind-expr-defines';\n" +
"import {tryParseJson} from '../../src/json';",
"import {tryParseJson} from '../../src/core/types/object/json';",
],
]);

Expand Down
2 changes: 1 addition & 1 deletion build-system/test-configs/conformance-config.textproto
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ requirement: {
allowlist: 'ads/google/ima/ima-video.js'
allowlist: 'ads/vendors/zen.js'
allowlist: 'extensions/amp-viewer-integration/0.1/messaging/messaging.js' # published as standalone library
allowlist: 'src/json.js' # Where parseJson itself is implemented.
allowlist: 'src/core/types/object/json.js' # Where parseJson itself is implemented.
allowlist_regexp: '.*\\.jss\\.js'
}

Expand Down
8 changes: 4 additions & 4 deletions build-system/test-configs/dep-check-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ exports.rules = [
'3p/**->src/core/error.js',
'3p/**->src/core/types/function/index.js',
'3p/**->src/core/types/index.js',
'3p/**->src/core/types/object.js',
'3p/**->src/core/types/object/index.js',
'3p/**->src/core/types/string/index.js',
'3p/**->src/log.js',
'3p/**->src/style.js',
'3p/**->src/url.js',
'3p/**->src/config.js',
'3p/**->src/mode.js',
'3p/**->src/json.js',
'3p/**->src/core/types/object/json.js',
'3p/**->src/3p-frame-messaging.js',
'3p/**->src/internal-version.js',
'3p/polyfills.js->src/polyfills/math-sign.js',
Expand All @@ -123,7 +123,7 @@ exports.rules = [
'ads/**->src/core/error.js',
'ads/**->src/core/types/function/index.js',
'ads/**->src/core/types/index.js',
'ads/**->src/core/types/object.js',
'ads/**->src/core/types/object/index.js',
'ads/**->src/core/types/string/index.js',
'ads/**->src/log.js',
'ads/**->src/mode.js',
Expand All @@ -144,7 +144,7 @@ exports.rules = [
'ads/google/a4a/utils.js->src/ini-load.js',
'ads/google/a4a/utils.js->src/utils/page-layout-box.js',
// Some ads need to depend on json.js
'ads/**->src/json.js',
'ads/**->src/core/types/object/json.js',
// IMA, similar to other non-Ad 3Ps above, needs access to event-helper
'ads/google/ima/ima-video.js->src/event-helper.js',
],
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-a4a/0.1/amp-a4a.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ import {
unobserveWithSharedInOb,
} from '../../../src/viewport-observer';
import {padStart} from '../../../src/core/types/string';
import {parseJson} from '../../../src/json';
import {parseJson} from '../../../src/core/types/object/json';
import {processHead} from './head-validation';
import {setStyle} from '../../../src/style';
import {signingServerURLs} from '../../../ads/_a4a-config';
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-a4a/0.1/amp-ad-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {isArray, isObject} from '../../../src/core/types';

import {isSecureUrlDeprecated} from '../../../src/url';
import {parseExtensionUrl} from '../../../src/service/extension-script';
import {parseJson} from '../../../src/json';
import {parseJson} from '../../../src/core/types/object/json';
import {urls} from '../../../src/config';

const TAG = 'amp-ad-util';
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-a4a/0.1/template-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
} from './amp-ad-utils';
import {getAmpAdTemplateHelper} from './amp-ad-template-helper';
import {preloadFriendlyIframeEmbedExtensions} from '../../../src/friendly-iframe-embed';
import {tryParseJson} from '../../../src/json';
import {tryParseJson} from '../../../src/core/types/object/json';
import {urls} from '../../../src/config';
import {utf8Decode} from '../../../src/core/types/string/bytes';

Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-a4a/0.1/test/test-name-frame-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import {NameFrameRenderer} from '../name-frame-renderer';
import {parseJson} from '../../../../src/json';
import {parseJson} from '../../../../src/core/types/object/json';
import {utf8Encode} from '../../../../src/core/types/string/bytes';

const realWinConfig = {
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-access/0.1/amp-access-iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {dev, userAssert} from '../../../src/log';
import {dict} from '../../../src/core/types/object';
import {getMode} from '../../../src/mode';
import {isArray} from '../../../src/core/types';
import {parseJson} from '../../../src/json';
import {parseJson} from '../../../src/core/types/object/json';
import {toggle} from '../../../src/style';

const AUTHORIZATION_TIMEOUT = 3000;
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-access/0.1/amp-access-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {escapeCssSelectorIdent} from '../../../src/core/dom/css';
import {fetchDocument} from '../../../src/document-fetcher';
import {isExperimentOn} from '../../../src/experiments';
import {isProxyOrigin, removeFragment} from '../../../src/url';
import {parseJson} from '../../../src/json';
import {parseJson} from '../../../src/core/types/object/json';

/** @const {string} */
const TAG = 'amp-access-server';
Expand Down
3 changes: 1 addition & 2 deletions extensions/amp-access/0.1/amp-access-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ import {Deferred} from '../../../src/core/data-structures/promise';
import {Services} from '../../../src/services';
import {assertHttpsUrl, parseQueryString} from '../../../src/url';
import {dev, user, userAssert} from '../../../src/log';
import {dict} from '../../../src/core/types/object';
import {dict, getValueForExpr} from '../../../src/core/types/object';
import {getLoginUrl, openLoginDialog} from './login-dialog';
import {getValueForExpr} from '../../../src/json';
import {isExperimentOn} from '../../../src/experiments';
import {isObject} from '../../../src/core/types';
import {triggerAnalyticsEvent} from '../../../src/analytics';
Expand Down
Loading