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 0.15.10 #597

Merged
merged 20 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Piral Changelog

## 0.15.10 (tbd)

- Fixed `.krasrc` files in pilets to take precendence over emulator
- Fixed support for `pilets` section in `piral.json` of Piral instance
- Fixed issue with numeric custom fields supplied to `pilet publish`
- Updated documentation of `piral-ng` with support of Angular 15
- Updated `piral-debug-utils` to also work more seamlessly with `piral-base`
- Updated `piral-cli` to have `pilet build` working without any Piral instances
- Added variants of `piral-base` (minimal, Node.js, full)
- Added support for new pilet schema `v3` (default remains at `v2`)

## 0.15.9 (April 11, 2023)

- Fixed transport of `state` in routes with `piral-blazor`
Expand Down
2 changes: 1 addition & 1 deletion docs/static/schemas/pilet-v0.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"properties": {
"schemaVersion": {
"type": "string",
"enum": ["none", "v0", "v1", "v2"],
"enum": ["none", "v0", "v1", "v2", "v3"],
"description": "The default output schema to be used when building the pilet."
},
"piralInstances": {
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/04-the-pilet-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const MyExtension: React.FC<ExtensionComponentProps<MyExtensionParams>> = ({ par
return null;
}

if (!Array.isArray(items) || items.some(m => typeof m !== 'number')) {
if (!Array.isArray(params.items) || params.items.some(m => typeof m !== 'number')) {
return null;
}

Expand Down
49 changes: 39 additions & 10 deletions src/converters/piral-ng/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ The basic dependencies look as follows:
"@angular/platform-browser": "^7",
"@angular/platform-browser-dynamic": "^7",
"core-js": "^3.15.2",
"rxjs": "^6.0.0",
"rxjs": "^6.4",
"zone.js": "~0.9"
}
```
Expand All @@ -608,7 +608,7 @@ The basic dependencies look as follows:
"@angular/platform-browser": "^8",
"@angular/platform-browser-dynamic": "^8",
"core-js": "^3.15.2",
"rxjs": "^6.0.0",
"rxjs": "^6.4",
"zone.js": "~0.9"
}
```
Expand All @@ -628,7 +628,7 @@ The basic dependencies look as follows:
"@angular/platform-browser": "^9",
"@angular/platform-browser-dynamic": "^9",
"core-js": "^3.15.2",
"rxjs": "~6.4",
"rxjs": "~6.5",
"zone.js": "~0.9"
}
```
Expand All @@ -648,7 +648,7 @@ The basic dependencies look as follows:
"@angular/platform-browser": "^10",
"@angular/platform-browser-dynamic": "^10",
"core-js": "^3.15.2",
"rxjs": "~6.4",
"rxjs": "~6.5",
"zone.js": "~0.9"
}
```
Expand All @@ -668,7 +668,7 @@ The basic dependencies look as follows:
"@angular/platform-browser": "^11",
"@angular/platform-browser-dynamic": "^11",
"core-js": "^3.15.2",
"rxjs": "~6.4",
"rxjs": "~6.5",
"zone.js": "~0.9"
}
```
Expand All @@ -689,7 +689,7 @@ The basic dependencies look as follows:
"@angular/platform-browser-dynamic": "^12",
"core-js": "^3.15.2",
"rxjs": "~6.4",
"zone.js": "~0.9"
"zone.js": "0.11.4"
}
```

Expand All @@ -708,8 +708,8 @@ The basic dependencies look as follows:
"@angular/platform-browser": "^13",
"@angular/platform-browser-dynamic": "^13",
"core-js": "^3.19.0",
"rxjs": "~7.4",
"zone.js": "~0.9"
"rxjs": "^7.4",
"zone.js": "0.11.4"
}
```

Expand Down Expand Up @@ -737,8 +737,37 @@ The basic dependencies look as follows:
"@angular/platform-browser": "^14",
"@angular/platform-browser-dynamic": "^14",
"core-js": "^3.19.0",
"rxjs": "~7.4",
"zone.js": "~0.11"
"rxjs": "^7.4",
"zone.js": "~0.12.0"
}
```

Besides the usual imports the explicit import of the `@angular/compiler` package may be necessary.

So include in your app shell as preamble:

```js
import 'core-js/proposals/reflect-metadata';
import '@angular/compiler';
```

### Angular 15

In general, Angular 15 seems to work and is **supported**.

The basic dependencies look as follows:

```json
{
"@angular/common": "^15",
"@angular/compiler": "^15",
"@angular/core": "^15",
"@angular/router": "^15",
"@angular/platform-browser": "^15",
"@angular/platform-browser-dynamic": "^15",
"core-js": "^3.19.0",
"rxjs": "^7.4",
"zone.js": "~0.13.0"
}
```

