piral-mithril 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 Mithril](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-mithril.svg?style=flat)](https://www.npmjs.com/package/piral-mithril) [![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-mithril` 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 `mithril`. What `piral-mithril` 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 Mithril.js converter for any component registration, as well as a `fromMithril` shortcut and a `MithrilExtension` 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 MithrilConverter {
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.MithrilExtension = exports.fromMithril = exports.createMithrilConverter = void 0;
4
- var converter_1 = require("./lib/converter");
4
+ var converter_1 = require("./esm/converter");
5
5
  function createMithrilConverter() {
6
6
  var params = [];
7
7
  for (var _i = 0; _i < arguments.length; _i++) {
package/esm/converter.js CHANGED
@@ -3,24 +3,22 @@ import { createExtension } from './extension';
3
3
  export function createConverter(config = {}) {
4
4
  const { rootName = 'slot' } = config;
5
5
  const Extension = createExtension(rootName);
6
- const convert = (component, captured) => {
7
- return {
8
- mount(el, props, ctx) {
9
- mithril.mount(el, {
10
- view: () => mithril.m(component, Object.assign(Object.assign(Object.assign({}, captured), ctx), props)),
11
- });
12
- },
13
- update(el, props, ctx) {
14
- mithril.mount(el, {
15
- view: () => mithril.m(component, Object.assign(Object.assign(Object.assign({}, captured), ctx), props)),
16
- });
17
- },
18
- unmount(el) {
19
- // tslint:disable-next-line:no-null-keyword
20
- mithril.mount(el, null);
21
- },
22
- };
23
- };
6
+ const convert = (component, captured) => ({
7
+ mount(el, props, ctx) {
8
+ mithril.mount(el, {
9
+ view: () => mithril.m(component, Object.assign(Object.assign(Object.assign({}, captured), ctx), props)),
10
+ });
11
+ },
12
+ update(el, props, ctx) {
13
+ mithril.mount(el, {
14
+ view: () => mithril.m(component, Object.assign(Object.assign(Object.assign({}, captured), ctx), props)),
15
+ });
16
+ },
17
+ unmount(el) {
18
+ // tslint:disable-next-line:no-null-keyword
19
+ mithril.mount(el, null);
20
+ },
21
+ });
24
22
  convert.Extension = Extension;
25
23
  return convert;
26
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAEnC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAW9C,MAAM,UAAU,eAAe,CAAC,SAAkC,EAAE;IAClE,MAAM,EAAE,QAAQ,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC;IACrC,MAAM,SAAS,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,CACd,SAA4B,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OAAO,CAAC,CAAC,CAAC,SAAS,gDACd,QAAQ,GACR,GAAG,GACH,KAAK,EACR;aACL,CAAC,CAAC;QACL,CAAC;QACD,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG;YACnB,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE;gBAChB,IAAI,EAAE,GAAG,EAAE,CACT,OAAO,CAAC,CAAC,CAAC,SAAS,gDACd,QAAQ,GACR,GAAG,GACH,KAAK,EACR;aACL,CAAC,CAAC;QACL,CAAC;QACD,OAAO,CAAC,EAAE;YACR,2CAA2C;YAC3C,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QAC1B,CAAC;KACF,CAAC,CAAC;IACH,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC"}
package/esm/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ForeignComponent, ExtensionSlotProps } from 'piral-core';
1
+ import type { ForeignComponent, ExtensionSlotProps } from 'piral-core';
2
2
  declare module 'piral-core/lib/types/custom' {
3
3
  interface PiletCustomApi extends PiletMithrilApi {
4
4
  }
package/lib/converter.js CHANGED
@@ -6,24 +6,22 @@ const extension_1 = require("./extension");
6
6
  function createConverter(config = {}) {
7
7
  const { rootName = 'slot' } = config;
8
8
  const Extension = (0, extension_1.createExtension)(rootName);
9
- const convert = (component, captured) => {
10
- return {
11
- mount(el, props, ctx) {
12
- mithril.mount(el, {
13
- view: () => mithril.m(component, Object.assign(Object.assign(Object.assign({}, captured), ctx), props)),
14
- });
15
- },
16
- update(el, props, ctx) {
17
- mithril.mount(el, {
18
- view: () => mithril.m(component, Object.assign(Object.assign(Object.assign({}, captured), ctx), props)),
19
- });
20
- },
21
- unmount(el) {
22
- // tslint:disable-next-line:no-null-keyword
23
- mithril.mount(el, null);
24
- },
25
- };
26
- };
9
+ const convert = (component, captured) => ({
10
+ mount(el, props, ctx) {
11
+ mithril.mount(el, {
12
+ view: () => mithril.m(component, Object.assign(Object.assign(Object.assign({}, captured), ctx), props)),
13
+ });
14
+ },
15
+ update(el, props, ctx) {
16
+ mithril.mount(el, {
17
+ view: () => mithril.m(component, Object.assign(Object.assign(Object.assign({}, captured), ctx), props)),
18
+ });
19
+ },
20
+ unmount(el) {
21
+ // tslint:disable-next-line:no-null-keyword
22
+ mithril.mount(el, null);
23
+ },
24
+ });
27
25
  convert.Extension = Extension;
28
26
  return convert;
29
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AAEnC,2CAA8C;AAW9C,SAAgB,eAAe,CAAC,SAAkC,EAAE;IAClE,MAAM,EAAE,QAAQ,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC;IACrC,MAAM,SAAS,GAAG,IAAA,2BAAe,EAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,CACd,SAA4B,EAC5B,QAA8B,EACJ,EAAE;QAC5B,OAAO;YACL,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG;gBAClB,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE;oBAChB,IAAI,EAAE,GAAG,EAAE,CACT,OAAO,CAAC,CAAC,CAAC,SAAS,gDACd,QAAQ,GACR,GAAG,GACH,KAAK,EACR;iBACL,CAAC,CAAC;YACL,CAAC;YACD,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG;gBACnB,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE;oBAChB,IAAI,EAAE,GAAG,EAAE,CACT,OAAO,CAAC,CAAC,CAAC,SAAS,gDACd,QAAQ,GACR,GAAG,GACH,KAAK,EACR;iBACL,CAAC,CAAC;YACL,CAAC;YACD,OAAO,CAAC,EAAE;gBACR,2CAA2C;gBAC3C,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;YAC1B,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;IACF,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC;AApCD,0CAoCC"}
1
+ {"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AAEnC,2CAA8C;AAW9C,SAAgB,eAAe,CAAC,SAAkC,EAAE;IAClE,MAAM,EAAE,QAAQ,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC;IACrC,MAAM,SAAS,GAAG,IAAA,2BAAe,EAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,CACd,SAA4B,EAC5B,QAA8B,EACJ,EAAE,CAAC,CAAC;QAC9B,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG;YAClB,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE;gBAChB,IAAI,EAAE,GAAG,EAAE,CACT,OAAO,CAAC,CAAC,CAAC,SAAS,gDACd,QAAQ,GACR,GAAG,GACH,KAAK,EACR;aACL,CAAC,CAAC;QACL,CAAC;QACD,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG;YACnB,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE;gBAChB,IAAI,EAAE,GAAG,EAAE,CACT,OAAO,CAAC,CAAC,CAAC,SAAS,gDACd,QAAQ,GACR,GAAG,GACH,KAAK,EACR;aACL,CAAC,CAAC;QACL,CAAC;QACD,OAAO,CAAC,EAAE;YACR,2CAA2C;YAC3C,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QAC1B,CAAC;KACF,CAAC,CAAC;IACH,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC;AAlCD,0CAkCC"}
package/lib/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ForeignComponent, ExtensionSlotProps } from 'piral-core';
1
+ import type { ForeignComponent, ExtensionSlotProps } from 'piral-core';
2
2
  declare module 'piral-core/lib/types/custom' {
3
3
  interface PiletCustomApi extends PiletMithrilApi {
4
4
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piral-mithril",
3
- "version": "0.15.0-alpha.3816",
3
+ "version": "0.15.0-alpha.3975",
4
4
  "description": "Plugin for integrating Mithril.js components in Piral.",
5
5
  "keywords": [
6
6
  "piral",
@@ -45,11 +45,10 @@
45
45
  },
46
46
  "devDependencies": {
47
47
  "mithril": "2.0.4",
48
- "piral-core": "0.15.0-alpha.3816"
48
+ "piral-core": "0.15.0-alpha.3975"
49
49
  },
50
50
  "peerDependencies": {
51
- "mithril": "^2.0.0",
52
- "piral-core": "0.14.x"
51
+ "mithril": "^2.0.0"
53
52
  },
54
- "gitHead": "cfd7ed44c6b73655be56587aeaf774692e0c94ad"
53
+ "gitHead": "461d63cd1957359472018b32a56778da716d3406"
55
54
  }
package/src/converter.ts CHANGED
@@ -17,34 +17,32 @@ export function createConverter(config: MithrilConverterOptions = {}) {
17
17
  const convert = <TProps extends BaseComponentProps>(
18
18
  component: Component<TProps>,
19
19
  captured?: Record<string, any>,
20
- ): ForeignComponent<TProps> => {
21
- return {
22
- mount(el, props, ctx) {
23
- mithril.mount(el, {
24
- view: () =>
25
- mithril.m(component, {
26
- ...captured,
27
- ...ctx,
28
- ...props,
29
- }),
30
- });
31
- },
32
- update(el, props, ctx) {
33
- mithril.mount(el, {
34
- view: () =>
35
- mithril.m(component, {
36
- ...captured,
37
- ...ctx,
38
- ...props,
39
- }),
40
- });
41
- },
42
- unmount(el) {
43
- // tslint:disable-next-line:no-null-keyword
44
- mithril.mount(el, null);
45
- },
46
- };
47
- };
20
+ ): ForeignComponent<TProps> => ({
21
+ mount(el, props, ctx) {
22
+ mithril.mount(el, {
23
+ view: () =>
24
+ mithril.m(component, {
25
+ ...captured,
26
+ ...ctx,
27
+ ...props,
28
+ }),
29
+ });
30
+ },
31
+ update(el, props, ctx) {
32
+ mithril.mount(el, {
33
+ view: () =>
34
+ mithril.m(component, {
35
+ ...captured,
36
+ ...ctx,
37
+ ...props,
38
+ }),
39
+ });
40
+ },
41
+ unmount(el) {
42
+ // tslint:disable-next-line:no-null-keyword
43
+ mithril.mount(el, null);
44
+ },
45
+ });
48
46
  convert.Extension = Extension;
49
47
  return convert;
50
48
  }
package/src/types.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ForeignComponent, ExtensionSlotProps } from 'piral-core';
1
+ import type { ForeignComponent, ExtensionSlotProps } from 'piral-core';
2
2
 
3
3
  declare module 'piral-core/lib/types/custom' {
4
4
  interface PiletCustomApi extends PiletMithrilApi {}