piral-riot 0.15.0-alpha.3816 → 0.15.0-alpha.3975

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 Riot](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-riot.svg?style=flat)](https://www.npmjs.com/package/piral-riot) [![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-riot` 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 `riot`. What `piral-riot` 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 a Riot.js converter for any component registration, as well as a `fromRiot` shortcut and a `RiotExtension` component.
8
8
 
package/convert.d.ts CHANGED
@@ -1,5 +1,12 @@
1
- import type { HtmlComponent } from 'piral-core';
2
- import { createConverter } from './lib/converter';
1
+ import { createConverter } from './esm/converter';
2
+ export interface HtmlComponent<TProps> {
3
+ component: {
4
+ mount(element: HTMLElement, props: TProps, ctx: any, locals: any): void;
5
+ update?(element: HTMLElement, props: TProps, ctx: any, locals: any): void;
6
+ unmount?(element: HTMLElement, locals: any): void;
7
+ };
8
+ type: 'html';
9
+ }
3
10
  export interface RiotConverter {
4
11
  (...params: Parameters<ReturnType<typeof createConverter>>): HtmlComponent<any>;
5
12
  }
package/convert.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  exports.__esModule = true;
3
3
  exports.RiotExtension = exports.fromRiot = exports.createRiotConverter = void 0;
4
- var converter_1 = require("./lib/converter");
4
+ var converter_1 = require("./esm/converter");
5
5
  function createRiotConverter() {
6
6
  var params = [];
7
7
  for (var _i = 0; _i < arguments.length; _i++) {
package/esm/converter.js CHANGED
@@ -5,15 +5,14 @@ export function createConverter(config = {}) {
5
5
  const Extension = createExtension(extensionName);
6
6
  const convert = (component, captured) => {
7
7
  const mountApp = Riot.component(component);
8
- let app = undefined;
9
8
  return {
10
- mount(el, props, ctx) {
11
- app = mountApp(el, Object.assign(Object.assign(Object.assign({}, captured), ctx), props));
9
+ mount(el, props, ctx, locals) {
10
+ locals.app = mountApp(el, Object.assign(Object.assign(Object.assign({}, captured), ctx), props));
12
11
  },
13
- unmount(el) {
14
- app.unmount(true);
12
+ unmount(el, locals) {
13
+ locals.app.unmount(true);
15
14
  el.innerHTML = '';
16
- app = undefined;
15
+ locals.app = undefined;
17
16
  },
18
17
  };
19
18
  };
@@ -1 +1 @@
1
- {"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAU9C,MAAM,UAAU,eAAe,CAAC,SAA+B,EAAE;IAC/D,MAAM,EAAE,aAAa,GAAG,gBAAgB,EAAE,GAAG,MAAM,CAAC;IACpD,MAAM,SAAS,GAAG,eAAe,CAAC,aAAa,CAAC,CAAC;IACjD,MAAM,OAAO,GAAG,CACd,SAA0C,EAC1C,QAA8B,EACJ,EAAE;QAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC3C,IAAI,GAAG,GAA+B,SAAS,CAAC;QAEhD,OAAO;YACL,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG;gBAClB,GAAG,GAAG,QAAQ,CAAC,EAAE,gDACZ,QAAQ,GACR,GAAG,GACH,KAAK,EACR,CAAC;YACL,CAAC;YACD,OAAO,CAAC,EAAE;gBACR,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBAClB,EAAE,CAAC,SAAS,GAAG,EAAE,CAAC;gBAClB,GAAG,GAAG,SAAS,CAAC;YAClB,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;IACF,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC"}
1
+ {"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAc9C,MAAM,UAAU,eAAe,CAAC,SAA+B,EAAE;IAC/D,MAAM,EAAE,aAAa,GAAG,gBAAgB,EAAE,GAAG,MAAM,CAAC;IACpD,MAAM,SAAS,GAAG,eAAe,CAAC,aAAa,CAAC,CAAC;IACjD,MAAM,OAAO,GAAG,CACd,SAA0C,EAC1C,QAA8B,EACJ,EAAE;QAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAE3C,OAAO;YACL,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAyB;gBAC7C,MAAM,CAAC,GAAG,GAAG,QAAQ,CAAC,EAAE,gDACnB,QAAQ,GACR,GAAG,GACH,KAAK,EACR,CAAC;YACL,CAAC;YACD,OAAO,CAAC,EAAE,EAAE,MAAyB;gBACnC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBACzB,EAAE,CAAC,SAAS,GAAG,EAAE,CAAC;gBAClB,MAAM,CAAC,GAAG,GAAG,SAAS,CAAC;YACzB,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;IACF,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC"}
package/esm/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { ForeignComponent, ExtensionSlotProps } from 'piral-core';
2
- import { RiotComponentShell } from 'riot';
1
+ import type { ForeignComponent, ExtensionSlotProps } from 'piral-core';
2
+ import type { RiotComponentShell } from 'riot';
3
3
  declare module 'piral-core/lib/types/custom' {
4
4
  interface PiletCustomApi extends PiletRiotApi {
5
5
  }
package/lib/converter.js CHANGED
@@ -8,15 +8,14 @@ function createConverter(config = {}) {
8
8
  const Extension = (0, extension_1.createExtension)(extensionName);
9
9
  const convert = (component, captured) => {
10
10
  const mountApp = Riot.component(component);
11
- let app = undefined;
12
11
  return {
13
- mount(el, props, ctx) {
14
- app = mountApp(el, Object.assign(Object.assign(Object.assign({}, captured), ctx), props));
12
+ mount(el, props, ctx, locals) {
13
+ locals.app = mountApp(el, Object.assign(Object.assign(Object.assign({}, captured), ctx), props));
15
14
  },
16
- unmount(el) {
17
- app.unmount(true);
15
+ unmount(el, locals) {
16
+ locals.app.unmount(true);
18
17
  el.innerHTML = '';
19
- app = undefined;
18
+ locals.app = undefined;
20
19
  },
21
20
  };
22
21
  };
@@ -1 +1 @@
1
- {"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAE7B,2CAA8C;AAU9C,SAAgB,eAAe,CAAC,SAA+B,EAAE;IAC/D,MAAM,EAAE,aAAa,GAAG,gBAAgB,EAAE,GAAG,MAAM,CAAC;IACpD,MAAM,SAAS,GAAG,IAAA,2BAAe,EAAC,aAAa,CAAC,CAAC;IACjD,MAAM,OAAO,GAAG,CACd,SAA0C,EAC1C,QAA8B,EACJ,EAAE;QAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC3C,IAAI,GAAG,GAA+B,SAAS,CAAC;QAEhD,OAAO;YACL,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG;gBAClB,GAAG,GAAG,QAAQ,CAAC,EAAE,gDACZ,QAAQ,GACR,GAAG,GACH,KAAK,EACR,CAAC;YACL,CAAC;YACD,OAAO,CAAC,EAAE;gBACR,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBAClB,EAAE,CAAC,SAAS,GAAG,EAAE,CAAC;gBAClB,GAAG,GAAG,SAAS,CAAC;YAClB,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;IACF,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC;AA3BD,0CA2BC"}
1
+ {"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAE7B,2CAA8C;AAc9C,SAAgB,eAAe,CAAC,SAA+B,EAAE;IAC/D,MAAM,EAAE,aAAa,GAAG,gBAAgB,EAAE,GAAG,MAAM,CAAC;IACpD,MAAM,SAAS,GAAG,IAAA,2BAAe,EAAC,aAAa,CAAC,CAAC;IACjD,MAAM,OAAO,GAAG,CACd,SAA0C,EAC1C,QAA8B,EACJ,EAAE;QAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAE3C,OAAO;YACL,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAyB;gBAC7C,MAAM,CAAC,GAAG,GAAG,QAAQ,CAAC,EAAE,gDACnB,QAAQ,GACR,GAAG,GACH,KAAK,EACR,CAAC;YACL,CAAC;YACD,OAAO,CAAC,EAAE,EAAE,MAAyB;gBACnC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBACzB,EAAE,CAAC,SAAS,GAAG,EAAE,CAAC;gBAClB,MAAM,CAAC,GAAG,GAAG,SAAS,CAAC;YACzB,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;IACF,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC;AA1BD,0CA0BC"}
package/lib/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { ForeignComponent, ExtensionSlotProps } from 'piral-core';
2
- import { RiotComponentShell } from 'riot';
1
+ import type { ForeignComponent, ExtensionSlotProps } from 'piral-core';
2
+ import type { RiotComponentShell } from 'riot';
3
3
  declare module 'piral-core/lib/types/custom' {
4
4
  interface PiletCustomApi extends PiletRiotApi {
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piral-riot",
3
- "version": "0.15.0-alpha.3816",
3
+ "version": "0.15.0-alpha.3975",
4
4
  "description": "Plugin for integrating Riot.js components in Piral.",
5
5
  "keywords": [
6
6
  "piral",
@@ -44,12 +44,11 @@
44
44
  "test": "echo \"Error: run tests from root\" && exit 1"
45
45
  },
46
46
  "devDependencies": {
47
- "piral-core": "0.15.0-alpha.3816",
47
+ "piral-core": "0.15.0-alpha.3975",
48
48
  "riot": "^4.7.2"
49
49
  },
50
50
  "peerDependencies": {
51
- "piral-core": "0.14.x",
52
51
  "riot": "^4.0.0"
53
52
  },
54
- "gitHead": "cfd7ed44c6b73655be56587aeaf774692e0c94ad"
53
+ "gitHead": "461d63cd1957359472018b32a56778da716d3406"
55
54
  }
package/src/converter.ts CHANGED
@@ -10,6 +10,10 @@ export interface RiotConverterOptions {
10
10
  extensionName?: string;
11
11
  }
12
12
 
13
+ interface RiotState<TProps> {
14
+ app: Riot.RiotComponent<TProps>;
15
+ }
16
+
13
17
  export function createConverter(config: RiotConverterOptions = {}) {
14
18
  const { extensionName = 'riot-extension' } = config;
15
19
  const Extension = createExtension(extensionName);
@@ -18,20 +22,19 @@ export function createConverter(config: RiotConverterOptions = {}) {
18
22
  captured?: Record<string, any>,
19
23
  ): ForeignComponent<TProps> => {
20
24
  const mountApp = Riot.component(component);
21
- let app: Riot.RiotComponent<TProps> = undefined;
22
25
 
23
26
  return {
24
- mount(el, props, ctx) {
25
- app = mountApp(el, {
27
+ mount(el, props, ctx, locals: RiotState<TProps>) {
28
+ locals.app = mountApp(el, {
26
29
  ...captured,
27
30
  ...ctx,
28
31
  ...props,
29
32
  });
30
33
  },
31
- unmount(el) {
32
- app.unmount(true);
34
+ unmount(el, locals: RiotState<TProps>) {
35
+ locals.app.unmount(true);
33
36
  el.innerHTML = '';
34
- app = undefined;
37
+ locals.app = undefined;
35
38
  },
36
39
  };
37
40
  };
package/src/types.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { ForeignComponent, ExtensionSlotProps } from 'piral-core';
2
- import { RiotComponentShell } from 'riot';
1
+ import type { ForeignComponent, ExtensionSlotProps } from 'piral-core';
2
+ import type { RiotComponentShell } from 'riot';
3
3
 
4
4
  declare module 'piral-core/lib/types/custom' {
5
5
  interface PiletCustomApi extends PiletRiotApi {}