This commit is contained in:
2022-07-21 03:28:35 +00:00
parent d7c883d6df
commit 51b34b0e1d
30103 changed files with 4152204 additions and 23 deletions
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2016-2019 Nuxt.js Team
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+32
View File
@@ -0,0 +1,32 @@
## Loading Screen
[![Github Actions CI][github-actions-src]][github-actions-href]
[![Standard JS][standard-js-src]][standard-js-href]
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![package phobia][package-phobia-src]][package-phobia-href]
This module is internally being used by [nuxt.js](https://github.com/nuxt/nuxt.js) to show loading screen.
![nuxt-loading-screen](https://user-images.githubusercontent.com/904724/54605661-12812680-4a4a-11e9-92e0-e7d7ed3a7c66.gif)
## License
MIT - Made with 💖 By Nuxt team!
<!-- Refs -->
[github-actions-src]: https://github.com/nuxt/loading-screen/workflows/ci/badge.svg?branch=master
[github-actions-href]: https://github.com/nuxt/loading-screen/actions?query=workflow%3Aci
[standard-js-src]: https://flat.badgen.net/badge/code%20style/standard/green
[standard-js-href]: https://standardjs.com
[npm-version-src]: https://flat.badgen.net/npm/v/@nuxt/loading-screen/latest
[npm-version-href]: https://npmjs.com/package/@nuxt/loading-screen
[npm-downloads-src]: https://flat.badgen.net/npm/dt/@nuxt/loading-screen
[npm-downloads-href]: https://npmjs.com/package/@nuxt/loading-screen
[package-phobia-src]: https://flat.badgen.net/packagephobia/install/@nuxt/loading-screen
[package-phobia-href]: https://packagephobia.now.sh/result?p=@nuxt/loading-screen
@@ -0,0 +1 @@
@import url(https://fonts.googleapis.com/css?family=Quicksand:400,500);a,abbr,acronym,address,applet,article,aside,audio,b,big,blockquote,body,canvas,caption,center,cite,code,dd,del,details,dfn,div,dl,dt,em,embed,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,html,i,iframe,img,ins,kbd,label,legend,li,mark,menu,nav,object,ol,output,p,pre,q,ruby,s,samp,section,small,span,strike,strong,sub,summary,sup,table,tbody,td,tfoot,th,thead,time,tr,tt,u,ul,var,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:after,blockquote:before,q:after,q:before{content:"";content:none}table{border-collapse:collapse;border-spacing:0}.loading-screen{display:flex;flex-flow:column nowrap;justify-content:center;align-content:center;align-items:center;font-family:Quicksand,sans-serif;height:100vh;transition:opacity .4s}.loading-screen.hide{opacity:0}.loading-screen .row{flex:0 0 auto}.logo{margin-bottom:40px}.v-enter-active,.v-leave-active{transition-delay:.5s;transition-property:all;transition-duration:.6s}.v-enter,.v-leave-to{opacity:0;transform:translateY(-10px)}.placeholder{text-align:center}h3{font-weight:500;font-size:18px;color:#383838;margin:1em 0;letter-spacing:1px}.hasErrors{color:#d0021b}.errorStack{padding:1.5em;border:1px solid #108775;border-radius:1em;background-color:#eee;margin:1em 0}p.pre{margin-top:1em;line-height:1.2em;white-space:pre}h4{margin-bottom:30px;font-size:15px;color:#383838}.reload_prevented{width:500px;max-width:85vw}.reload_prevented p{margin-bottom:1rem}.progress_bar_container{background-color:#ddd;border-radius:6px;width:500px;max-width:85vw;height:10px;margin-bottom:10px}.progress_bar{border-radius:6px;height:10px;width:10px;transition:width .4s}.progress_bar.client{background-color:#00c58e}.progress_bar.server{background-color:#108775}.progress_bar.modern{background-color:#2f495e}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,5 @@
/*!
* Vue.js v2.6.12
* (c) 2014-2020 Evan You
* Released under the MIT License.
*/
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
!function(e){function r(r){for(var n,l,f=r[0],i=r[1],a=r[2],c=0,s=[];c<f.length;c++)l=f[c],Object.prototype.hasOwnProperty.call(o,l)&&o[l]&&s.push(o[l][0]),o[l]=0;for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,a||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,f=1;f<t.length;f++){var i=t[f];0!==o[i]&&(n=!1)}n&&(u.splice(r--,1),e=l(l.s=t[0]))}return e}var n={},o={2:0},u=[];function l(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,l),t.l=!0,t.exports}l.m=e,l.c=n,l.d=function(e,r,t){l.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},l.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(e,r){if(1&r&&(e=l(e)),8&r)return e;if(4&r&&"object"===typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(l.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)l.d(t,n,function(r){return e[r]}.bind(null,n));return t},l.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(r,"a",r),r},l.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},l.p="__BASE_URL__/";var f=window.webpackJsonp=window.webpackJsonp||[],i=f.push.bind(f);f.push=r,f=f.slice();for(var a=0;a<f.length;a++)r(f[a]);var p=i;t()}([]);
+1
View File
@@ -0,0 +1 @@
<!doctype html><html><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>Nuxt.js: Loading app...</title><link href="__BASE_URL__/assets/css/index.28675de3.chunk.css" rel="stylesheet"></head><body><div id="nuxt_loading_screen"></div><script>window.$STATE=__STATE__</script><script>window.$OPTIONS=__OPTIONS__</script><script>!function(e){function r(r){for(var n,l,f=r[0],i=r[1],a=r[2],c=0,s=[];c<f.length;c++)l=f[c],Object.prototype.hasOwnProperty.call(o,l)&&o[l]&&s.push(o[l][0]),o[l]=0;for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,a||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,f=1;f<t.length;f++){var i=t[f];0!==o[i]&&(n=!1)}n&&(u.splice(r--,1),e=l(l.s=t[0]))}return e}var n={},o={2:0},u=[];function l(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,l),t.l=!0,t.exports}l.m=e,l.c=n,l.d=function(e,r,t){l.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(e,r){if(1&r&&(e=l(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(l.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)l.d(t,n,function(r){return e[r]}.bind(null,n));return t},l.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(r,"a",r),r},l.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},l.p="__BASE_URL__/";var f=window.webpackJsonp=window.webpackJsonp||[],i=f.push.bind(f);f.push=r,f=f.slice();for(var a=0;a<f.length;a++)r(f[a]);var p=i;t()}([])</script><script src="__BASE_URL__/assets/js/chunk-vendors.b9580920.chunk.js"></script><script src="__BASE_URL__/assets/js/index.28675de3.chunk.js"></script></body></html>
+146
View File
@@ -0,0 +1,146 @@
const { resolve } = require('path')
const { readFileSync } = require('fs')
const connect = require('connect')
const serveStatic = require('serve-static')
const getPort = require('get-port-please')
const { json, end, header } = require('node-res')
const { parseStack } = require('./utils')
const SSE = require('./sse')
class LoadingUI {
constructor (options) {
this.options = options
this._lastBroadcast = 0
this.states = []
this.allDone = true
this.hasErrors = false
this.serveIndex = this.serveIndex.bind(this)
this._init()
}
_init () {
// Create a connect middleware stack
this.app = connect()
// Create an SSE handler instance
this.sse = new SSE()
// Fix CORS
this.app.use((req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', '*')
next()
})
// Subscribe to SSR channel
this.app.use('/sse', (req, res) => this.sse.subscribe(req, res))
// Serve state with JSON
this.app.use('/json', (req, res) => json(req, res, this.state))
// Load indexTemplate
const distPath = resolve(__dirname, '../app-dist')
this.indexTemplate = readFileSync(resolve(distPath, 'index.html'), 'utf-8')
// Serve assets
this.app.use('/assets', serveStatic(resolve(distPath, 'assets')))
}
async initAlt ({ url }) {
if (this._server || this.options.baseURLAlt) {
return
}
// Redirect users directly open this port
this.app.use('/', (req, res) => {
res.setHeader('Location', url)
res.statusCode = 307
res.end(url)
})
// Start listening on alternative port
const port = await getPort({ random: true, name: 'nuxt_loading' })
return new Promise((resolve, reject) => {
this._server = this.app.listen(port, (err) => {
if (err) { return reject(err) }
this.options.baseURLAlt = `http://localhost:${port}`
resolve()
})
})
}
close () {
if (this._server) {
return new Promise((resolve, reject) => {
this._server.close((err) => {
if (err) {
return reject(err)
}
resolve()
})
})
}
}
get state () {
return {
error: this.error,
states: this.states,
allDone: this.allDone,
hasErrors: this.hasErrors
}
}
setStates (states) {
this.clearError()
this.states = states
this.allDone = this.states.every(state => state.progress === 0 || state.progress === 100)
this.hasErrors = this.states.some(state => state.hasErrors === true)
this.broadcastState()
}
setError (error) {
this.clearStates(true)
this.error = {
description: error.toString(),
stack: parseStack(error.stack).join('\n')
}
this.broadcastState()
}
clearError () {
this.error = undefined
}
clearStates (hasErrors) {
this.states = []
this.allDone = false
this.hasErrors = !!hasErrors
}
broadcastState () {
const now = new Date()
if ((now - this._lastBroadcast > 500) || this.allDone || this.hasErrors) {
this.sse.broadcast('state', this.state)
this._lastBroadcast = now
}
}
serveIndex (req, res) {
const html = this.indexTemplate
.replace('__STATE__', JSON.stringify(this.state))
.replace('__OPTIONS__', JSON.stringify(this.options))
.replace(/__BASE_URL__/g, this.options.baseURL)
header(res, 'Content-Type', 'text/html')
end(res, html)
}
}
module.exports = LoadingUI
+48
View File
@@ -0,0 +1,48 @@
module.exports = function NuxtLoadingScreen () {
if (!this.options.dev) {
return
}
const defu = require('defu')
const LoadingUI = require('./loading')
const { nuxt } = this
const baseURL = nuxt.options.router.base + '_loading'
const options = this.options.build.loadingScreen = defu(this.options.build.loadingScreen, {
baseURL,
baseURLAlt: baseURL,
altPort: false,
image: undefined,
colors: {}
})
const loading = new LoadingUI(options)
nuxt.options.serverMiddleware.push({
path: '/_loading',
handler: (req, res) => { loading.app(req, res) }
})
if (options.altPort) {
nuxt.hook('listen', async (_, { url }) => {
await loading.initAlt({ url })
})
}
nuxt.hook('close', async () => {
await loading.close()
})
nuxt.hook('bundler:progress', (states) => {
loading.setStates(states)
})
nuxt.hook('cli:buildError', (error) => {
loading.setError(error)
})
nuxt.hook('server:nuxt:renderLoading', (req, res) => {
loading.serveIndex(req, res)
})
}
+43
View File
@@ -0,0 +1,43 @@
const { status, header } = require('node-res')
class SSE {
constructor () {
this.subscriptions = new Set()
this.counter = 0
}
// Subscribe to a channel and set initial headers
subscribe (req, res) {
req.socket.setTimeout(0)
status(res, 200)
header(res, 'Content-Type', 'text/event-stream')
header(res, 'Cache-Control', 'no-cache')
if (req.httpVersion !== '2.0') {
header(res, 'Connection', 'keep-alive')
}
this.subscriptions.add(res)
res.on('close', () => this.subscriptions.delete(res))
this.broadcast('ready', {})
}
// Publish event and data to all connected clients
broadcast (event, data) {
this.counter++
// Do console.log(this.subscriptions.size) to see, if there are any memory leaks
for (const res of this.subscriptions) {
this.clientBroadcast(res, event, data)
}
}
// Publish event and data to a given response object
clientBroadcast (res, event, data) {
res.write(`id: ${this.counter}\n`)
res.write('event: message\n')
res.write(`data: ${JSON.stringify({ event, ...data })}\n\n`)
}
}
module.exports = SSE
+21
View File
@@ -0,0 +1,21 @@
const { sep } = require('path')
// copied from https://github.com/nuxt/consola/blob/master/src/utils/error.js
function parseStack (stack) {
const cwd = process.cwd() + sep
const lines = stack
.split('\n')
.splice(1)
.map(l => l
.trim()
.replace('file://', '')
.replace(cwd, '')
)
return lines
}
module.exports = {
parseStack
}
+71
View File
@@ -0,0 +1,71 @@
{
"_args": [
[
"@nuxt/loading-screen@2.0.4",
"/home/node/nuxt"
]
],
"_from": "@nuxt/loading-screen@2.0.4",
"_id": "@nuxt/loading-screen@2.0.4",
"_inBundle": false,
"_integrity": "sha512-xpEDAoRu75tLUYCkUJCIvJkWJSuwr8pqomvQ+fkXpSrkxZ/9OzlBFjAbVdOAWTMj4aV/LVQso4vcEdircKeFIQ==",
"_location": "/@nuxt/loading-screen",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@nuxt/loading-screen@2.0.4",
"name": "@nuxt/loading-screen",
"escapedName": "@nuxt%2floading-screen",
"scope": "@nuxt",
"rawSpec": "2.0.4",
"saveSpec": null,
"fetchSpec": "2.0.4"
},
"_requiredBy": [
"/nuxt"
],
"_resolved": "https://registry.npmjs.org/@nuxt/loading-screen/-/loading-screen-2.0.4.tgz",
"_spec": "2.0.4",
"_where": "/home/node/nuxt",
"bugs": {
"url": "https://github.com/nuxt/loading-screen/issues"
},
"dependencies": {
"connect": "^3.7.0",
"defu": "^5.0.0",
"get-port-please": "^2.2.0",
"node-res": "^5.0.1",
"serve-static": "^1.14.1"
},
"description": "[![Github Actions CI][github-actions-src]][github-actions-href] [![Standard JS][standard-js-src]][standard-js-href] [![npm version][npm-version-src]][npm-version-href] [![npm downloads][npm-downloads-src]][npm-downloads-href] [![package phobia][package-phobia-src]][package-phobia-href]",
"devDependencies": {
"@nuxtjs/eslint-config": "latest",
"eslint": "latest",
"poi": "latest",
"standard-version": "latest",
"unfetch": "latest",
"vue": "latest",
"vue-template-compiler": "latest"
},
"files": [
"lib",
"app-dist"
],
"homepage": "https://github.com/nuxt/loading-screen#readme",
"license": "MIT",
"main": "lib/module.js",
"name": "@nuxt/loading-screen",
"repository": {
"type": "git",
"url": "git+https://github.com/nuxt/loading-screen.git"
},
"scripts": {
"build": "yarn poi --prod",
"lint": "eslint --ext .vue,.ts,.js .",
"prepack": "yarn build",
"release": "yarn test && standard-version && git push --follow-tags && npm publish",
"test": "yarn lint"
},
"version": "2.0.4"
}