chushihua

This commit is contained in:
li
2026-01-26 23:20:48 +08:00
commit 7b5aab0206
22521 changed files with 3300090 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
.root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
"extends": "airbnb-base"
};
+4
View File
@@ -0,0 +1,4 @@
# Change Log
## [1.0.1](https://github.com/nolimits4web/ssr-window/compare/v1.0.0...v1.0.1) - Released on July 18, 2018
* Simplified code structure to bypass rollup bugs
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Vladimir Kharlampidi
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.
+9
View File
@@ -0,0 +1,9 @@
# SSR Window
Better handling for `window` object in SSR environment.
Was created for use in:
* [Dom7](https://github.com/nolimits4web/dom7)
* [Swiper](https://github.com/nolimits4web/swiper)
* [Framework7](https://github.com/framework7io/framework7)
+74
View File
@@ -0,0 +1,74 @@
/**
* SSR Window 1.0.1
* Better handling for window object in SSR environment
* https://github.com/nolimits4web/ssr-window
*
* Copyright 2018, Vladimir Kharlampidi
*
* Licensed under MIT
*
* Released on: July 18, 2018
*/
var doc = (typeof document === 'undefined') ? {
body: {},
addEventListener: function addEventListener() {},
removeEventListener: function removeEventListener() {},
activeElement: {
blur: function blur() {},
nodeName: '',
},
querySelector: function querySelector() {
return null;
},
querySelectorAll: function querySelectorAll() {
return [];
},
getElementById: function getElementById() {
return null;
},
createEvent: function createEvent() {
return {
initEvent: function initEvent() {},
};
},
createElement: function createElement() {
return {
children: [],
childNodes: [],
style: {},
setAttribute: function setAttribute() {},
getElementsByTagName: function getElementsByTagName() {
return [];
},
};
},
location: { hash: '' },
} : document; // eslint-disable-line
var win = (typeof window === 'undefined') ? {
document: doc,
navigator: {
userAgent: '',
},
location: {},
history: {},
CustomEvent: function CustomEvent() {
return this;
},
addEventListener: function addEventListener() {},
removeEventListener: function removeEventListener() {},
getComputedStyle: function getComputedStyle() {
return {
getPropertyValue: function getPropertyValue() {
return '';
},
};
},
Image: function Image() {},
Date: function Date() {},
screen: {},
setTimeout: function setTimeout() {},
clearTimeout: function clearTimeout() {},
} : window; // eslint-disable-line
export { win as window, doc as document };
+85
View File
@@ -0,0 +1,85 @@
/**
* SSR Window 1.0.1
* Better handling for window object in SSR environment
* https://github.com/nolimits4web/ssr-window
*
* Copyright 2018, Vladimir Kharlampidi
*
* Licensed under MIT
*
* Released on: July 18, 2018
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.ssrWindow = {})));
}(this, (function (exports) { 'use strict';
var doc = (typeof document === 'undefined') ? {
body: {},
addEventListener: function addEventListener() {},
removeEventListener: function removeEventListener() {},
activeElement: {
blur: function blur() {},
nodeName: '',
},
querySelector: function querySelector() {
return null;
},
querySelectorAll: function querySelectorAll() {
return [];
},
getElementById: function getElementById() {
return null;
},
createEvent: function createEvent() {
return {
initEvent: function initEvent() {},
};
},
createElement: function createElement() {
return {
children: [],
childNodes: [],
style: {},
setAttribute: function setAttribute() {},
getElementsByTagName: function getElementsByTagName() {
return [];
},
};
},
location: { hash: '' },
} : document; // eslint-disable-line
var win = (typeof window === 'undefined') ? {
document: doc,
navigator: {
userAgent: '',
},
location: {},
history: {},
CustomEvent: function CustomEvent() {
return this;
},
addEventListener: function addEventListener() {},
removeEventListener: function removeEventListener() {},
getComputedStyle: function getComputedStyle() {
return {
getPropertyValue: function getPropertyValue() {
return '';
},
};
},
Image: function Image() {},
Date: function Date() {},
screen: {},
setTimeout: function setTimeout() {},
clearTimeout: function clearTimeout() {},
} : window; // eslint-disable-line
exports.window = win;
exports.document = doc;
Object.defineProperty(exports, '__esModule', { value: true });
})));
+12
View File
@@ -0,0 +1,12 @@
/**
* SSR Window 1.0.1
* Better handling for window object in SSR environment
* https://github.com/nolimits4web/ssr-window
*
* Copyright 2018, Vladimir Kharlampidi
*
* Licensed under MIT
*
* Released on: July 18, 2018
*/!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e.ssrWindow={})}(this,function(e){"use strict";var n="undefined"==typeof document?{body:{},addEventListener:function(){},removeEventListener:function(){},activeElement:{blur:function(){},nodeName:""},querySelector:function(){return null},querySelectorAll:function(){return[]},getElementById:function(){return null},createEvent:function(){return{initEvent:function(){}}},createElement:function(){return{children:[],childNodes:[],style:{},setAttribute:function(){},getElementsByTagName:function(){return[]}}},location:{hash:""}}:document,t="undefined"==typeof window?{document:n,navigator:{userAgent:""},location:{},history:{},CustomEvent:function(){return this},addEventListener:function(){},removeEventListener:function(){},getComputedStyle:function(){return{getPropertyValue:function(){return""}}},Image:function(){},Date:function(){},screen:{},setTimeout:function(){},clearTimeout:function(){}}:window;e.window=t,e.document=n,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=ssr-window.min.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["ssr-window.js"],"names":["global","factory","exports","module","define","amd","ssrWindow","this","doc","document","body","addEventListener","removeEventListener","activeElement","blur","nodeName","querySelector","querySelectorAll","getElementById","createEvent","initEvent","createElement","children","childNodes","style","setAttribute","getElementsByTagName","location","hash","win","window","navigator","userAgent","history","CustomEvent","getComputedStyle","getPropertyValue","Image","Date","screen","setTimeout","clearTimeout","Object","defineProperty","value"],"mappings":";;;;;;;;;;IAWC,SAAUA,EAAQC,GACC,iBAAZC,SAA0C,oBAAXC,OAAyBF,EAAQC,SACrD,mBAAXE,QAAyBA,OAAOC,IAAMD,QAAQ,WAAYH,GAChEA,EAASD,EAAOM,cAHlB,CAIEC,KAAM,SAAWL,GAAW,aAE9B,IAAIM,EAA2B,oBAAbC,UAChBC,QACAC,iBAAkB,aAClBC,oBAAqB,aACrBC,eACEC,KAAM,aACNC,SAAU,IAEZC,cAAe,WACb,OAAO,MAETC,iBAAkB,WAChB,UAEFC,eAAgB,WACd,OAAO,MAETC,YAAa,WACX,OACEC,UAAW,eAGfC,cAAe,WACb,OACEC,YACAC,cACAC,SACAC,aAAc,aACdC,qBAAsB,WACpB,YAINC,UAAYC,KAAM,KAChBnB,SAEAoB,EAAyB,oBAAXC,QAChBrB,SAAUD,EACVuB,WACEC,UAAW,IAEbL,YACAM,WACAC,YAAa,WACX,OAAO3B,MAETI,iBAAkB,aAClBC,oBAAqB,aACrBuB,iBAAkB,WAChB,OACEC,iBAAkB,WAChB,MAAO,MAIbC,MAAO,aACPC,KAAM,aACNC,UACAC,WAAY,aACZC,aAAc,cACZX,OAEJ5B,EAAQ4B,OAASD,EACjB3B,EAAQO,SAAWD,EAEnBkC,OAAOC,eAAezC,EAAS,cAAgB0C,OAAO","file":"ssr-window.min.js","sourcesContent":["/**\n * SSR Window 1.0.1\n * Better handling for window object in SSR environment\n * https://github.com/nolimits4web/ssr-window\n *\n * Copyright 2018, Vladimir Kharlampidi\n *\n * Licensed under MIT\n *\n * Released on: July 18, 2018\n */\n(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :\n\ttypeof define === 'function' && define.amd ? define(['exports'], factory) :\n\t(factory((global.ssrWindow = {})));\n}(this, (function (exports) { 'use strict';\n\nvar doc = (typeof document === 'undefined') ? {\n body: {},\n addEventListener: function addEventListener() {},\n removeEventListener: function removeEventListener() {},\n activeElement: {\n blur: function blur() {},\n nodeName: '',\n },\n querySelector: function querySelector() {\n return null;\n },\n querySelectorAll: function querySelectorAll() {\n return [];\n },\n getElementById: function getElementById() {\n return null;\n },\n createEvent: function createEvent() {\n return {\n initEvent: function initEvent() {},\n };\n },\n createElement: function createElement() {\n return {\n children: [],\n childNodes: [],\n style: {},\n setAttribute: function setAttribute() {},\n getElementsByTagName: function getElementsByTagName() {\n return [];\n },\n };\n },\n location: { hash: '' },\n} : document; // eslint-disable-line\n\nvar win = (typeof window === 'undefined') ? {\n document: doc,\n navigator: {\n userAgent: '',\n },\n location: {},\n history: {},\n CustomEvent: function CustomEvent() {\n return this;\n },\n addEventListener: function addEventListener() {},\n removeEventListener: function removeEventListener() {},\n getComputedStyle: function getComputedStyle() {\n return {\n getPropertyValue: function getPropertyValue() {\n return '';\n },\n };\n },\n Image: function Image() {},\n Date: function Date() {},\n screen: {},\n setTimeout: function setTimeout() {},\n clearTimeout: function clearTimeout() {},\n} : window; // eslint-disable-line\n\nexports.window = win;\nexports.document = doc;\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\n})));\n"]}
+130
View File
@@ -0,0 +1,130 @@
const gulp = require('gulp');
const connect = require('gulp-connect');
const open = require('gulp-open');
const header = require('gulp-header');
const uglify = require('gulp-uglify');
const sourcemaps = require('gulp-sourcemaps');
const rollup = require('rollup-stream');
const buble = require('rollup-plugin-buble');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const rename = require('gulp-rename');
const modifyFile = require('gulp-modify-file');
const pkg = require('./package.json');
const date = (function date() {
return {
year: new Date().getFullYear(),
month: ('January February March April May June July August September October November December').split(' ')[new Date().getMonth()],
day: new Date().getDate(),
};
}());
const banner = `
/**
* SSR Window ${pkg.version}
* ${pkg.description}
* ${pkg.homepage}
*
* Copyright ${date.year}, ${pkg.author}
*
* Licensed under ${pkg.license}
*
* Released on: ${date.month} ${date.day}, ${date.year}
*/
`.trim();
// UMD DIST
function umd(cb) {
const env = process.env.NODE_ENV || 'development';
rollup({
input: './src/ssr-window.js',
plugins: [buble()],
format: 'umd',
name: 'ssrWindow',
strict: true,
sourcemap: env === 'development',
banner,
})
.pipe(source('ssr-window.js', './src'))
.pipe(buffer())
.pipe(gulp.dest(`./${env === 'development' ? 'build' : 'dist'}/`))
.on('end', () => {
if (env === 'development') {
if (cb) cb();
return;
}
gulp.src('./dist/ssr-window.js')
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(header(banner))
.pipe(rename('ssr-window.min.js'))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./dist/'))
.on('end', () => {
if (cb) cb();
});
});
}
// ES MODULE DIST
function es(cb) {
const env = process.env.NODE_ENV || 'development';
rollup({
input: './src/ssr-window.js',
plugins: [buble()],
format: 'es',
name: 'ssrWindow',
strict: true,
sourcemap: env === 'development',
banner,
})
.pipe(source('ssr-window.js', './src'))
.pipe(buffer())
.pipe(rename('ssr-window.esm.js'))
.pipe(gulp.dest(`./${env === 'development' ? 'build' : 'dist'}/`))
.on('end', () => {
if (cb) cb();
});
}
gulp.task('build', (cb) => {
let cbs = 0;
umd(() => {
cbs += 1;
if (cbs === 2) cb();
});
es(() => {
cbs += 1;
if (cbs === 2) cb();
});
});
gulp.task('demo', (cb) => {
const env = process.env.NODE_ENV || 'development';
gulp.src('./demo/index.html')
.pipe(modifyFile((content) => {
if (env === 'development') {
return content
.replace('../dist/dom7.min.js', '../build/dom7.js');
}
return content
.replace('../build/dom7.js', '../dist/dom7.min.js');
}))
.pipe(gulp.dest('./demo/'))
.on('end', () => {
if (cb) cb();
});
});
gulp.task('watch', () => {
gulp.watch('./src/*.js', ['build']);
});
gulp.task('connect', () => connect.server({
root: ['./'],
livereload: true,
port: '3000',
}));
gulp.task('open', () => gulp.src('./demo/index.html').pipe(open({ uri: 'http://localhost:3000/demo/index.html' })));
gulp.task('server', ['watch', 'connect', 'open']);
+45
View File
@@ -0,0 +1,45 @@
{
"name": "ssr-window",
"version": "1.0.1",
"description": "Better handling for window object in SSR environment",
"main": "dist/ssr-window.js",
"jsnext:main": "dist/ssr-window.esm.js",
"module": "dist/ssr-window.esm.js",
"scripts": {
"build-dev": "NODE_ENV=development gulp build",
"build-prod": "NODE_ENV=production gulp build",
"test": "npm run build-dev"
},
"repository": {
"type": "git",
"url": "git+https://github.com/nolimits4web/ssr-window.git"
},
"keywords": [
"ssr",
"window",
"document"
],
"author": "Vladimir Kharlampidi",
"license": "MIT",
"bugs": {
"url": "https://github.com/nolimits4web/ssr-window/issues"
},
"homepage": "https://github.com/nolimits4web/ssr-window",
"devDependencies": {
"eslint": "^4.17.0",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-plugin-import": "^2.8.0",
"gulp": "^3.9.1",
"gulp-connect": "^5.2.0",
"gulp-header": "^2.0.1",
"gulp-modify-file": "^1.0.1",
"gulp-open": "^2.1.0",
"gulp-rename": "^1.2.2",
"gulp-sourcemaps": "^2.6.4",
"gulp-uglify": "^3.0.0",
"rollup-plugin-buble": "^0.19.1",
"rollup-stream": "^1.24.1",
"vinyl-buffer": "^1.0.1",
"vinyl-source-stream": "^2.0.0"
}
}
+37
View File
@@ -0,0 +1,37 @@
const doc = (typeof document === 'undefined') ? {
body: {},
addEventListener() {},
removeEventListener() {},
activeElement: {
blur() {},
nodeName: '',
},
querySelector() {
return null;
},
querySelectorAll() {
return [];
},
getElementById() {
return null;
},
createEvent() {
return {
initEvent() {},
};
},
createElement() {
return {
children: [],
childNodes: [],
style: {},
setAttribute() {},
getElementsByTagName() {
return [];
},
};
},
location: { hash: '' },
} : document; // eslint-disable-line
export default doc;
+4
View File
@@ -0,0 +1,4 @@
import document from './document';
import window from './window';
export { window, document };
+29
View File
@@ -0,0 +1,29 @@
import document from './document';
const win = (typeof window === 'undefined') ? {
document,
navigator: {
userAgent: '',
},
location: {},
history: {},
CustomEvent: function CustomEvent() {
return this;
},
addEventListener() {},
removeEventListener() {},
getComputedStyle() {
return {
getPropertyValue() {
return '';
},
};
},
Image() {},
Date() {},
screen: {},
setTimeout() {},
clearTimeout() {},
} : window; // eslint-disable-line
export default win;