Skip to content

Commit

Permalink
Release/2.5.0 (#320)
Browse files Browse the repository at this point in the history
Closes: #325

* feat: 🎸 consistent api (#324)

✅ Closes: #299, #297

* fix: 🐛 activePath is ignored (#357)
  • Loading branch information
maoxiaoke authored Aug 13, 2021
1 parent 343fdcf commit ba08918
Show file tree
Hide file tree
Showing 43 changed files with 10,914 additions and 515 deletions.
17 changes: 8 additions & 9 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,19 1,18 @@
const { tslint, deepmerge } = require('@ice/spec');
const { getESLintConfig } = require('@iceworks/spec');

module.exports = deepmerge(tslint, {
module.exports = getESLintConfig('react-ts', {
env: {
jest: true,
},
rules: {
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/interface-name-prefix': 1,
'no-unused-expressions': 'off',
},
settings: {
react: {
pragma: 'React',
version: 'detect',
},
'no-async-promise-executor': 'off',
'no-mixed-operators': 'off',
'react/static-property-placement': 'off',
'@iceworks/best-practices/recommend-functional-component': 'off',
'@iceworks/best-practices/recommend-polyfill': 'off',
},
});

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 19,4 @@ build/
# Docusaurus Generated files
.docusaurus
.cache-loader
.vscode/launch.json
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 2,14 @@

See [https://github.com/ice-lab/icestark/releases](https://github.com/ice-lab/icestark/releases) for what has changed in each version of icestark.

## 2.5.0

- [feat] `path` is deprecated and using the more powerful `activePath` instead. ([#299, #297, #209](https://github.com/ice-lab/icestark/issues/299))
- [feat] debug mirco-frontends are accessiable by using source maps, even in sandbox. ([#259](https://github.com/ice-lab/icestark/issues/259))
- [fix] call callCapturedEventListeners later to prevent double Prompt. ([#325](https://github.com/ice-lab/icestark/issues/325))
- [refact] refactor url-matching algorithm.


## 2.4.0

- [feat] support appending extra attributes for scripts when using `loadScriptMode = script`. ([#276](https://github.com/ice-lab/icestark/issues/276))
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
{
"name": "@ice/stark",
"version": "2.4.0",
"version": "2.5.0",
"description": "Icestark is a JavaScript library for multiple projects, Ice workbench solution.",
"scripts": {
"install:deps": "rm -rf node_modules && rm -rf ./packages/*/node_modules && yarn install && lerna exec -- npm install",
Expand Down Expand Up @@ -56,7 56,7 @@
"devDependencies": {
"@commitlint/cli": "^7.5.2",
"@commitlint/config-conventional": "^7.5.0",
"@ice/spec": "^0.1.4",
"@iceworks/spec": "^1.3.2",
"@testing-library/jest-dom": "^4.2.3",
"@testing-library/react": "^9.3.2",
"@types/jest": "^24.0.12",
Expand All @@ -65,7 65,7 @@
"@types/react": "^16.8.19",
"@types/url-parse": "^1.4.3",
"codecov": "^3.4.0",
"eslint": "^5.16.0",
"eslint": "^7.31.0",
"husky": "^2.2.0",
"jest": "^24.7.1",
"jest-fetch-mock": "^2.1.2",
Expand All @@ -76,7 76,7 @@
"stylelint": "^10.1.0",
"ts-jest": "^24.0.2",
"ts-node": "^9.0.0",
"typescript": "^3.4.4",
"typescript": "^4.3.5",
"urllib": "^2.36.1"
},
"resolutions": {
Expand Down
1 change: 0 additions & 1 deletion packages/icestark-app/src/AppLink.tsx
Original file line number Diff line number Diff line change
@@ -1,4 1,3 @@
/* eslint-disable react/jsx-filename-extension */
import * as React from 'react';
import formatUrl from './util/formatUrl';

Expand Down
4 changes: 2 additions & 2 deletions packages/icestark-app/src/appHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 5,14 @@ const appHistory = {
window.history.pushState(
{},
null,
formatUrl(url, hashType)
formatUrl(url, hashType),
);
},
replace: (url: string, hashType?: boolean) => {
window.history.replaceState(
{},
null,
formatUrl(url, hashType)
formatUrl(url, hashType),
);
},
};
Expand Down
2 changes: 1 addition & 1 deletion packages/icestark-app/src/renderNotFound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 3,7 @@ import { getCache } from './cache';
/**
* CustomEvent Polyfill for IE
*/
(function() {
(function () {
if (typeof (window as any).CustomEvent === 'function') return false;

function CustomEvent(event, params) {
Expand Down
2 changes: 1 addition & 1 deletion packages/icestark-app/src/setBasename.ts
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
import { setCache } from './cache';

function setBasename (base: string) {
function setBasename(base: string) {
return setCache('basename', base);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/icestark-app/src/setLibraryName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 4,7 @@ const setLibraryName = (library: string | string[]): void => {
if (!library) {
console.error('[@ice/stark-app] setLibraryName: params can not be empty!');
return;
};
}
setCache('library', library);
};

Expand Down
3 changes: 1 addition & 2 deletions packages/icestark-data/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 8,6 @@ const storeNameSpace = 'store';

type StringSymbolUnion = string | symbol;

// eslint-disable-next-line @typescript-eslint/interface-name-prefix
interface IO {
set(key: string | symbol | object, value?: any): void;
get(key?: StringSymbolUnion): void;
Expand Down Expand Up @@ -58,7 57,7 @@ class Store implements IO, Hooks {
}

if (typeof key !== 'string' && typeof key !== 'symbol') {
warn(`store.get: key should be string / symbol`);
warn('store.get: key should be string / symbol');
return null;
}

Expand Down
4 changes: 4 additions & 0 deletions packages/icestark-module/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 1,9 @@
# Changelog

## 1.4.2

- [feat] append sourceURL to js resources to make sourcemaps work.

## 1.4.1

- [refact] compatible with sandbox spell error.
Expand Down
2 changes: 1 addition & 1 deletion packages/icestark-module/package.json
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
{
"name": "@ice/stark-module",
"version": "1.4.1",
"version": "1.4.2",
"description": "toolkit for load standard micro-module",
"main": "lib/index.js",
"scripts": {
Expand Down
40 changes: 22 additions & 18 deletions packages/icestark-module/src/MicroModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 22,17 @@ interface State {
* default render component, mount all modules
*/
export default class MicroModule extends React.Component<any, State> {
static defaultProps = {
loadingComponent: null,
handleError: () => {},
};

private moduleInfo = null;

private mountNode = null;

private unmout = false;

static defaultProps = {
loadingComponent: null,
handleError: () => {},
};

constructor(props) {
super(props);
this.state = {
Expand Down Expand Up @@ -61,15 61,15 @@ export default class MicroModule extends React.Component<any, State> {
}
}

getModuleInfo () {
getModuleInfo() {
const { moduleInfo } = this.props;
this.moduleInfo = moduleInfo || getModules().filter(m => m.name === this.props.moduleName)[0];
this.moduleInfo = moduleInfo || getModules().filter((m) => m.name === this.props.moduleName)[0];
if (!this.moduleInfo) {
console.error(`[icestark] Can't find ${this.props.moduleName} module in modules config`);
}
}

validateRender () {
validateRender() {
const { render } = this.moduleInfo || {};

if (render && typeof render !== 'function') {
Expand All @@ -78,7 78,6 @@ export default class MicroModule extends React.Component<any, State> {
return render && typeof render === 'function';
}


async mountModule() {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { sandbox, moduleInfo, wrapperClassName, wrapperStyle, loadingComponent, handleError, ...rest } = this.props;
Expand All @@ -94,7 93,7 @@ export default class MicroModule extends React.Component<any, State> {
this.setState({ loading: true });

try {
const { mount, component } = await loadModule(this.moduleInfo, sandbox);
const { mount, component } = await loadModule(this.moduleInfo, sandbox);
const lifecycleMount = mount;
this.setState({ loading: false });
if (lifecycleMount && component) {
Expand All @@ -121,14 120,19 @@ export default class MicroModule extends React.Component<any, State> {
const { render } = this.moduleInfo || {};

const { wrapperClassName, wrapperStyle, loadingComponent } = this.props;
return loading ? loadingComponent
: (<div className={wrapperClassName} style={wrapperStyle} ref={ref => this.mountNode = ref} >
{
this.moduleInfo && this.validateRender() && render()
}
</div>);
return loading
? loadingComponent
: (
<div
className={wrapperClassName}
style={wrapperStyle}
ref={(ref) => { this.mountNode = ref; }}
>
{ this.moduleInfo && this.validateRender() && render() }
</div>
);
}
};
}

/**
* Render Modules, compatible with Render and <Render>
Expand All @@ -147,4 151,4 @@ export function renderModules(modules: StarkModule[], render: any, componentProp

console.warn('Please set render Component, try use MicroModule and mount first module');
return <MicroModule moduleName={modules[0]?.name} {...componentProps} />;
};
}
4 changes: 2 additions & 2 deletions packages/icestark-module/src/assist.ts
Original file line number Diff line number Diff line change
@@ -1,3 1,3 @@
export function shallowCompare<T extends object> (source: T , target: T) {
return Object.keys(source).every(key => source[key] === target[key]);
export function shallowCompare<T extends object>(source: T, target: T) {
return Object.keys(source).every((key) => source[key] === target[key]);
}
20 changes: 6 additions & 14 deletions packages/icestark-module/src/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 14,14 @@ function shouldSkipProperty(p, globalWindow) {
|| isIE11 && globalWindow[p] && typeof window !== 'undefined' && globalWindow[p].parent === window;
}

export function getGlobalProp (globalWindow) {
export function getGlobalProp(globalWindow) {
let cnt = 0;
let lastProp;
// eslint-disable-next-line no-restricted-syntax
for (const p in globalWindow) {
// do not check frames cause it could be removed during import
if (shouldSkipProperty(p, globalWindow))
// eslint-disable-next-line no-continue
continue;
if (cnt === 0 && p !== firstGlobalProp || cnt === 1 && p !== secondGlobalProp)
return p;
if (shouldSkipProperty(p, globalWindow)) { continue; }
if (cnt === 0 && p !== firstGlobalProp || cnt === 1 && p !== secondGlobalProp) { return p; }
cnt ;
lastProp = p;
}
Expand All @@ -42,7 39,7 @@ export function getGlobalProp (globalWindow) {
}
}

export function noteGlobalProps (globalWindow) {
export function noteGlobalProps(globalWindow) {
// alternatively Object.keys(global).pop()
// but this may be faster (pending benchmarks)
firstGlobalProp = undefined;
Expand All @@ -51,13 48,8 @@ export function noteGlobalProps (globalWindow) {
// eslint-disable-next-line no-restricted-syntax
for (const p in globalWindow) {
// do not check frames cause it could be removed during import
if (shouldSkipProperty(p, globalWindow))
// eslint-disable-next-line no-continue
continue;
if (!firstGlobalProp)
firstGlobalProp = p;
else if (!secondGlobalProp)
secondGlobalProp = p;
if (shouldSkipProperty(p, globalWindow)) { continue; }
if (!firstGlobalProp) { firstGlobalProp = p; } else if (!secondGlobalProp) { secondGlobalProp = p; }
lastGlobalProp = p;
}
return lastGlobalProp;
Expand Down
12 changes: 9 additions & 3 deletions packages/icestark-module/src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 4,7 @@ import { StarkModule } from './modules';

export interface ImportTask {
[name: string]: Promise<string[]>;
};
}

export type PromiseModule = Promise<Response>;

Expand All @@ -23,7 23,13 @@ export default class ModuleLoader {
}
const urls = Array.isArray(url) ? url : [url];

const task = Promise.all(urls.map((scriptUrl) => fetch(scriptUrl).then((res) => res.text())));
const task = Promise.all(
urls.map(
(scriptUrl) => fetch(scriptUrl)
.then((res) => res.text())
.then((res) => `${res} \n //# sourceURL=${scriptUrl}`),
),
);
this.importTask[name] = task;
return task;
}
Expand Down Expand Up @@ -77,4 83,4 @@ export default class ModuleLoader {
return moduleInfo;
});
}
};
}
Loading

0 comments on commit ba08918

Please sign in to comment.