piral-elm 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 Elm](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-elm.svg?style=flat)](https://www.npmjs.com/package/piral-elm) [![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-elm` 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 has no peer dependencies. What `piral-elm` 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 Elm converter for any component registration, as well as a `fromElm` shortcut together with a `elm-extension` web 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 ElmConverter {
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.ElmExtension = exports.fromElm = exports.createElmConverter = void 0;
4
- var converter_1 = require("./lib/converter");
4
+ var converter_1 = require("./esm/converter");
5
5
  function createElmConverter() {
6
6
  var params = [];
7
7
  for (var _i = 0; _i < arguments.length; _i++) {
package/esm/converter.js CHANGED
@@ -2,20 +2,18 @@ import { createExtension } from './extension';
2
2
  export function createConverter(config = {}) {
3
3
  const { selector = 'elm-extension' } = config;
4
4
  const Extension = createExtension(selector);
5
- const convert = (main, captured) => {
6
- return {
7
- mount(el, props, ctx) {
8
- const node = el.appendChild(document.createElement('div'));
9
- main.init({
10
- node,
11
- flags: Object.assign(Object.assign(Object.assign({}, captured), ctx), props),
12
- });
13
- },
14
- unmount(el) {
15
- el.innerHTML = '';
16
- },
17
- };
18
- };
5
+ const convert = (main, captured) => ({
6
+ mount(el, props, ctx) {
7
+ const node = el.appendChild(document.createElement('div'));
8
+ main.init({
9
+ node,
10
+ flags: Object.assign(Object.assign(Object.assign({}, captured), ctx), props),
11
+ });
12
+ },
13
+ unmount(el) {
14
+ el.innerHTML = '';
15
+ },
16
+ });
19
17
  convert.Extension = Extension;
20
18
  return convert;
21
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAW9C,MAAM,UAAU,eAAe,CAAC,SAA8B,EAAE;IAC9D,MAAM,EAAE,QAAQ,GAAG,eAAe,EAAE,GAAG,MAAM,CAAC;IAC9C,MAAM,SAAS,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,CACd,IAAuB,EACvB,QAA8B,EACJ,EAAE;QAC5B,OAAO;YACL,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG;gBAClB,MAAM,IAAI,GAAG,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;gBAC3D,IAAI,CAAC,IAAI,CAAC;oBACR,IAAI;oBACJ,KAAK,gDACA,QAAQ,GACR,GAAG,GACH,KAAK,CACT;iBACF,CAAC,CAAC;YACL,CAAC;YACD,OAAO,CAAC,EAAE;gBACR,EAAE,CAAC,SAAS,GAAG,EAAE,CAAC;YACpB,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":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAW9C,MAAM,UAAU,eAAe,CAAC,SAA8B,EAAE;IAC9D,MAAM,EAAE,QAAQ,GAAG,eAAe,EAAE,GAAG,MAAM,CAAC;IAC9C,MAAM,SAAS,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,CACd,IAAuB,EACvB,QAA8B,EACJ,EAAE,CAAC,CAAC;QAC9B,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG;YAClB,MAAM,IAAI,GAAG,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;YAC3D,IAAI,CAAC,IAAI,CAAC;gBACR,IAAI;gBACJ,KAAK,gDACA,QAAQ,GACR,GAAG,GACH,KAAK,CACT;aACF,CAAC,CAAC;QACL,CAAC;QACD,OAAO,CAAC,EAAE;YACR,EAAE,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,CAAC;KACF,CAAC,CAAC;IACH,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC"}
package/lib/converter.js CHANGED
@@ -5,20 +5,18 @@ const extension_1 = require("./extension");
5
5
  function createConverter(config = {}) {
6
6
  const { selector = 'elm-extension' } = config;
7
7
  const Extension = (0, extension_1.createExtension)(selector);
8
- const convert = (main, captured) => {
9
- return {
10
- mount(el, props, ctx) {
11
- const node = el.appendChild(document.createElement('div'));
12
- main.init({
13
- node,
14
- flags: Object.assign(Object.assign(Object.assign({}, captured), ctx), props),
15
- });
16
- },
17
- unmount(el) {
18
- el.innerHTML = '';
19
- },
20
- };
21
- };
8
+ const convert = (main, captured) => ({
9
+ mount(el, props, ctx) {
10
+ const node = el.appendChild(document.createElement('div'));
11
+ main.init({
12
+ node,
13
+ flags: Object.assign(Object.assign(Object.assign({}, captured), ctx), props),
14
+ });
15
+ },
16
+ unmount(el) {
17
+ el.innerHTML = '';
18
+ },
19
+ });
22
20
  convert.Extension = Extension;
23
21
  return convert;
24
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":";;;AACA,2CAA8C;AAW9C,SAAgB,eAAe,CAAC,SAA8B,EAAE;IAC9D,MAAM,EAAE,QAAQ,GAAG,eAAe,EAAE,GAAG,MAAM,CAAC;IAC9C,MAAM,SAAS,GAAG,IAAA,2BAAe,EAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,CACd,IAAuB,EACvB,QAA8B,EACJ,EAAE;QAC5B,OAAO;YACL,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG;gBAClB,MAAM,IAAI,GAAG,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;gBAC3D,IAAI,CAAC,IAAI,CAAC;oBACR,IAAI;oBACJ,KAAK,gDACA,QAAQ,GACR,GAAG,GACH,KAAK,CACT;iBACF,CAAC,CAAC;YACL,CAAC;YACD,OAAO,CAAC,EAAE;gBACR,EAAE,CAAC,SAAS,GAAG,EAAE,CAAC;YACpB,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;IACF,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC;AA1BD,0CA0BC"}
1
+ {"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":";;;AACA,2CAA8C;AAW9C,SAAgB,eAAe,CAAC,SAA8B,EAAE;IAC9D,MAAM,EAAE,QAAQ,GAAG,eAAe,EAAE,GAAG,MAAM,CAAC;IAC9C,MAAM,SAAS,GAAG,IAAA,2BAAe,EAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,CACd,IAAuB,EACvB,QAA8B,EACJ,EAAE,CAAC,CAAC;QAC9B,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG;YAClB,MAAM,IAAI,GAAG,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;YAC3D,IAAI,CAAC,IAAI,CAAC;gBACR,IAAI;gBACJ,KAAK,gDACA,QAAQ,GACR,GAAG,GACH,KAAK,CACT;aACF,CAAC,CAAC;QACL,CAAC;QACD,OAAO,CAAC,EAAE;YACR,EAAE,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,CAAC;KACF,CAAC,CAAC;IACH,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC;AAxBD,0CAwBC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piral-elm",
3
- "version": "0.15.0-alpha.3816",
3
+ "version": "0.15.0-alpha.3975",
4
4
  "description": "Plugin for integrating Elm components in Piral.",
5
5
  "keywords": [
6
6
  "piral",
@@ -44,10 +44,7 @@
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
  },
49
- "peerDependencies": {
50
- "piral-core": "0.14.x"
51
- },
52
- "gitHead": "cfd7ed44c6b73655be56587aeaf774692e0c94ad"
49
+ "gitHead": "461d63cd1957359472018b32a56778da716d3406"
53
50
  }
package/src/converter.ts CHANGED
@@ -16,24 +16,22 @@ export function createConverter(config: ElmConverterOptions = {}) {
16
16
  const convert = <TProps extends BaseComponentProps>(
17
17
  main: ElmModule<TProps>,
18
18
  captured?: Record<string, any>,
19
- ): ForeignComponent<TProps> => {
20
- return {
21
- mount(el, props, ctx) {
22
- const node = el.appendChild(document.createElement('div'));
23
- main.init({
24
- node,
25
- flags: {
26
- ...captured,
27
- ...ctx,
28
- ...props,
29
- },
30
- });
31
- },
32
- unmount(el) {
33
- el.innerHTML = '';
34
- },
35
- };
36
- };
19
+ ): ForeignComponent<TProps> => ({
20
+ mount(el, props, ctx) {
21
+ const node = el.appendChild(document.createElement('div'));
22
+ main.init({
23
+ node,
24
+ flags: {
25
+ ...captured,
26
+ ...ctx,
27
+ ...props,
28
+ },
29
+ });
30
+ },
31
+ unmount(el) {
32
+ el.innerHTML = '';
33
+ },
34
+ });
37
35
  convert.Extension = Extension;
38
36
  return convert;
39
37
  }