Skip to content

Commit

Permalink
Merge pull request #980 from raxjs/release-next
Browse files Browse the repository at this point in the history
hotfix: v3.8.13
  • Loading branch information
SoloJiang authored Mar 16, 2022
2 parents 4622c33 + 65dd5e6 commit c14c8a1
Show file tree
Hide file tree
Showing 35 changed files with 385 additions and 61 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
## Changelog

## 3.8.13

- Fix: build-scripts version
- Fix: spa page auto execute
- Fix: keep alive page error
- Fix: miniapp app.json pages field need be filtered by targets
- Fix: css modules `:global`

## 3.8.12

- Fix: remove `html` field for TabBar to avoid error in old PHA
Expand Down
24 changes: 24 additions & 0 deletions __tests__/build-cases/spa-keep-alive.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { buildFixture, setupBrowser } from '../utils/build';
import { IPage } from '../utils/browser';

const example = 'spa-keep-alive';
let page: IPage = null;
let browser = null;

buildFixture(example);

describe('should build web result: ', () => {
test('open /', async () => {
const res = await setupBrowser({ example });
page = res.page;
browser = res.browser;
await page.waitForFunction(`document.getElementsByTagName('img').length > 0`);
expect(await page.$$text('.title')).toStrictEqual(['Welcome to Your Rax App']);
await page.click('#link');
await page.waitForFunction(`document.getElementsByClassName('about').length > 0`);
});
});

afterAll(async () => {
await browser.close();
});
30 changes: 30 additions & 0 deletions __tests__/dev-cases/spa-keep-alive.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import * as path from 'path';
import * as fs from 'fs-extra';
import { startFixture, setupBrowser } from '../utils/start';
import { IPage } from '../utils/browser';

const example = 'spa-keep-alive';
let page: IPage = null;
let browser = null;
let devServer = null;


describe('should start web devServer: ', () => {
test('open /', async () => {
const serverOptions = await startFixture(example);
const port = serverOptions.port;
devServer = serverOptions.devServer;
const res = await setupBrowser({ port, defaultHtml: '' });
page = res.page;
browser = res.browser;
await page.waitForFunction(`document.getElementsByTagName('span').length > 0`);
expect(await page.$$text('.title')).toStrictEqual(['Welcome to Your Rax App']);
await page.click('#link');
await page.waitForFunction(`document.getElementsByClassName('about').length > 0`);
}, 120000);
});

afterAll(async () => {
await browser?.close?.();
await devServer?.close();
});
1 change: 1 addition & 0 deletions examples/spa-keep-alive/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# spa-keep-alive
4 changes: 4 additions & 0 deletions examples/spa-keep-alive/build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"targets": ["web"],
"compileDependencies": []
}
14 changes: 14 additions & 0 deletions examples/spa-keep-alive/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "basic-spa",
"description": "rax example",
"devDependencies": {
"@types/rax": "^1.0.0"
},
"scripts": {
"start": "../../packages/rax-app/bin/rax-cli.js start",
"build": "../../packages/rax-app/bin/rax-cli.js build"
},
"engines": {
"node": ">=8.0.0"
}
}
Binary file added examples/spa-keep-alive/public/rax.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions examples/spa-keep-alive/src/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"routes": [
{
"path": "/",
"source": "pages/Home/index",
"window": {
"title": "Home Page"
},
"keepAlive": true
},
{
"path": "/pages/about.html",
"source": "pages/About/index",
"window": {
"title": "About Page"
},
"keepAlive": true
}
],
"window": {
"title": "Rax App"
},
"tabBar": {
"textColor": "#dddddd",
"selectedColor": "#49a9ee",
"backgroundColor": "#ffffff",
"items": [
{
"pageName": "/",
"name": "Home Page"
},
{
"pageName": "/pages/about.html",
"text": "About"
}
]
}
}
23 changes: 23 additions & 0 deletions examples/spa-keep-alive/src/app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { runApp } from 'rax-app';

runApp({
app: {
// ErrorBoundary

// 生命周期
onShow() {
console.log('app show...');
},
onHide() {
console.log('app hide...');
},

// 获取初始数据
getInitialData: async () => {
return {
a: 1,
b: 2,
};
},
}
});
5 changes: 5 additions & 0 deletions examples/spa-keep-alive/src/components/Logo/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.logo {
width: 200rpx;
height: 180rpx;
margin-bottom: 20rpx;
}
21 changes: 21 additions & 0 deletions examples/spa-keep-alive/src/components/Logo/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { createElement, PureComponent } from 'rax';
import Image from 'rax-image';

import './index.css';

class Logo extends PureComponent {
render() {
const source = {
uri: `${process.env.PUBLIC_URL}/rax.png`,
};
console.log('with router =>', this.props);
return (
<Image
className="logo"
source={source}
/>
);
}
}

