Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 1.1.0 #617

Merged
merged 33 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b49729e
Auto update documentation
Jun 27, 2023
155361a
Corrected typo
FlorianRappl Jun 29, 2023
85ecbe6
Improved webpack stability
FlorianRappl Jul 6, 2023
00a7547
Fixed codegen
FlorianRappl Jul 6, 2023
7c9b34d
Extended importmap with optional qualifier
FlorianRappl Jul 6, 2023
a25a97f
Working on improving notification types
FlorianRappl Jul 6, 2023
1775391
Improved the notification types
FlorianRappl Jul 7, 2023
05a8847
Updated optional dependencies to be optional
FlorianRappl Jul 7, 2023
8d43620
Improved menu types
FlorianRappl Jul 7, 2023
ad2e5ac
Improved cyclic deps
FlorianRappl Jul 7, 2023
a81a4f5
feature: https://github.com/smapiot/piral/issues/610 dynamic Breadcru…
Flouwrian Jul 7, 2023
c68d537
implemented dynamic breadcrumbs
Flouwrian Jul 10, 2023
0c23913
removed breadcrumb api from sample
Flouwrian Jul 10, 2023
6e534dc
added more tests
Flouwrian Jul 10, 2023
84a6f7d
prettier
Flouwrian Jul 10, 2023
bd481c1
removed traces of feature development
Flouwrian Jul 10, 2023
4a0d55a
removed traces of Layout.tsx
Flouwrian Jul 10, 2023
d8e1c4b
Merge pull request #614 from smapiot/feature/dynamic-breadcrumbs-issu…
FlorianRappl Jul 10, 2023
d975a9a
Bump semver from 5.7.1 to 5.7.2
dependabot[bot] Jul 11, 2023
dbc28ca
Merge pull request #615 from smapiot/dependabot/npm_and_yarn/semver-5…
FlorianRappl Jul 11, 2023
4e20321
Ignore rejecting URLs
FlorianRappl Jul 11, 2023
3019e5e
Enhanced path resolution
FlorianRappl Jul 12, 2023
0832836
Updated webpack deps
FlorianRappl Jul 18, 2023
e4e3afe
Bump word-wrap from 1.2.3 to 1.2.4
dependabot[bot] Jul 18, 2023
c07aa61
Merge pull request #616 from smapiot/dependabot/npm_and_yarn/word-wra…
FlorianRappl Jul 18, 2023
560f180
Added conflict lib
FlorianRappl Jul 19, 2023
72d5d80
Merge branch 'develop' of https://github.com/smapiot/piral into develop
FlorianRappl Jul 19, 2023
3630312
Added pilet-has-non-conflicting-css
FlorianRappl Jul 24, 2023
da5f369
Updated documentation
FlorianRappl Jul 24, 2023
debc9aa
Exclusively keep this for schedules / documentation
FlorianRappl Jul 24, 2023
6579ac3
Merge branch 'develop' into documentation
FlorianRappl Jul 24, 2023
9c8f296
Updated css conflict inspector
FlorianRappl Jul 25, 2023
9f8645d
PR suggestions
FlorianRappl Jul 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name: check-documentation

on:
push:
branches: [documentation, develop]
pull_request:
branches: [documentation, develop]
schedule:
- cron: "0 9 * * *"

Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Piral Changelog

## 1.1.0 (tbd)