Expand Down
7 changes: 4 additions & 3 deletions src/converters/piral-ng/src/startup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ if (process.env.NODE_ENV === 'development') {
console.log('Running in outdated mode (Angular 5-8)');
},
current() {
console.log('Running in current mode (Angular 9-14)');
console.log('Running in current mode (Angular 9-15)');
},
next() {
console.log('Running in next mode (Angular 15)');
console.log('Running in next mode (Angular 16)');
},
unknown() {
console.log('Running with an unknown version of Angular');
Expand All @@ -135,7 +135,8 @@ if (process.env.NODE_ENV === 'development') {
v12: versionHandlers.current,
v13: versionHandlers.current,
v14: versionHandlers.current,
v15: versionHandlers.next,
v15: versionHandlers.current,
v16: versionHandlers.next,
};

const handler = getVersionHandler(versions) || versionHandlers.unknown;
Expand Down
1 change: 1 addition & 0 deletions src/framework/piral-base/full.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib/index.full';
1 change: 1 addition & 0 deletions src/framework/piral-base/minimal.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib/index.minimal';
1 change: 1 addition & 0 deletions src/framework/piral-base/node.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib/index.node';
49 changes: 26 additions & 23 deletions src/framework/piral-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,38 @@
"author": "smapiot",
"homepage": "https://piral.io",
"license": "MIT",
"module": "esm/index.js",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"module": "dist/dist/piral-base-full.js",
"main": "dist/piral-base-node.js",
"typings": "lib/index.full.d.ts",
"piletApiTypings": "lib/types/runtime.d.ts",
"exports": {
".": {
"import": "./esm/index.js",
"require": "./lib/index.js"
"node": "./dist/piral-base-node.js",
"import": "./dist/piral-base-full.mjs",
"types": "./lib/index.full.d.ts"
},
"./esm/*": {
"import": "./esm/*"
"./minimal": {
"import": "./dist/piral-base-minimal.mjs",
"types": "./lib/index.minimal.d.ts"
},
"./lib/*": {
"require": "./lib/*"
"./node": {
"require": "./dist/piral-base-node.js",
"types": "./lib/index.node.d.ts"
},
"./_/*": {
"import": "./esm/*.js",
"require": "./lib/*.js"
"./full": {
"import": "./dist/piral-base-full.mjs",
"types": "./lib/index.full.d.ts"
},
"./package.json": "./package.json"
},
"sideEffects": false,
"files": [
"esm",
"dist",
"lib",
"src"
"src",
"full.d.ts",
"minimal.d.ts",
"node.d.ts"
],
"funding": {
"type": "github",
Expand All @@ -58,15 +64,12 @@
"url": "https://github.com/smapiot/piral/issues"
},
"scripts": {
"cleanup": "rimraf esm lib",
"build": "yarn build:commonjs && yarn build:esnext",
"build:commonjs": "yarn build:commonjs:tsc && rimraf lib/utils/system.js && yarn build:commonjs:system",
"build:commonjs:tsc": "tsc --project tsconfig.json --outDir lib --module commonjs",
"build:commonjs:system": "esbuild src/utils/system.ts --bundle --outfile=lib/utils/system.js --format=cjs",
"build:esnext": "yarn build:esnext:tsc && rimraf esm/utils/system.js && yarn build:esnext:system",
"build:esnext:tsc": "tsc --project tsconfig.json --outDir esm --module esnext",
"build:esnext:system": "esbuild src/utils/system.ts --bundle --outfile=esm/utils/system.js --format=esm",
"typedoc": "typedoc --json ../../../docs/types/piral-base.json src --exclude \"src/**/*.test.*\"",
"cleanup": "rimraf dist esm lib",
"build": "yarn build:node && yarn build:full && yarn build:minimal && tsc --project tsconfig.json",
"build:node": "esbuild src/index.node.ts --bundle --outfile=dist/piral-base-node.js --platform=node --format=cjs --external:tslib --target=es2020",
"build:full": "esbuild src/index.full.ts --bundle --outfile=dist/piral-base-full.mjs --platform=browser --format=esm --external:tslib --target=es2020",
"build:minimal": "esbuild src/index.minimal.ts --bundle --outfile=dist/piral-base-minimal.mjs --platform=browser --format=esm --external:tslib --target=es2020",
"typedoc": "typedoc src/index.full.ts --json ../../../docs/types/piral-base.json src --exclude \"src/**/*.test.*\"",
"test": "echo \"Error: run tests from root\" && exit 1"
},
"dependencies": {
Expand Down
3 changes: 3 additions & 0 deletions src/framework/piral-base/src/aggregate.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import 'systemjs/dist/system.js';
import 'systemjs/dist/extras/named-register.js';

import { runPilet } from './aggregate';

describe('Piral-Base aggregate module', () => {
Expand Down
3 changes: 3 additions & 0 deletions src/framework/piral-base/src/create.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import 'systemjs/dist/system.js';
import 'systemjs/dist/extras/named-register.js';

import { startLoadingPilets } from './create';

describe('Piral-Base create module', () => {
Expand Down
14 changes: 14 additions & 0 deletions src/framework/piral-base/src/index.full.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import 'systemjs/dist/system.js';
import 'systemjs/dist/extras/named-register.js';

export * from './aggregate';
export * from './api';
export * from './create';
export * from './events';
export * from './inspect';
export * from './lifecycle';
export * from './load';
export * from './loader';
export * from './strategies';
export * from './types';
export * from './utils';
6 changes: 6 additions & 0 deletions src/framework/piral-base/src/index.minimal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import 'systemjs/dist/system.js';
import 'systemjs/dist/extras/named-register.js';

export * from './events';
export * from './types';
export * from './utils/system';
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import 'systemjs';
import 'systemjs/dist/extras/named-register.js';

export * from './aggregate';
export * from './api';
export * from './create';
Expand Down
3 changes: 3 additions & 0 deletions src/framework/piral-base/src/inspect.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import 'systemjs/dist/system.js';
import 'systemjs/dist/extras/named-register.js';

import { inspectPilet } from './inspect';

describe('inspect pilet module', () => {
Expand Down
17 changes: 15 additions & 2 deletions src/framework/piral-base/src/inspect.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
import { setupSinglePilet, setupPiletBundle } from './lifecycle';
import type { PiletEntry, PiletV0Entry, PiletV1Entry, PiletV2Entry, PiletBundleEntry, PiletRunner } from './types';
import type {
PiletEntry,
PiletV0Entry,
PiletV1Entry,
PiletV2Entry,
PiletV3Entry,
PiletBundleEntry,
PiletRunner,
} from './types';

export type InspectPiletV0 = ['v0', PiletV0Entry, PiletRunner];

export type InspectPiletV1 = ['v1', PiletV1Entry, PiletRunner];

export type InspectPiletV2 = ['v2', PiletV2Entry, PiletRunner];

export type InspectPiletV3 = ['v3', PiletV3Entry, PiletRunner];

export type InspectPiletBundle = ['bundle', PiletBundleEntry, PiletRunner];

export type InspectPiletUnknown = ['unknown', PiletEntry, PiletRunner];
Expand All @@ -15,13 +25,16 @@ export type InspectPiletResult =
| InspectPiletV0
| InspectPiletV1
| InspectPiletV2
| InspectPiletV3
| InspectPiletUnknown
| InspectPiletBundle;

export function inspectPilet(meta: PiletEntry): InspectPiletResult {
const inBrowser = typeof document !== 'undefined';

if (inBrowser && 'link' in meta && meta.spec === 'v2') {
if ('link' in meta && meta.spec === 'v3') {
return ['v3', meta, setupSinglePilet];
} else if (inBrowser && 'link' in meta && meta.spec === 'v2') {
return ['v2', meta, setupSinglePilet];
} else if (inBrowser && 'requireRef' in meta && meta.spec !== 'v2') {
return ['v1', meta, setupSinglePilet];
Expand Down
3 changes: 3 additions & 0 deletions src/framework/piral-base/src/lifecycle/cleanup.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import 'systemjs/dist/system.js';
import 'systemjs/dist/extras/named-register.js';

import { prepareCleanup, runCleanup } from './cleanup';

describe('Cleaning up Modules', () => {
Expand Down
13 changes: 7 additions & 6 deletions src/framework/piral-base/src/lifecycle/cleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,25 @@ const evtName = 'unload-pilet';
* @param hooks The hooks to use in the cleanup process.
*/
export function runCleanup(app: SinglePilet, api: PiletApi, hooks: PiletLifecycleHooks) {
const css = document.querySelector(`link[data-origin=${JSON.stringify(app.name)}]`);
const url = app.basePath;
if (typeof document !== 'undefined') {
const css = document.querySelector(`link[data-origin=${JSON.stringify(app.name)}]`);
css?.remove();
}

css?.remove();
const url = app.basePath;

callfunc(app.teardown, api);
callfunc(hooks.cleanupPilet, app);

// check if this was actually set up using a require reference
if ('requireRef' in app) {
const depName = app.requireRef;
delete window[depName];
delete globalThis[depName];
}

// remove the pilet's evaluated modules from SystemJS (except the shared dependencies)
if (url) {
const dependencies = Object.keys(app.dependencies || {}).map((m) => app.dependencies[m]);
unregisterModules(url, dependencies);
unregisterModules(url, Object.values(app.dependencies));
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/framework/piral-base/src/lifecycle/setup.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import 'systemjs/dist/system.js';
import 'systemjs/dist/extras/named-register.js';

import { setupSinglePilet, setupPiletBundle } from './setup';

describe('Setting up Modules', () => {
Expand Down
3 changes: 3 additions & 0 deletions src/framework/piral-base/src/load.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import 'systemjs/dist/system.js';
import 'systemjs/dist/extras/named-register.js';

import { loadPilets, loadMetadata } from './load';

describe('Loading Modules', () => {
Expand Down
3 changes: 3 additions & 0 deletions src/framework/piral-base/src/loader.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import 'systemjs/dist/system.js';
import 'systemjs/dist/extras/named-register.js';

import { getDefaultLoader, extendLoader } from './loader';

describe('Standard Module Loader', () => {
Expand Down
Loading