forked from mirrors/gecko-dev
Bug 1861918 - Convert kinto-offline-client to an ES module. r=leplatrem,extension-reviewers,robwu
Differential Revision: https://phabricator.services.mozilla.com/D204431
This commit is contained in:
parent
9f1de9d049
commit
dd30d8567c
9 changed files with 14 additions and 52 deletions
|
|
@ -209,10 +209,6 @@ remote/shared/messagehandler/test/browser/resources/modules/root/invalid.sys.mjs
|
|||
|
||||
# services/ exclusions
|
||||
|
||||
# Third party services
|
||||
services/common/kinto-http-client.sys.mjs
|
||||
services/common/kinto-offline-client.js
|
||||
|
||||
# Webpack-bundled library
|
||||
services/fxaccounts/FxAccountsPairingChannel.sys.mjs
|
||||
|
||||
|
|
|
|||
|
|
@ -1399,7 +1399,7 @@ security/nss/
|
|||
security/sandbox/chromium/
|
||||
security/sandbox/chromium-shim/
|
||||
services/common/kinto-http-client.sys.mjs
|
||||
services/common/kinto-offline-client.js
|
||||
services/common/kinto-offline-client.sys.mjs
|
||||
testing/gtest/gmock/
|
||||
testing/gtest/gtest/
|
||||
testing/mochitest/MochiKit/
|
||||
|
|
|
|||
|
|
@ -12,36 +12,15 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
* This file is generated from kinto.js - do not modify directly.
|
||||
*/
|
||||
|
||||
// This is required because with Babel compiles ES2015 modules into a
|
||||
// require() form that tries to keep its modules on "this", but
|
||||
// doesn't specify "this", leaving it to default to the global
|
||||
// object. However, in strict mode, "this" no longer defaults to the
|
||||
// global object, so expose the global object explicitly. Babel's
|
||||
// compiled output will use a variable called "global" if one is
|
||||
// present.
|
||||
//
|
||||
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1394556#c3 for
|
||||
// more details.
|
||||
const global = this;
|
||||
|
||||
var EXPORTED_SYMBOLS = ["Kinto"];
|
||||
|
||||
/*
|
||||
* Version 13.0.0 - 7fbf95d
|
||||
*/
|
||||
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||||
typeof define === 'function' && define.amd ? define(factory) :
|
||||
(global = global || self, global.Kinto = factory());
|
||||
}(this, (function () { 'use strict';
|
||||
|
||||
/**
|
||||
* Base db adapter.
|
||||
*
|
||||
|
|
@ -2592,19 +2571,13 @@ class KintoBase {
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
const { setTimeout, clearTimeout } = ChromeUtils.importESModule("resource://gre/modules/Timer.sys.mjs");
|
||||
const { XPCOMUtils } = ChromeUtils.importESModule("resource://gre/modules/XPCOMUtils.sys.mjs");
|
||||
XPCOMUtils.defineLazyGlobalGetters(global, ["fetch", "indexedDB"]);
|
||||
ChromeUtils.defineESModuleGetters(global, {
|
||||
const lazy = {};
|
||||
ChromeUtils.defineESModuleGetters(lazy, {
|
||||
EventEmitter: "resource://gre/modules/EventEmitter.sys.mjs",
|
||||
// Use standalone kinto-http module landed in FFx.
|
||||
KintoHttpClient: "resource://services-common/kinto-http-client.sys.mjs"
|
||||
});
|
||||
ChromeUtils.defineLazyGetter(global, "generateUUID", () => {
|
||||
const { generateUUID } = Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator);
|
||||
return generateUUID;
|
||||
});
|
||||
class Kinto extends KintoBase {
|
||||
export class Kinto extends KintoBase {
|
||||
static get adapters() {
|
||||
return {
|
||||
BaseAdapter,
|
||||
|
|
@ -2612,11 +2585,11 @@ class Kinto extends KintoBase {
|
|||
};
|
||||
}
|
||||
get ApiClass() {
|
||||
return KintoHttpClient;
|
||||
return lazy.KintoHttpClient;
|
||||
}
|
||||
constructor(options = {}) {
|
||||
const events = {};
|
||||
EventEmitter.decorate(events);
|
||||
lazy.EventEmitter.decorate(events);
|
||||
const defaults = {
|
||||
adapter: IDB,
|
||||
events,
|
||||
|
|
@ -2629,7 +2602,7 @@ class Kinto extends KintoBase {
|
|||
return typeof id == "string" && RE_RECORD_ID.test(id);
|
||||
},
|
||||
generate() {
|
||||
return generateUUID()
|
||||
return Services.uuid.generateUUID()
|
||||
.toString()
|
||||
.replace(/[{}]/g, "");
|
||||
},
|
||||
|
|
@ -2638,6 +2611,3 @@ class Kinto extends KintoBase {
|
|||
}
|
||||
}
|
||||
|
||||
return Kinto;
|
||||
|
||||
})));
|
||||
|
|
@ -13,9 +13,7 @@
|
|||
*/
|
||||
import { Sqlite } from "resource://gre/modules/Sqlite.sys.mjs";
|
||||
|
||||
const { Kinto } = ChromeUtils.import(
|
||||
"resource://services-common/kinto-offline-client.js"
|
||||
);
|
||||
import { Kinto } from "resource://services-common/kinto-offline-client.sys.mjs";
|
||||
|
||||
/**
|
||||
* Filter and sort list against provided filters and order.
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ EXTRA_COMPONENTS += [
|
|||
EXTRA_JS_MODULES["services-common"] += [
|
||||
"async.sys.mjs",
|
||||
"kinto-http-client.sys.mjs",
|
||||
"kinto-offline-client.js",
|
||||
"kinto-offline-client.sys.mjs",
|
||||
"kinto-storage-adapter.sys.mjs",
|
||||
"logmanager.sys.mjs",
|
||||
"observers.sys.mjs",
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
const { Kinto } = ChromeUtils.import(
|
||||
"resource://services-common/kinto-offline-client.js"
|
||||
const { Kinto } = ChromeUtils.importESModule(
|
||||
"resource://services-common/kinto-offline-client.sys.mjs"
|
||||
);
|
||||
const { FirefoxAdapter } = ChromeUtils.importESModule(
|
||||
"resource://services-common/kinto-storage-adapter.sys.mjs"
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ let gPendingTransactions = new Set();
|
|||
/**
|
||||
* Import the records into the Remote Settings Chrome IndexedDB.
|
||||
*
|
||||
* Note: This duplicates some logics from `kinto-offline-client.js`.
|
||||
* Note: This duplicates some logics from `kinto-offline-client.sys.mjs`.
|
||||
*
|
||||
* @param {String} bucket
|
||||
* @param {String} collection
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
|
|||
CryptoUtils: "resource://services-crypto/utils.sys.mjs",
|
||||
ExtensionCommon: "resource://gre/modules/ExtensionCommon.sys.mjs",
|
||||
FirefoxAdapter: "resource://services-common/kinto-storage-adapter.sys.mjs",
|
||||
Kinto: "resource://services-common/kinto-offline-client.sys.mjs",
|
||||
KintoHttpClient: "resource://services-common/kinto-http-client.sys.mjs",
|
||||
Observers: "resource://services-common/observers.sys.mjs",
|
||||
Utils: "resource://services-sync/util.sys.mjs",
|
||||
|
|
@ -54,9 +55,6 @@ ChromeUtils.defineESModuleGetters(lazy, {
|
|||
* @typedef {any} KeyBundle
|
||||
* @typedef {any} SyncResultObject
|
||||
*/
|
||||
XPCOMUtils.defineLazyModuleGetters(lazy, {
|
||||
Kinto: "resource://services-common/kinto-offline-client.js",
|
||||
});
|
||||
|
||||
ChromeUtils.defineLazyGetter(lazy, "fxAccounts", () => {
|
||||
return ChromeUtils.importESModule(
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ security/nss/
|
|||
security/sandbox/chromium/
|
||||
security/sandbox/chromium-shim/
|
||||
services/common/kinto-http-client.sys.mjs
|
||||
services/common/kinto-offline-client.js
|
||||
services/common/kinto-offline-client.sys.mjs
|
||||
testing/gtest/gmock/
|
||||
testing/gtest/gtest/
|
||||
testing/mochitest/MochiKit/
|
||||
|
|
|
|||
Loading…
Reference in a new issue