- Fixed retrieval of dep versions not exporting their *package.json*
- Fixed calling custom Webpack config throwing an exception
- Fixed absolute to a relative path for shared dependencies
- Updated dependencies of `piral-cli-webpack5`
- Added support for optionally centrally shared dependencies
- Added possibility to extend notification types to `piral-notifications`
- Added possibility to further extend options w.r.t. menu type in `piral-menu`
- Added lint rule for detecting potential CSS conflicts in pilets (#611)

## 1.0.2 (June 27, 2023)

- Fixed support for `piral-extension` inside shadow DOM
Expand Down
2 changes: 1 addition & 1 deletion docs/articles.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ title: Articles About Piral
- [Microfrontends on Azure](https://www.youtube.com/watch?v=_q4JDrIMvlA)
- [Microfrontends with Blazor](https://www.youtube.com/watch?v=npff2NjVXEE)
- [Microfrontends with React](https://www.youtube.com/watch?v=kG7gIF16cOk)
- [Axiom on Microfrontends](https://www.youtube.com/watch?v=u6v8wSzifPc)
- [Axinom on Microfrontends](https://www.youtube.com/watch?v=u6v8wSzifPc)
- [Introduction to Piral Inspector](https://www.youtube.com/watch?v=8CE7_X01NmM)
- [Piral Community Standup](https://www.youtube.com/watch?v=ZzqnE7XO6Tk&list=PLQ9i8GS-LNXkG1bDpT54XxOTisyRh3Rin)

Expand Down
2 changes: 1 addition & 1 deletion docs/commands/build-pilet.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Sets the maximum number of concurrent build jobs.


- Type: `number`
- Default: `16`
- Default: `12`

### `--source-maps`

Expand Down
2 changes: 1 addition & 1 deletion docs/commands/debug-pilet.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Sets the maximum number of concurrent build jobs.


- Type: `number`
- Default: `16`
- Default: `12`

### `--open`

Expand Down
2 changes: 1 addition & 1 deletion docs/commands/new-piral.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Sets the tag or version of the package to install. By default, this uses the ver

- Aliases: `--piral-version`
- Type: `string`
- Default: `"1.0.0"`
- Default: `"1.0.2"`

### `--force-overwrite`

Expand Down
6 changes: 6 additions & 0 deletions docs/commands/validate-pilet.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ Checks that no other (third-party) dependencies are bundled in.

**Options**: `'ignore' | 'active'`

### `has-non-conflicting-css`

Checks if a pilet might cause a CSS conflict. A score of 100 means that there is the least chance of a CSS conflict, while a score of 0 means that a CSS conflict is most likely. Negative values yield a warning if the CSS score is below the given number. Positive values yield an error if the CSS score is below the given number. A value of 0 turns this validation off. By default, a pilet's stylesheet having a CSS score of below 50 will result in a warning.

**Options**: `number`

### `stays-small`

Checks if the main bundle of the pilet is not exceeding a given threshold. The pilet must have been built beforehand for this validation to be conclusive. Negative values yield a warning if the absolute size in kB is exceeded. Positive values yield an error if the absolute size in kB is exceeded. A value of 0 turns this validation off. By default, a pilet's main bundle exceeding 50 kB will result in a warning.
Expand Down
21 changes: 21 additions & 0 deletions docs/concepts/I08-importmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,17 @@ This way, you can either create reusable packages containing importmaps or easil
}
```

Classically, all centrally shared dependencies are delivered with the app shell ("single bundle"). In some case it might make sense to load a shared dependency only when needed. To enable this behavior you can suffix the dependency with the `?` character - indicating that the shared dependency is optional:

```json
{
"imports": {
"lodash?": ""
},
"inherit": []
}
```

## Pilet Importmaps

For pilets the story is similar, but not exactly the same. As with a Piral instance you can define a key `importmap` in the *package.json* of the pilet. Likewise, you can either have an importmap definition in there, such as
Expand Down Expand Up @@ -221,6 +232,16 @@ Another possibility is that remote packages can be added:

In the case of remote packages, no side-bundle is created. Instead, the given URL will be used as a side-bundle. Remote packages will give you a neat way to restrict shared dependencies to a pre-defined pool, which is then re-used consistently.

To make a shared dependency optional (this is the default for pilets anyway, but needs to be done explicitly in the app shell) you need to suffix it with a question mark.

```json
{
"imports": {
"emojis-list@2.x?": "."
}
}
```

## Inheritance

In addition to the `imports` key, the `piral-cli` also supports another key called `inherit`. This is just an array of strings resolving to other packages or importmaps. For instance, the following importmap inherits the importmap from `piral-core`:
Expand Down
6 changes: 6 additions & 0 deletions mlc_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
},
{
"pattern": "^https://unpkg.com/"
},
{
"pattern": "^https://aka.ms/"
},
{
"pattern": "^https://azure.microsoft.com/free"
}
],
"aliveStatusCodes": [429, 200]
Expand Down
1 change: 1 addition & 0 deletions src/framework/piral-core/app.codegen
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module.exports = function () {
const debug = typeof cfg.debugTools === 'boolean' ? cfg.debugTools : !!process.env.DEBUG_PIRAL;
const opts = {
root,
origin: __dirname,
cat: process.env.NODE_ENV === 'test' ? 'src' : '_',
appName: process.env.BUILD_PCKG_NAME || '',
externals: (process.env.SHARED_DEPENDENCIES || '').split(',').filter(Boolean),
Expand Down
2 changes: 1 addition & 1 deletion src/framework/piral-core/app.codegen.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { AppPath, GlobalState, GlobalStateContext, NavigationApi } from './

export const publicPath: string;

export function createNavigation(): NavigationApi;
export function createNavigation(publicPath: string): NavigationApi;

export function createDefaultState(): GlobalState;

Expand Down
3 changes: 1 addition & 2 deletions src/framework/piral-core/src/Piral.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as React from 'react';
import { createInstance } from './createInstance';
import { PiralView, RegisteredRouter } from './components';
import { PiralContext } from './PiralContext';
import { publicPath } from '../app.codegen';
import type { PiralProps } from './types';

/**
Expand All @@ -22,7 +21,7 @@ const app = (
*/
export const Piral: React.FC<PiralProps> = ({ instance = createInstance(), breakpoints, children }) => (
<PiralContext instance={instance}>
<RegisteredRouter publicPath={publicPath}>
<RegisteredRouter publicPath={instance.context.navigation.publicPath}>
<PiralView breakpoints={breakpoints}>{children}</PiralView>
</RegisteredRouter>
</PiralContext>
Expand Down
35 changes: 13 additions & 22 deletions src/framework/piral-core/src/components/PiralRoutes.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,19 @@ const mountWithRouter = (node, url = '/') =>

jest.mock('../hooks');

(hooks as any).useRoutes = () => [
{
path: '/',
Component: StubHome,
},
{
path: '/custom',
Component: StubCustomPage,
},
{
path: '/foo',
Component: StubFooPage,
},
{
path: '/foo/bar',
Component: StubFooBarPage,
},
{
path: '/bar',
Component: StubBarPage,
},
];
(hooks as any).useGlobalState = (cb) =>
cb({
routes: {
'/': StubHome,
'/custom': StubCustomPage,
'/foo': StubFooPage,
'/foo/bar': StubFooBarPage,
'/bar': StubBarPage,
},
registry: {
pages: {},
},
});

const StubHome: React.FC = (props) => <div role="home" />;
StubHome.displayName = 'StubHome';
Expand Down
16 changes: 14 additions & 2 deletions src/framework/piral-core/src/components/PiralRoutes.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
import * as React from 'react';
import { RouteComponentProps, SwitchProps } from 'react-router';
import { useRoutes } from '../hooks';
import { RouteSwitchProps } from '../types';
import { useGlobalState } from '../hooks';
import { RouteSwitchProps, AppPath } from '../types';
import { useRouteFilter } from '../../app.codegen';

function useRoutes() {
FlorianRappl marked this conversation as resolved.
Show resolved Hide resolved
const routes = useGlobalState((s) => s.routes);
const pages = useGlobalState((s) => s.registry.pages);
const paths: Array<AppPath> = [];

Object.keys(routes).map((path) => paths.push({ path, Component: routes[path] }));
Object.keys(pages).map((path) => paths.push({ path, Component: pages[path].component }));

return useRouteFilter(paths);
}

/**
* The props used by the PiralRoutes component.
Expand Down
3 changes: 1 addition & 2 deletions src/framework/piral-core/src/components/wrapComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { PortalRenderer } from './PortalRenderer';
import { ForeignComponentContainer } from './ForeignComponentContainer';
import { useGlobalStateContext } from '../hooks';
import { convertComponent, none } from '../utils';
import { publicPath } from '../../app.codegen';
import type { AnyComponent, ComponentConverters, ForeignComponent, PiletApi, BaseComponentProps } from '../types';

// this is an arbitrary start number to have 6 digits
Expand Down Expand Up @@ -34,7 +33,7 @@ function wrapForeignComponent<T>(
const { destroyPortal, navigation } = useGlobalStateContext();
const id = React.useMemo(() => (portalIdBase++).toString(26), none);
// router added for backwards compatibility
const context = React.useMemo(() => ({ publicPath, navigation, router: navigation.router }), []);
const context = React.useMemo(() => ({ publicPath: navigation.publicPath, navigation, router: navigation.router }), []);
const innerProps = React.useMemo(() => ({ ...props, ...captured }), [props]);

React.useEffect(() => () => destroyPortal(id), none);
Expand Down
3 changes: 2 additions & 1 deletion src/framework/piral-core/src/defaults/DefaultErrorInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import { ExtensionSlot, SwitchErrorInfo } from '../components';
import { ExtensionSlot } from '../components/ExtensionSlot';
import { SwitchErrorInfo } from '../components/SwitchErrorInfo';
import { ErrorInfoProps } from '../types';

/**
Expand Down
3 changes: 2 additions & 1 deletion src/framework/piral-core/src/defaults/navigator_none.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function createRedirect() {
return () => null;
}

export function createNavigation(): NavigationApi {
export function createNavigation(publicPath: string): NavigationApi {
return {
get path() {
return location.pathname;
Expand All @@ -31,5 +31,6 @@ export function createNavigation(): NavigationApi {
return _noop;
},
router: undefined,
publicPath,
};
}
3 changes: 2 additions & 1 deletion src/framework/piral-core/src/defaults/navigator_v5.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function createRedirect(to: string) {
return () => <Redirect to={to} />;
}

export function createNavigation(): NavigationApi {
export function createNavigation(publicPath: string): NavigationApi {
const enhance = (location: Location, action: Action) => ({
action,
location: {
Expand Down Expand Up @@ -95,5 +95,6 @@ export function createNavigation(): NavigationApi {
return _nav;
},
},
publicPath,
};
}
3 changes: 2 additions & 1 deletion src/framework/piral-core/src/defaults/navigator_v6.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function createRedirect(to: string) {
return () => <Navigate to={to} />;
}

export function createNavigation(): NavigationApi {
export function createNavigation(publicPath: string): NavigationApi {
const enhance = (info) => ({
...info,
location: {
Expand Down Expand Up @@ -92,5 +92,6 @@ export function createNavigation(): NavigationApi {
get router() {
return _nav;
},
publicPath,
};
}
1 change: 0 additions & 1 deletion src/framework/piral-core/src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ export * from './actions';
export * from './globalState';
export * from './piletApi';
export * from './media';
export * from './routes';
export * from './setter';
export * from './sharedData';
14 changes: 0 additions & 14 deletions src/framework/piral-core/src/hooks/routes.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/framework/piral-core/src/state/createActions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as actions from '../actions';
import { UseBoundStore } from 'zustand';
import { createNavigation } from '../../app.codegen';
import { createNavigation, publicPath } from '../../app.codegen';
import { EventEmitter, GlobalState, GlobalStateContext, PiralDefineActions } from '../types';

function createContext(state: UseBoundStore<GlobalState>, events: EventEmitter) {
Expand All @@ -10,7 +10,7 @@ function createContext(state: UseBoundStore<GlobalState>, events: EventEmitter)
converters: {
html: ({ component }) => component,
},
navigation: createNavigation(),
navigation: createNavigation(publicPath),
state,
} as GlobalStateContext;
return ctx;
Expand Down
Loading
Loading