piral-ng 0.15.0-alpha.3809 → 0.15.0-alpha.3933

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # [Piral Ng](https://piral.io) · [![GitHub License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/smapiot/piral/blob/main/LICENSE) [![npm version](https://img.shields.io/npm/v/piral-ng.svg?style=flat)](https://www.npmjs.com/package/piral-ng) [![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://jestjs.io) [![Gitter Chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/piral-io/community)
4
4
 
5
- This is a plugin that only has a peer dependency to `piral-core`. What `piral-ng` brings to the table is a set of Pilet API extensions that can be used with `piral` or `piral-core`.
5
+ This is a plugin that only has a peer dependency to `rxjs`, `@angular/core` and related packages. What `piral-ng` brings to the table is a set of Pilet API extensions that can be used with `piral` or `piral-core`.
6
6
 
7
7
  The set includes an Angular converter for any component registration, as well as a `fromNg` shortcut, a `defineNgModule` function, and a `NgExtension` component.
8
8
 
package/esm/converter.js CHANGED
@@ -5,16 +5,17 @@ import { bootstrap, prepareBootstrap } from './bootstrap';
5
5
  export function createConverter(_ = {}) {
6
6
  const convert = (component) => {
7
7
  const bootstrapped = prepareBootstrap(component);
8
- let mounted = Promise.resolve();
9
- let active = true;
10
8
  return {
11
- mount(el, props, ctx) {
12
- active = true;
13
- mounted = mounted.then(() => enqueue(() => active && bootstrap(bootstrapped, el, props, ctx)));
9
+ mount(el, props, ctx, locals) {
10
+ locals.active = true;
11
+ if (!locals.queued) {
12
+ locals.queued = Promise.resolve();
13
+ }
14
+ locals.queued = locals.queued.then(() => enqueue(() => locals.active && bootstrap(bootstrapped, el, props, ctx)));
14
15
  },
15
- unmount() {
16
- active = false;
17
- mounted = mounted.then((dispose) => dispose && dispose());
16
+ unmount(el, locals) {
17
+ locals.active = false;
18
+ locals.queued = locals.queued.then((dispose) => dispose && dispose());
18
19
  },
19
20
  };
20
21
  };
@@ -1 +1 @@
1
- {"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAU1D,MAAM,UAAU,eAAe,CAAC,IAAwB,EAAE;IACxD,MAAM,OAAO,GAAG,CAAoC,SAAc,EAA4B,EAAE;QAC9F,MAAM,YAAY,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAC;QACjD,IAAI,OAAO,GAA+B,OAAO,CAAC,OAAO,EAAE,CAAC;QAC5D,IAAI,MAAM,GAAG,IAAI,CAAC;QAElB,OAAO;YACL,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG;gBAClB,MAAM,GAAG,IAAI,CAAC;gBACd,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,IAAI,SAAS,CAAC,YAAY,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;YACjG,CAAC;YACD,OAAO;gBACL,MAAM,GAAG,KAAK,CAAC;gBACf,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,IAAI,OAAO,EAAE,CAAC,CAAC;YAC5D,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;IACF,OAAO,CAAC,YAAY,GAAG,YAAY,CAAC;IACpC,OAAO,CAAC,SAAS,GAAG,WAAW,CAAC;IAChC,OAAO,OAAO,CAAC;AACjB,CAAC"}
1
+ {"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.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8,16 +8,17 @@ const bootstrap_1 = require("./bootstrap");
8
8
  function createConverter(_ = {}) {
9
9
  const convert = (component) => {
10
10
  const bootstrapped = (0, bootstrap_1.prepareBootstrap)(component);
11
- let mounted = Promise.resolve();
12
- let active = true;
13
11
  return {
14
- mount(el, props, ctx) {
15
- active = true;
16
- mounted = mounted.then(() => (0, queue_1.enqueue)(() => active && (0, bootstrap_1.bootstrap)(bootstrapped, el, props, ctx)));
12
+ mount(el, props, ctx, locals) {
13
+ locals.active = true;
14
+ if (!locals.queued) {
15
+ locals.queued = Promise.resolve();
16
+ }
17
+ locals.queued = locals.queued.then(() => (0, queue_1.enqueue)(() => locals.active && (0, bootstrap_1.bootstrap)(bootstrapped, el, props, ctx)));
17
18
  },
18
- unmount() {
19
- active = false;
20
- mounted = mounted.then((dispose) => dispose && dispose());
19
+ unmount(el, locals) {
20
+ locals.active = false;
21
+ locals.queued = locals.queued.then((dispose) => dispose && dispose());
21
22
  },
22
23
  };
23
24
  };
@@ -1 +1 @@
1
- {"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":";;;AAEA,+CAA4C;AAC5C,mCAAkC;AAClC,qCAAwC;AACxC,2CAA0D;AAU1D,SAAgB,eAAe,CAAC,IAAwB,EAAE;IACxD,MAAM,OAAO,GAAG,CAAoC,SAAc,EAA4B,EAAE;QAC9F,MAAM,YAAY,GAAG,IAAA,4BAAgB,EAAC,SAAS,CAAC,CAAC;QACjD,IAAI,OAAO,GAA+B,OAAO,CAAC,OAAO,EAAE,CAAC;QAC5D,IAAI,MAAM,GAAG,IAAI,CAAC;QAElB,OAAO;YACL,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG;gBAClB,MAAM,GAAG,IAAI,CAAC;gBACd,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,MAAM,IAAI,IAAA,qBAAS,EAAC,YAAY,EAAE,EAAE,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AC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,IAAI,OAAO,EAAE,CAAC,CAAC;YACxE,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;IACF,OAAO,CAAC,YAAY,GAAG,qBAAY,CAAC;IACpC,OAAO,CAAC,SAAS,GAAG,yBAAW,CAAC;IAChC,OAAO,OAAO,CAAC;AACjB,CAAC;AAzBD,0CAyBC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piral-ng",
3
- "version": "0.15.0-alpha.3809",
3
+ "version": "0.15.0-alpha.3933",
4
4
  "description": "Plugin for integrating Angular components in Piral.",
5
5
  "keywords": [
6
6
  "piral",
@@ -53,7 +53,7 @@
53
53
  "@angular/platform-browser": "^8.0.0",
54
54
  "@angular/platform-browser-dynamic": "^8.0.0",
55
55
  "@angular/router": "^8.0.0",
56
- "piral-core": "0.15.0-alpha.3809",
56
+ "piral-core": "0.15.0-alpha.3933",
57
57
  "rxjs": "^7.3.0"
58
58
  },
59
59
  "peerDependencies": {
@@ -62,10 +62,7 @@
62
62
  "@angular/platform-browser": "^2.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0",
63
63
  "@angular/platform-browser-dynamic": "^2.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0",
64
64
  "@angular/router": "^2.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0",
65
- "core-js": "~3.5.0",
66
- "piral-core": "0.14.x",
67
- "rxjs": "^5.0.0 || ^6.0.0 || ^7.0.0",
68
- "zone.js": "~0.9.0 || ~0.10.0 || ~0.11.0"
65
+ "rxjs": "^5.0.0 || ^6.0.0 || ^7.0.0"
69
66
  },
70
- "gitHead": "e26067cdcbbe90ff72d1d0815929655c05126e3a"
67
+ "gitHead": "520a272d09f02543153f1d8b2ae23a3ae10acd6f"
71
68
  }
package/src/converter.ts CHANGED
@@ -13,20 +13,30 @@ export interface NgConverter {
13
13
  Extension: any;
14
14
  }
15
15
 
16
+ interface NgState {
17
+ queued: Promise<void | Disposable>;
18
+ active: boolean;
19
+ }
20
+
16
21
  export function createConverter(_: NgConverterOptions = {}): NgConverter {
17
22
  const convert = <TProps extends BaseComponentProps>(component: any): ForeignComponent<TProps> => {
18
23
  const bootstrapped = prepareBootstrap(component);
19
- let mounted: Promise<void | Disposable> = Promise.resolve();
20
- let active = true;
21
24
 
22
25
  return {
23
- mount(el, props, ctx) {
24
- active = true;
25
- mounted = mounted.then(() => enqueue(() => active && bootstrap(bootstrapped, el, props, ctx)));
26
+ mount(el, props, ctx, locals: NgState) {
27
+ locals.active = true;
28
+
29
+ if (!locals.queued) {
30
+ locals.queued = Promise.resolve();
31
+ }
32
+
33
+ locals.queued = locals.queued.then(() =>
34
+ enqueue(() => locals.active && bootstrap(bootstrapped, el, props, ctx)),
35
+ );
26
36
  },
27
- unmount() {
28
- active = false;
29
- mounted = mounted.then((dispose) => dispose && dispose());
37
+ unmount(el, locals: NgState) {
38
+ locals.active = false;
39
+ locals.queued = locals.queued.then((dispose) => dispose && dispose());
30
40
  },
31
41
  };
32
42
  };