export default Logo;
16 changes: 16 additions & 0 deletions examples/spa-keep-alive/src/pages/About/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.home {
align-items: center;
margin-top: 200rpx;
}

.title {
font-size: 35rpx;
font-weight: bold;
margin: 20rpx 0;
}

.info {
font-size: 36rpx;
margin: 8rpx 0;
color: #555;
}
23 changes: 23 additions & 0 deletions examples/spa-keep-alive/src/pages/About/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { createElement, Component } from 'rax';
import View from 'rax-view';
import Text from 'rax-text';
import { getSearchParams } from 'rax-app';

import './index.css';

class About extends Component {
componentDidMount() {
console.log('about search params', getSearchParams());
}

render() {
return (
<View className="about">
<Text className="title">About Page</Text>
<Text className="info" onClick={() => (this.props as any).history.push('/')}>Go Home</Text>
</View>
);
}
}

export default About;
16 changes: 16 additions & 0 deletions examples/spa-keep-alive/src/pages/Home/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.home {
align-items: center;
margin-top: 200rpx;
}

.title {
font-size: 35rpx;
font-weight: bold;
margin: 20rpx 0;
}

.info {
font-size: 36rpx;
margin: 8rpx 0;
color: #555;
}
37 changes: 37 additions & 0 deletions examples/spa-keep-alive/src/pages/Home/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { createElement, useState } from 'rax';
import { usePageShow, usePageHide, getSearchParams } from 'rax-app';
import View from 'rax-view';
import Text from 'rax-text';
import Logo from '@/components/Logo';

import './index.css';

export default function Home(props) {
const { history } = props;
const [count, setCount] = useState(0);

const searchParams = getSearchParams();

console.log('home search params =>', searchParams);
console.log('home page props =>', props);

usePageShow(() => {
console.log('home show...');
});

usePageHide(() => {
console.log('home hide...');
});

return (
<View className="home">
<Logo />
<Text className="title">Welcome to Your Rax App</Text>
<Text className="info">More information about Rax</Text>
<Text onClick={() => {
setCount(count + 1);
}}>State: {count}</Text>
<Text className="info" id="link" onClick={() => history.push('/pages/about.html', { id: 1 })}>Go About</Text>
</View>
);
}
33 changes: 33 additions & 0 deletions examples/spa-keep-alive/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"compileOnSave": false,
"buildOnSave": false,
"compilerOptions": {
"baseUrl": ".",
"outDir": "build",
"module": "esnext",
"target": "es6",
"jsx": "preserve",
"jsxFactory": "createElement",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"lib": ["es6", "dom"],
"sourceMap": true,
"allowJs": true,
"rootDir": "./",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": false,
"importHelpers": true,
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true,
"skipLibCheck": true,
"paths": {
"@/*": ["./src/*"],
"rax-app": [".rax/index.ts"]
}
},
"include": ["src", ".rax"],
"exclude": ["node_modules", "build", "public"]
}
4 changes: 4 additions & 0 deletions packages/plugin-rax-kraken/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v2.0.1

- Fix: build-scripts version

## v2.0.0

- Feat: upgrade dependencies for webpack 5
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-rax-kraken/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "build-plugin-rax-kraken",
"version": "2.1.0",
"version": "2.1.1",
"description": "rax kraken app plugin",
"main": "lib/index.js",
"files": [
Expand All @@ -17,7 +17,7 @@
"author": "",
"license": "MIT",
"peerDependencies": {
"build-scripts": "1.0.0",
"build-scripts": "^1.0.0",
"rax": "^1.0.0"
},
"dependencies": {
Expand Down
8 changes: 8 additions & 0 deletions packages/plugin-rax-miniapp/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## v2.0.2

- Fix: miniapp app.json pages field need be filtered by targets

## v2.0.1

- Fix: build-scripts version

## v2.0.0

- Feat: upgrade dependencies for webpack 5
Expand Down
6 changes: 3 additions & 3 deletions packages/plugin-rax-miniapp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "build-plugin-rax-miniapp",
"version": "2.0.0",
"version": "2.0.2",
"description": "rax miniapp app plugin",
"main": "lib/index.js",
"files": [
Expand All @@ -17,7 +17,7 @@
"author": "",
"license": "MIT",
"peerDependencies": {
"build-scripts": "1.0.0",
"build-scripts": "^1.0.0",
"rax": "^1.0.0"
},
"dependencies": {
Expand All @@ -31,4 +31,4 @@
"miniapp-renderer": "^0.2.2",
"miniapp-webview-config": "^1.0.0"
}
}
}
7 changes: 7 additions & 0 deletions packages/plugin-rax-miniapp/src/filterByTarget.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function filterByTarget(routes, { target }) {
return routes.filter(({ targets }) => {
if (!targets) return true;
return targets.includes(target);
});
}

Loading

0 comments on commit c14c8a1

Please sign in to comment.