From 8380a674b939bd9d38d6b00c9eab6d19f0ea2123 Mon Sep 17 00:00:00 2001 From: eight Date: Thu, 20 Feb 2020 20:17:15 +0800 Subject: [PATCH] Upgrade uuid (#858) * Upgrade uuid * Fix: eslint --- background/style-manager.js | 6 +++--- package-lock.json | 30 ++++++++++++++++++++++++++---- package.json | 2 +- tools/build-vendor.js | 7 ++++++- vendor/uuid/README.md | 7 +++---- vendor/uuid/uuid.min.js | 2 +- 6 files changed, 40 insertions(+), 14 deletions(-) diff --git a/background/style-manager.js b/background/style-manager.js index 8be5d2ac..a1dee182 100644 --- a/background/style-manager.js +++ b/background/style-manager.js @@ -1,6 +1,6 @@ /* eslint no-eq-null: 0, eqeqeq: [2, "smart"] */ /* global createCache db calcStyleDigest db tryRegExp styleCodeEmpty - getStyleWithNoCode msg sync uuid */ + getStyleWithNoCode msg sync uuidv4 */ /* exported styleManager */ 'use strict'; @@ -384,7 +384,7 @@ const styleManager = (() => { delete style.id; } if (!style._id) { - style._id = uuid(); + style._id = uuidv4(); } style._rev = Date.now(); fixUsoMd5Issue(style); @@ -523,7 +523,7 @@ const styleManager = (() => { function prepare() { const ADD_MISSING_PROPS = { name: style => `ID: ${style.id}`, - _id: () => uuid(), + _id: () => uuidv4(), _rev: () => Date.now() }; diff --git a/package-lock.json b/package-lock.json index 24f72904..2ee26f60 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "Stylus", - "version": "1.5.8", + "version": "1.5.9", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -3961,6 +3961,12 @@ "remove-trailing-separator": "^1.0.1" } }, + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "dev": true + }, "zip-stream": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/zip-stream/-/zip-stream-1.2.0.tgz", @@ -6569,6 +6575,14 @@ "tough-cookie": "~2.5.0", "tunnel-agent": "^0.6.0", "uuid": "^3.3.2" + }, + "dependencies": { + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "dev": true + } } }, "require-directory": { @@ -6945,6 +6959,14 @@ "tough-cookie": "~2.4.3", "tunnel-agent": "^0.6.0", "uuid": "^3.3.2" + }, + "dependencies": { + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "dev": true + } } }, "tough-cookie": { @@ -8025,9 +8047,9 @@ "dev": true }, "uuid": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", - "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "version": "7.0.0-beta.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-7.0.0-beta.0.tgz", + "integrity": "sha512-Am22LVM3UXB0DTzQAeDSsZwP5eyqjIhmff330hqkxGvIxX8RRrUYLtKJ0eYxiBgjeQdUaMONpBZbJachMShxBw==", "dev": true }, "v8-compile-cache": { diff --git a/package.json b/package.json index 1f78bbe1..52df771e 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "sync-version": "^1.0.1", "tiny-glob": "^0.2.6", "usercss-meta": "^0.9.0", - "uuid": "^3.4.0", + "uuid": "^7.0.0-beta.0", "web-ext": "^4.1.0", "webext-tx-fix": "^0.3.3" }, diff --git a/tools/build-vendor.js b/tools/build-vendor.js index ad3f6f9a..1e3d5c24 100644 --- a/tools/build-vendor.js +++ b/tools/build-vendor.js @@ -61,7 +61,7 @@ const files = { 'dist/db-to-cloud.min.js → db-to-cloud.min.js' ], 'uuid': [ - 'https://bundle.run/uuid@{VERSION}/v4.js → uuid.min.js' + 'dist/umd/uuidv4.min.js → uuid.min.js' ] }; @@ -120,6 +120,7 @@ async function buildFiles(pkg, patterns) { await fse.outputFile(`vendor/${pkg}/${dest}`, content); fetchedFiles.push([src, dest]); } else { + let dirty = false; for (const file of await glob(`node_modules/${pkg}/${src}`)) { if (dest) { await fse.copy(file, `vendor/${pkg}/${dest}`); @@ -127,6 +128,10 @@ async function buildFiles(pkg, patterns) { await fse.copy(file, path.join('vendor', path.relative('node_modules', file))); } copiedFiles.push([path.relative(`node_modules/${pkg}`, file), dest]); + dirty = true; + } + if (!dirty) { + throw new Error(`Pattern ${src} matches no files`); } } } diff --git a/vendor/uuid/README.md b/vendor/uuid/README.md index aa913050..718a07c3 100644 --- a/vendor/uuid/README.md +++ b/vendor/uuid/README.md @@ -1,6 +1,5 @@ -## uuid v3.4.0 +## uuid v7.0.0-beta.0 -Following files are downloaded from HTTP: - -* uuid.min.js: https://bundle.run/uuid@3.4.0/v4.js +Following files are copied from npm (node_modules): +* uuid.min.js: dist\umd\uuidv4.min.js diff --git a/vendor/uuid/uuid.min.js b/vendor/uuid/uuid.min.js index eb688a0f..110b26e5 100644 --- a/vendor/uuid/uuid.min.js +++ b/vendor/uuid/uuid.min.js @@ -1 +1 @@ -!function(n){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).uuid=n()}}(function(){return function(){return function n(e,r,t){function o(f,u){if(!r[f]){if(!e[f]){var d="function"==typeof require&&require;if(!u&&d)return d(f,!0);if(i)return i(f,!0);var a=new Error("Cannot find module '"+f+"'");throw a.code="MODULE_NOT_FOUND",a}var p=r[f]={exports:{}};e[f][0].call(p.exports,function(n){return o(e[f][1][n]||n)},p,p.exports,n,e,r,t)}return r[f].exports}for(var i="function"==typeof require&&require,f=0;f>>((3&e)<<3)&255;return i}}},{}],3:[function(n,e,r){var t=n("./lib/rng"),o=n("./lib/bytesToUuid");e.exports=function(n,e,r){var i=e&&r||0;"string"==typeof n&&(e="binary"===n?new Array(16):null,n=null);var f=(n=n||{}).random||(n.rng||t)();if(f[6]=15&f[6]|64,f[8]=63&f[8]|128,e)for(var u=0;u<16;++u)e[i+u]=f[u];return e||o(f)}},{"./lib/bytesToUuid":1,"./lib/rng":2}]},{},[3])(3)}); \ No newline at end of file +!function(o,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(o=o||self).uuidv4=e()}(this,(function(){"use strict";var o="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto),e=new Uint8Array(16);function r(){if(!o)throw new Error("uuid: This browser does not seem to support crypto.getRandomValues(). If you need to support this browser, please provide a custom random number generator through options.rng.");return o(e)}for(var n=[],t=0;t<256;++t)n[t]=(t+256).toString(16).substr(1);return function(o,e,t){var u=e&&t||0;"string"==typeof o&&(e="binary"===o?new Array(16):null,o=null);var i=(o=o||{}).random||(o.rng||r)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,e)for(var s=0;s<16;++s)e[u+s]=i[s];return e||function(o,e){var r=e||0,t=n;return[t[o[r++]],t[o[r++]],t[o[r++]],t[o[r++]],"-",t[o[r++]],t[o[r++]],"-",t[o[r++]],t[o[r++]],"-",t[o[r++]],t[o[r++]],"-",t[o[r++]],t[o[r++]],t[o[r++]],t[o[r++]],t[o[r++]],t[o[r++]]].join("")}(i)}})); \ No newline at end of file