-
Notifications
You must be signed in to change notification settings - Fork 948
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
187 changed files
with
17,828 additions
and
583 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
.DS_Store | ||
node_modules | ||
/dist | ||
|
||
# local env files | ||
.env.local | ||
.env.*.local | ||
|
||
# Log files | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Editor directories and files | ||
.idea | ||
.vscode | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# @hippy/vue-next demo | ||
|
||
|
||
### Introduction | ||
This package is the demo project for @hippy/vue-next. Project include most use case for | ||
@hippy/vue-next. Just try it. | ||
|
||
### Usage | ||
Read the hippy framework [doc](https://github.com/Tencent/Hippy/blob/master/README.md#-getting-started) and learn | ||
how to use. | ||
|
||
### How To Use SSR | ||
|
||
we were support SSR for @hippy/vue-next. here is only how to use SSR. how to use vue-next doc is [here](https://hippyjs.org/en-us/#/hippy-vue/vue3) | ||
|
||
1. Before running vue-next-ssr-demo, you should run `npm run init` at root directory to install dependencies and build front-end sdk packages. | ||
2. Then run `cd examples/hippy-vue-next-ssr-demo` and `npm install --legacy-peer-deps` to install demo dependencies. | ||
|
||
Now determine which environment you want build | ||
|
||
> Because our server listening port 8080, so if you are using android device, you should run `adb reverse tcp:8080 tcp:8080` | ||
> to forward mobile device port to pc port, iOS simulator doesn't need this step. | ||
ensure you were at `examples/hippy-vue-next-ssr-demo`. | ||
|
||
#### Development | ||
|
||
1. run `npm run ssr:dev-build` to build client entry & client bundle, then running hippy debug server | ||
2. run `npm run ssr:dev-server` to build server bundle and start SSR web server to listen port **8080**. | ||
3. debug your app with [reference](https://hippyjs.org/en-us/#/guide/debug) | ||
> You can change server listen port 8080 in `server.ts` by your self, but you also need change request port 8080 in | ||
> `src/main-client.ts` and modify the adb reverse port, ensure port is same at three place | ||
#### Production | ||
|
||
1. run `npm run ssr:prod-build` to build client entry, server bundle, client bundle | ||
2. run `npm run ssr:prod-server` to start SSR web server to listen port **8080**. | ||
3. test your app | ||
> In production, you can use process manage tool to manage your NodeJs process, like pm2. | ||
> | ||
> And you should deploy you web server at real server with real domain, then you can request | ||
> SSR cgi like https://xxx.com/getSsrFirstScreenData | ||
> | ||
#### Tips | ||
> Usage of non SSR is [here](https://hippyjs.org/en-us/#/guide/integration) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
declare module '*.jpg'; | ||
declare module '*.png'; | ||
declare module '*.vue' { | ||
import { defineComponent } from 'vue'; | ||
const Component: ReturnType<typeof defineComponent>; | ||
export default Component; | ||
} | ||
|
||
type NeedToTyped = any; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
{ | ||
"name": "hippy-vue-next-demo", | ||
"version": "3.0.0", | ||
"description": "A SSR Demo Example For Hippy-Vue-Next Library To Show.", | ||
"private": true, | ||
"webMain": "./src/main-web.ts", | ||
"nativeMain": "./src/main-native.ts", | ||
"serverMain": "./src/main-server.ts", | ||
"serverEntry": "./server.ts", | ||
"ssrMain": "./src/main.ts", | ||
"repository": "https://github.com/Tencent/Hippy/tree/master/examples/hippy-vue-next-demo", | ||
"license": "Apache-2.0", | ||
"author": "OpenHippy Team", | ||
"scripts": { | ||
"hippy:dev": "node ./scripts/env-polyfill.js hippy-dev -c ./scripts/hippy-webpack.dev.js", | ||
"web:dev": "npm run hippy:dev & node ./scripts/env-polyfill.js webpack serve --config ./scripts/hippy-webpack.web-renderer.dev.js", | ||
"web:build": "node ./scripts/env-polyfill.js webpack --config ./scripts/hippy-webpack.web-renderer.js", | ||
"ssr:dev-client": "node ./scripts/env-polyfill.js hippy-dev -c ./scripts/webpack-ssr-config/client.dev.js", | ||
"ssr:dev-server": "node ./scripts/env-polyfill.js && node ./scripts/webpack.ssr.dev.js", | ||
"ssr:prod-build": "node ./scripts/webpack.ssr.build.js", | ||
"ssr:prod-server": "node ./dist/server/index.js --mode production" | ||
}, | ||
"dependencies": { | ||
"@hippy/vue-router-next-history": "latest", | ||
"@hippy/web-renderer": "latest", | ||
"@hippy/vue-next": "latest", | ||
"@hippy/vue-next-server-renderer": "file:../../packages/hippy-vue-next-server-renderer", | ||
"@hippy/vue-next-style-parser": "file:../../packages/hippy-vue-next-style-parser", | ||
"@vue/runtime-core": "^3.2.46", | ||
"@vue/shared": "^3.2.46", | ||
"core-js": "^3.20.2", | ||
"vue": "^3.2.46", | ||
"vue-router": "^4.0.12", | ||
"express": "^4.18.2", | ||
"pinia": "2.0.30" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.12.0", | ||
"@babel/plugin-proposal-class-properties": "^7.10.4", | ||
"@babel/plugin-proposal-decorators": "^7.10.5", | ||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.10.4", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.5.5", | ||
"@babel/plugin-proposal-optional-chaining": "^7.10.4", | ||
"@babel/plugin-transform-async-to-generator": "^7.5.0", | ||
"@babel/plugin-transform-runtime": "^7.11.0", | ||
"@babel/polyfill": "^7.12.0", | ||
"@babel/preset-env": "^7.12.0", | ||
"@babel/runtime": "^7.16.0", | ||
"@hippy/debug-server-next": "latest", | ||
"@hippy/hippy-dynamic-import-plugin": "^2.0.0", | ||
"@hippy/hippy-hmr-plugin": "^0.1.0", | ||
"@hippy/rejection-tracking-polyfill": "^1.0.0", | ||
"@hippy/vue-css-loader": "^2.0.1", | ||
"@vitejs/plugin-vue": "^1.9.4", | ||
"@hippy/vue-next-compiler-ssr": "file:../../packages/hippy-vue-next-compiler-ssr", | ||
"@types/shelljs": "^0.8.5", | ||
"@vue/cli-service": "^4.5.19", | ||
"@vue/compiler-sfc": "^3.2.46", | ||
"babel-loader": "^8.1.0", | ||
"case-sensitive-paths-webpack-plugin": "^2.2.0", | ||
"chokidar": "^3.5.3", | ||
"clean-webpack-plugin": "^4.0.0", | ||
"webpack-manifest-plugin": "^4.1.1", | ||
"cross-env": "^7.0.3", | ||
"cross-env-os": "^7.1.1", | ||
"esbuild": "^0.13.14", | ||
"esbuild-loader": "^2.18.0", | ||
"file-loader": "^4.3.0", | ||
"less": "^4.1.2", | ||
"less-loader": "^7.1.0", | ||
"shelljs": "^0.8.5", | ||
"terser": "^4.8.0", | ||
"ts-loader": "^8.4.0", | ||
"@types/express": "^4.17.17", | ||
"url-loader": "^4.0.0", | ||
"vue-loader": "^17.0.0", | ||
"webpack": "^4.46.0", | ||
"webpack-cli": "^4.7.2" | ||
}, | ||
"engines": { | ||
"node": ">=15" | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
driver/js/examples/hippy-vue-next-ssr-demo/scripts/env-polyfill.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
const { exec } = require('shelljs'); | ||
|
||
const runScript = (scriptStr) => { | ||
console.log(`Full command execute: "${scriptStr}"`); | ||
const result = exec(scriptStr, { stdio: 'inherit' }); | ||
if (result.code !== 0) { | ||
console.error(`❌ Execute cmd - "${scriptStr}" error: ${result.stderr}`); | ||
process.exit(1); | ||
} | ||
}; | ||
|
||
const toNum = (originalNum) => { | ||
const num = `${originalNum}`; | ||
const versionList = num.split('.'); | ||
const currentSplitLength = versionList.length; | ||
if (currentSplitLength !== 4) { | ||
let index = currentSplitLength; | ||
while (index < 4) { | ||
versionList.push('0'); | ||
index += 1; | ||
} | ||
} | ||
const r = ['0000', '000', '00', '0', '']; | ||
for (let i = 0; i < versionList.length; i += 1) { | ||
let len = versionList[i].length; | ||
if (len > 4) { | ||
len = 4; | ||
versionList[i] = versionList[i].slice(0, 4); | ||
} | ||
versionList[i] = r[len] + versionList[i]; | ||
} | ||
return versionList.join(''); | ||
}; | ||
|
||
const versionCompare = (targetVer, currentVer) => { | ||
if (!targetVer || !currentVer) return 1; | ||
const numA = toNum(currentVer); | ||
const numB = toNum(targetVer); | ||
if (numA === numB) { | ||
return 0; | ||
} | ||
return numA < numB ? -1 : 1; | ||
}; | ||
|
||
const LEGACY_OPENSSL_VERSION = '3.0.0'; | ||
const scriptString = process.argv.slice(2).join(' '); | ||
let envPrefixStr = ''; | ||
|
||
console.log(`Start to execute cmd: "${scriptString}"`); | ||
console.log(`Current openssl version: ${process.versions.openssl}`); | ||
|
||
const result = /^(\d+\.\d+\.\d+).*$/.exec(process.versions.openssl.toString().trim()); | ||
if (result && result[1]) { | ||
const currentVersion = result[1]; | ||
const compareResult = versionCompare(LEGACY_OPENSSL_VERSION, currentVersion); | ||
if (compareResult >= 0) { | ||
envPrefixStr += 'NODE_OPTIONS=--openssl-legacy-provider'; | ||
} | ||
} | ||
|
||
runScript(`${envPrefixStr} ${scriptString}`); // start to execute cmd |
Oops, something went wrong.