piral-hyperapp 0.13.7 → 0.14.0-alpha.3154

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/convert.d.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  import type { HtmlComponent } from 'piral-core';
2
- import { createExtension } from './lib/extension';
3
- declare const convert: <TProps extends import("piral-core").BaseComponentProps>(root: import("./lib/types").Component<TProps, {}, {}>, state: any, actions: any) => import("piral-core").ForeignComponent<TProps>;
2
+ import { createConverter } from './lib/converter';
4
3
  export interface HyperappConverter {
5
- (...params: Parameters<typeof convert>): HtmlComponent<any>;
4
+ (...params: Parameters<ReturnType<typeof createConverter>>): HtmlComponent<any>;
6
5
  }
7
- export declare const fromHyperapp: HyperappConverter;
8
- export declare const createHyperappExtension: typeof createExtension;
9
- export {};
6
+ export declare function createHyperappConverter(...params: Parameters<typeof createConverter>): {
7
+ from: HyperappConverter;
8
+ Extension: import("./lib/types").Component<import("piral-core").ExtensionSlotProps<string>, {}, {}>;
9
+ };
10
+ declare const fromHyperapp: HyperappConverter, HyperExtension: import("./lib/types").Component<import("piral-core").ExtensionSlotProps<string>, {}, {}>;
11
+ export { fromHyperapp, HyperExtension };
package/convert.js CHANGED
@@ -1,12 +1,21 @@
1
1
  "use strict";
2
2
  exports.__esModule = true;
3
- exports.createHyperappExtension = exports.fromHyperapp = void 0;
3
+ exports.HyperExtension = exports.fromHyperapp = exports.createHyperappConverter = void 0;
4
4
  var converter_1 = require("./lib/converter");
5
- var extension_1 = require("./lib/extension");
6
- var convert = converter_1.createConverter();
7
- var fromHyperapp = function (root, state, actions) { return ({
8
- type: 'html',
9
- component: convert(root, state, actions)
10
- }); };
5
+ function createHyperappConverter() {
6
+ var params = [];
7
+ for (var _i = 0; _i < arguments.length; _i++) {
8
+ params[_i] = arguments[_i];
9
+ }
10
+ var convert = converter_1.createConverter.apply(void 0, params);
11
+ var Extension = convert.Extension;
12
+ var from = function (root, state, actions) { return ({
13
+ type: 'html',
14
+ component: convert(root, state, actions)
15
+ }); };
16
+ return { from: from, Extension: Extension };
17
+ }
18
+ exports.createHyperappConverter = createHyperappConverter;
19
+ var _a = createHyperappConverter(), fromHyperapp = _a.from, HyperExtension = _a.Extension;
11
20
  exports.fromHyperapp = fromHyperapp;
12
- exports.createHyperappExtension = extension_1.createExtension;
21
+ exports.HyperExtension = HyperExtension;
@@ -1,3 +1,13 @@
1
- import { ForeignComponent, BaseComponentProps } from 'piral-core';
2
- import { Component } from './types';
3
- export declare function createConverter(): <TProps extends BaseComponentProps>(root: Component<TProps, {}, {}>, state: any, actions: any) => ForeignComponent<TProps>;
1
+ import type { ForeignComponent, BaseComponentProps } from 'piral-core';
2
+ import type { Component } from './types';
3
+ export interface HyperappConverterOptions {
4
+ /**
5
+ * Defines the name of the root element.
6
+ * @default slot
7
+ */
8
+ rootName?: string;
9
+ }
10
+ export declare function createConverter(config?: HyperappConverterOptions): {
11
+ <TProps extends BaseComponentProps>(root: Component<TProps, {}, {}>, state: any, actions: any): ForeignComponent<TProps>;
12
+ Extension: Component<import("piral-core").ExtensionSlotProps<string>, {}, {}>;
13
+ };
package/esm/converter.js CHANGED
@@ -1,15 +1,19 @@
1
1
  import { mountHyperapp } from './mount';
2
- export function createConverter() {
3
- var convert = function (root, state, actions) {
2
+ import { createExtension } from './extension';
3
+ export function createConverter(config = {}) {
4
+ const { rootName = 'slot' } = config;
5
+ const Extension = createExtension(rootName);
6
+ const convert = (root, state, actions) => {
4
7
  return {
5
- mount: function (el, props, ctx) {
8
+ mount(el, props, ctx) {
6
9
  mountHyperapp(el, root, props, ctx, state, actions);
7
10
  },
8
- unmount: function (el) {
11
+ unmount(el) {
9
12
  el.innerHTML = '';
10
13
  },
11
14
  };
12
15
  };
16
+ convert.Extension = Extension;
13
17
  return convert;
14
18
  }
15
19
  //# sourceMappingURL=converter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGxC,MAAM,UAAU,eAAe;IAC7B,IAAM,OAAO,GAAG,UACd,IAAuB,EACvB,KAAU,EACV,OAAY;QAEZ,OAAO;YACL,KAAK,YAAC,EAAE,EAAE,KAAK,EAAE,GAAG;gBAClB,aAAa,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;YACtD,CAAC;YACD,OAAO,YAAC,EAAE;gBACR,EAAE,CAAC,SAAS,GAAG,EAAE,CAAC;YACpB,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;IACF,OAAO,OAAO,CAAC;AACjB,CAAC"}
1
+ {"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAW9C,MAAM,UAAU,eAAe,CAAC,SAAmC,EAAE;IACnE,MAAM,EAAE,QAAQ,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC;IACrC,MAAM,SAAS,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,CACd,IAAuB,EACvB,KAAU,EACV,OAAY,EACc,EAAE;QAC5B,OAAO;YACL,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG;gBAClB,aAAa,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;YACtD,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"}
package/esm/create.d.ts CHANGED
@@ -1,14 +1,10 @@
1
1
  import type { PiralPlugin } from 'piral-core';
2
+ import { HyperappConverterOptions } from './converter';
2
3
  import type { PiletHyperappApi } from './types';
3
4
  /**
4
5
  * Available configuration options for the Hyperapp plugin.
5
6
  */
6
- export interface HyperappConfig {
7
- /**
8
- * Defines the name of the root element.
9
- * @default slot
10
- */
11
- rootName?: string;
7
+ export interface HyperappConfig extends HyperappConverterOptions {
12
8
  }
13
9
  /**
14
10
  * Creates new Pilet API extensions for the Hyperapp integration.
package/esm/create.js CHANGED
@@ -1,29 +1,21 @@
1
1
  import { createConverter } from './converter';
2
- import { createExtension } from './extension';
3
2
  /**
4
3
  * Creates new Pilet API extensions for the Hyperapp integration.
5
4
  */
6
- export function createHyperappApi(config) {
7
- if (config === void 0) { config = {}; }
8
- var rootName = config.rootName;
9
- return function (context) {
10
- var convert = createConverter();
11
- context.converters.hyperapp = function (_a) {
12
- var root = _a.root, state = _a.state, actions = _a.actions;
13
- return convert(root, state, actions);
14
- };
15
- return function (api) {
16
- return {
17
- fromHyperapp: function (root, state, actions) {
18
- return {
19
- type: 'hyperapp',
20
- root: root,
21
- state: state,
22
- actions: actions,
23
- };
24
- },
25
- HyperappExtension: createExtension(api, rootName),
26
- };
5
+ export function createHyperappApi(config = {}) {
6
+ return (context) => {
7
+ const convert = createConverter(config);
8
+ context.converters.hyperapp = ({ root, state, actions }) => convert(root, state, actions);
9
+ return {
10
+ fromHyperapp(root, state, actions) {
11
+ return {
12
+ type: 'hyperapp',
13
+ root,
14
+ state,
15
+ actions,
16
+ };
17
+ },
18
+ HyperappExtension: convert.Extension,
27
19
  };
28
20
  };
29
21
  }
package/esm/create.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAc9C;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAA2B;IAA3B,uBAAA,EAAA,WAA2B;IACnD,IAAA,QAAQ,GAAK,MAAM,SAAX,CAAY;IAE5B,OAAO,UAAC,OAAO;QACb,IAAM,OAAO,GAAG,eAAe,EAAE,CAAC;QAClC,OAAO,CAAC,UAAU,CAAC,QAAQ,GAAG,UAAC,EAAwB;gBAAtB,IAAI,UAAA,EAAE,KAAK,WAAA,EAAE,OAAO,aAAA;YAAO,OAAA,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC;QAA7B,CAA6B,CAAC;QAE1F,OAAO,UAAC,GAAG;YACT,OAAO;gBACL,YAAY,YAAC,IAAI,EAAE,KAAK,EAAE,OAAO;oBAC/B,OAAO;wBACL,IAAI,EAAE,UAAU;wBAChB,IAAI,MAAA;wBACJ,KAAK,OAAA;wBACL,OAAO,SAAA;qBACR,CAAC;gBACJ,CAAC;gBACD,iBAAiB,EAAE,eAAe,CAAC,GAAG,EAAE,QAAQ,CAAC;aAClD,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAA4B,MAAM,aAAa,CAAC;AAQxE;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAAyB,EAAE;IAC3D,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,MAAM,OAAO,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;QACxC,OAAO,CAAC,UAAU,CAAC,QAAQ,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAE1F,OAAO;YACL,YAAY,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO;gBAC/B,OAAO;oBACL,IAAI,EAAE,UAAU;oBAChB,IAAI;oBACJ,KAAK;oBACL,OAAO;iBACR,CAAC;YACJ,CAAC;YACD,iBAAiB,EAAE,OAAO,CAAC,SAAS;SACrC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
@@ -1,3 +1,3 @@
1
- import type { PiletApi, ExtensionSlotProps } from 'piral-core';
1
+ import type { ExtensionSlotProps } from 'piral-core';
2
2
  import type { Component } from './types';
3
- export declare function createExtension(api: PiletApi, rootName?: string): Component<ExtensionSlotProps>;
3
+ export declare function createExtension(rootName: string): Component<ExtensionSlotProps>;
package/esm/extension.js CHANGED
@@ -1,12 +1,15 @@
1
1
  import { createHyperappElement } from './mount';
2
- export function createExtension(api, rootName) {
3
- if (rootName === void 0) { rootName = 'slot'; }
4
- return function (props) {
5
- return createHyperappElement(rootName, {
6
- oncreate: function (element) {
7
- api.renderHtmlExtension(element, props);
8
- },
9
- });
10
- };
2
+ export function createExtension(rootName) {
3
+ return (props) => createHyperappElement(rootName, {
4
+ oncreate(element) {
5
+ element.dispatchEvent(new CustomEvent('render-html', {
6
+ bubbles: true,
7
+ detail: {
8
+ target: element,
9
+ props,
10
+ },
11
+ }));
12
+ },
13
+ });
11
14
  }
12
15
  //# sourceMappingURL=extension.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAGhD,MAAM,UAAU,eAAe,CAAC,GAAa,EAAE,QAAiB;IAAjB,yBAAA,EAAA,iBAAiB;IAC9D,OAAO,UAAC,KAAK;QACX,OAAA,qBAAqB,CAAC,QAAQ,EAAE;YAC9B,QAAQ,EAAR,UAAS,OAAoB;gBAC3B,GAAG,CAAC,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC1C,CAAC;SACF,CAAC;IAJF,CAIE,CAAC;AACP,CAAC"}
1
+ {"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAGhD,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,OAAO,CAAC,KAAK,EAAE,EAAE,CACf,qBAAqB,CAAC,QAAQ,EAAE;QAC9B,QAAQ,CAAC,OAAoB;YAC3B,OAAO,CAAC,aAAa,CACnB,IAAI,WAAW,CAAC,aAAa,EAAE;gBAC7B,OAAO,EAAE,IAAI;gBACb,MAAM,EAAE;oBACN,MAAM,EAAE,OAAO;oBACf,KAAK;iBACN;aACF,CAAC,CACH,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACP,CAAC"}
package/esm/mount.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { Component } from './types';
1
+ import type { Component } from './types';
2
2
  export declare function mountHyperapp<T extends Object>(el: HTMLElement, root: Component<T>, props: T, ctx: any, state: any, actions: any): void;
3
3
  export declare function createHyperappElement(name: string, props: any): any;
package/esm/mount.js CHANGED
@@ -1,7 +1,6 @@
1
- import { __assign } from "tslib";
2
- var _a = require('hyperapp'), h = _a.h, app = _a.app;
1
+ const { h, app } = require('hyperapp');
3
2
  export function mountHyperapp(el, root, props, ctx, state, actions) {
4
- app(__assign(__assign({}, ctx), state), actions, function () { return h(root, props); }, el);
3
+ app(Object.assign(Object.assign({}, ctx), state), actions, () => h(root, props), el);
5
4
  }
6
5
  export function createHyperappElement(name, props) {
7
6
  return h(name, props, []);
package/esm/mount.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mount.js","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":";AAEM,IAAA,KAAa,OAAO,CAAC,UAAU,CAAC,EAA9B,CAAC,OAAA,EAAE,GAAG,SAAwB,CAAC;AAEvC,MAAM,UAAU,aAAa,CAC3B,EAAe,EACf,IAAkB,EAClB,KAAQ,EACR,GAAQ,EACR,KAAU,EACV,OAAY;IAEZ,GAAG,uBAEI,GAAG,GACH,KAAK,GAEV,OAAO,EACP,cAAM,OAAA,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAd,CAAc,EACpB,EAAE,CACH,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,IAAY,EAAE,KAAU;IAC5D,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;AAC5B,CAAC"}
1
+ {"version":3,"file":"mount.js","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":"AAEA,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEvC,MAAM,UAAU,aAAa,CAC3B,EAAe,EACf,IAAkB,EAClB,KAAQ,EACR,GAAQ,EACR,KAAU,EACV,OAAY;IAEZ,GAAG,iCAEI,GAAG,GACH,KAAK,GAEV,OAAO,EACP,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EACpB,EAAE,CACH,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,IAAY,EAAE,KAAU;IAC5D,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;AAC5B,CAAC"}
@@ -1,3 +1,13 @@
1
- import { ForeignComponent, BaseComponentProps } from 'piral-core';
2
- import { Component } from './types';
3
- export declare function createConverter(): <TProps extends BaseComponentProps>(root: Component<TProps, {}, {}>, state: any, actions: any) => ForeignComponent<TProps>;
1
+ import type { ForeignComponent, BaseComponentProps } from 'piral-core';
2
+ import type { Component } from './types';
3
+ export interface HyperappConverterOptions {
4
+ /**
5
+ * Defines the name of the root element.
6
+ * @default slot
7
+ */
8
+ rootName?: string;
9
+ }
10
+ export declare function createConverter(config?: HyperappConverterOptions): {
11
+ <TProps extends BaseComponentProps>(root: Component<TProps, {}, {}>, state: any, actions: any): ForeignComponent<TProps>;
12
+ Extension: Component<import("piral-core").ExtensionSlotProps<string>, {}, {}>;
13
+ };
package/lib/converter.js CHANGED
@@ -1,18 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createConverter = void 0;
4
- var mount_1 = require("./mount");
5
- function createConverter() {
6
- var convert = function (root, state, actions) {
4
+ const mount_1 = require("./mount");
5
+ const extension_1 = require("./extension");
6
+ function createConverter(config = {}) {
7
+ const { rootName = 'slot' } = config;
8
+ const Extension = (0, extension_1.createExtension)(rootName);
9
+ const convert = (root, state, actions) => {
7
10
  return {
8
- mount: function (el, props, ctx) {
9
- mount_1.mountHyperapp(el, root, props, ctx, state, actions);
11
+ mount(el, props, ctx) {
12
+ (0, mount_1.mountHyperapp)(el, root, props, ctx, state, actions);
10
13
  },
11
- unmount: function (el) {
14
+ unmount(el) {
12
15
  el.innerHTML = '';
13
16
  },
14
17
  };
15
18
  };
19
+ convert.Extension = Extension;
16
20
  return convert;
17
21
  }
18
22
  exports.createConverter = createConverter;
@@ -1 +1 @@
1
- {"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":";;;AACA,iCAAwC;AAGxC,SAAgB,eAAe;IAC7B,IAAM,OAAO,GAAG,UACd,IAAuB,EACvB,KAAU,EACV,OAAY;QAEZ,OAAO;YACL,KAAK,YAAC,EAAE,EAAE,KAAK,EAAE,GAAG;gBAClB,qBAAa,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;YACtD,CAAC;YACD,OAAO,YAAC,EAAE;gBACR,EAAE,CAAC,SAAS,GAAG,EAAE,CAAC;YACpB,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;IACF,OAAO,OAAO,CAAC;AACjB,CAAC;AAhBD,0CAgBC"}
1
+ {"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":";;;AACA,mCAAwC;AACxC,2CAA8C;AAW9C,SAAgB,eAAe,CAAC,SAAmC,EAAE;IACnE,MAAM,EAAE,QAAQ,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC;IACrC,MAAM,SAAS,GAAG,IAAA,2BAAe,EAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,CACd,IAAuB,EACvB,KAAU,EACV,OAAY,EACc,EAAE;QAC5B,OAAO;YACL,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG;gBAClB,IAAA,qBAAa,EAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;YACtD,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;AAnBD,0CAmBC"}
package/lib/create.d.ts CHANGED
@@ -1,14 +1,10 @@
1
1
  import type { PiralPlugin } from 'piral-core';
2
+ import { HyperappConverterOptions } from './converter';
2
3
  import type { PiletHyperappApi } from './types';
3
4
  /**
4
5
  * Available configuration options for the Hyperapp plugin.
5
6
  */
6
- export interface HyperappConfig {
7
- /**
8
- * Defines the name of the root element.
9
- * @default slot
10
- */
11
- rootName?: string;
7
+ export interface HyperappConfig extends HyperappConverterOptions {
12
8
  }
13
9
  /**
14
10
  * Creates new Pilet API extensions for the Hyperapp integration.
package/lib/create.js CHANGED
@@ -1,32 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createHyperappApi = void 0;
4
- var converter_1 = require("./converter");
5
- var extension_1 = require("./extension");
4
+ const converter_1 = require("./converter");
6
5
  /**
7
6
  * Creates new Pilet API extensions for the Hyperapp integration.
8
7
  */
9
- function createHyperappApi(config) {
10
- if (config === void 0) { config = {}; }
11
- var rootName = config.rootName;
12
- return function (context) {
13
- var convert = converter_1.createConverter();
14
- context.converters.hyperapp = function (_a) {
15
- var root = _a.root, state = _a.state, actions = _a.actions;
16
- return convert(root, state, actions);
17
- };
18
- return function (api) {
19
- return {
20
- fromHyperapp: function (root, state, actions) {
21
- return {
22
- type: 'hyperapp',
23
- root: root,
24
- state: state,
25
- actions: actions,
26
- };
27
- },
28
- HyperappExtension: extension_1.createExtension(api, rootName),
29
- };
8
+ function createHyperappApi(config = {}) {
9
+ return (context) => {
10
+ const convert = (0, converter_1.createConverter)(config);
11
+ context.converters.hyperapp = ({ root, state, actions }) => convert(root, state, actions);
12
+ return {
13
+ fromHyperapp(root, state, actions) {
14
+ return {
15
+ type: 'hyperapp',
16
+ root,
17
+ state,
18
+ actions,
19
+ };
20
+ },
21
+ HyperappExtension: convert.Extension,
30
22
  };
31
23
  };
32
24
  }
package/lib/create.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":";;;AACA,yCAA8C;AAC9C,yCAA8C;AAc9C;;GAEG;AACH,SAAgB,iBAAiB,CAAC,MAA2B;IAA3B,uBAAA,EAAA,WAA2B;IACnD,IAAA,QAAQ,GAAK,MAAM,SAAX,CAAY;IAE5B,OAAO,UAAC,OAAO;QACb,IAAM,OAAO,GAAG,2BAAe,EAAE,CAAC;QAClC,OAAO,CAAC,UAAU,CAAC,QAAQ,GAAG,UAAC,EAAwB;gBAAtB,IAAI,UAAA,EAAE,KAAK,WAAA,EAAE,OAAO,aAAA;YAAO,OAAA,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC;QAA7B,CAA6B,CAAC;QAE1F,OAAO,UAAC,GAAG;YACT,OAAO;gBACL,YAAY,YAAC,IAAI,EAAE,KAAK,EAAE,OAAO;oBAC/B,OAAO;wBACL,IAAI,EAAE,UAAU;wBAChB,IAAI,MAAA;wBACJ,KAAK,OAAA;wBACL,OAAO,SAAA;qBACR,CAAC;gBACJ,CAAC;gBACD,iBAAiB,EAAE,2BAAe,CAAC,GAAG,EAAE,QAAQ,CAAC;aAClD,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AArBD,8CAqBC"}
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":";;;AACA,2CAAwE;AAQxE;;GAEG;AACH,SAAgB,iBAAiB,CAAC,SAAyB,EAAE;IAC3D,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,MAAM,OAAO,GAAG,IAAA,2BAAe,EAAC,MAAM,CAAC,CAAC;QACxC,OAAO,CAAC,UAAU,CAAC,QAAQ,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAE1F,OAAO;YACL,YAAY,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO;gBAC/B,OAAO;oBACL,IAAI,EAAE,UAAU;oBAChB,IAAI;oBACJ,KAAK;oBACL,OAAO;iBACR,CAAC;YACJ,CAAC;YACD,iBAAiB,EAAE,OAAO,CAAC,SAAS;SACrC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAjBD,8CAiBC"}
@@ -1,3 +1,3 @@
1
- import type { PiletApi, ExtensionSlotProps } from 'piral-core';
1
+ import type { ExtensionSlotProps } from 'piral-core';
2
2
  import type { Component } from './types';
3
- export declare function createExtension(api: PiletApi, rootName?: string): Component<ExtensionSlotProps>;
3
+ export declare function createExtension(rootName: string): Component<ExtensionSlotProps>;
package/lib/extension.js CHANGED
@@ -1,16 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createExtension = void 0;
4
- var mount_1 = require("./mount");
5
- function createExtension(api, rootName) {
6
- if (rootName === void 0) { rootName = 'slot'; }
7
- return function (props) {
8
- return mount_1.createHyperappElement(rootName, {
9
- oncreate: function (element) {
10
- api.renderHtmlExtension(element, props);
11
- },
12
- });
13
- };
4
+ const mount_1 = require("./mount");
5
+ function createExtension(rootName) {
6
+ return (props) => (0, mount_1.createHyperappElement)(rootName, {
7
+ oncreate(element) {
8
+ element.dispatchEvent(new CustomEvent('render-html', {
9
+ bubbles: true,
10
+ detail: {
11
+ target: element,
12
+ props,
13
+ },
14
+ }));
15
+ },
16
+ });
14
17
  }
15
18
  exports.createExtension = createExtension;
16
19
  //# sourceMappingURL=extension.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":";;;AACA,iCAAgD;AAGhD,SAAgB,eAAe,CAAC,GAAa,EAAE,QAAiB;IAAjB,yBAAA,EAAA,iBAAiB;IAC9D,OAAO,UAAC,KAAK;QACX,OAAA,6BAAqB,CAAC,QAAQ,EAAE;YAC9B,QAAQ,EAAR,UAAS,OAAoB;gBAC3B,GAAG,CAAC,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC1C,CAAC;SACF,CAAC;IAJF,CAIE,CAAC;AACP,CAAC;AAPD,0CAOC"}
1
+ {"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":";;;AACA,mCAAgD;AAGhD,SAAgB,eAAe,CAAC,QAAgB;IAC9C,OAAO,CAAC,KAAK,EAAE,EAAE,CACf,IAAA,6BAAqB,EAAC,QAAQ,EAAE;QAC9B,QAAQ,CAAC,OAAoB;YAC3B,OAAO,CAAC,aAAa,CACnB,IAAI,WAAW,CAAC,aAAa,EAAE;gBAC7B,OAAO,EAAE,IAAI;gBACb,MAAM,EAAE;oBACN,MAAM,EAAE,OAAO;oBACf,KAAK;iBACN;aACF,CAAC,CACH,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACP,CAAC;AAfD,0CAeC"}
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./create"), exports);
5
- tslib_1.__exportStar(require("./types"), exports);
3
+ const tslib_1 = require("tslib");
4
+ (0, tslib_1.__exportStar)(require("./create"), exports);
5
+ (0, tslib_1.__exportStar)(require("./types"), exports);
6
6
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mDAAyB;AACzB,kDAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,wDAAyB;AACzB,uDAAwB"}
package/lib/mount.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { Component } from './types';
1
+ import type { Component } from './types';
2
2
  export declare function mountHyperapp<T extends Object>(el: HTMLElement, root: Component<T>, props: T, ctx: any, state: any, actions: any): void;
3
3
  export declare function createHyperappElement(name: string, props: any): any;
package/lib/mount.js CHANGED
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createHyperappElement = exports.mountHyperapp = void 0;
4
- var tslib_1 = require("tslib");
5
- var _a = require('hyperapp'), h = _a.h, app = _a.app;
4
+ const { h, app } = require('hyperapp');
6
5
  function mountHyperapp(el, root, props, ctx, state, actions) {
7
- app(tslib_1.__assign(tslib_1.__assign({}, ctx), state), actions, function () { return h(root, props); }, el);
6
+ app(Object.assign(Object.assign({}, ctx), state), actions, () => h(root, props), el);
8
7
  }
9
8
  exports.mountHyperapp = mountHyperapp;
10
9
  function createHyperappElement(name, props) {
package/lib/mount.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mount.js","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":";;;;AAEM,IAAA,KAAa,OAAO,CAAC,UAAU,CAAC,EAA9B,CAAC,OAAA,EAAE,GAAG,SAAwB,CAAC;AAEvC,SAAgB,aAAa,CAC3B,EAAe,EACf,IAAkB,EAClB,KAAQ,EACR,GAAQ,EACR,KAAU,EACV,OAAY;IAEZ,GAAG,uCAEI,GAAG,GACH,KAAK,GAEV,OAAO,EACP,cAAM,OAAA,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAd,CAAc,EACpB,EAAE,CACH,CAAC;AACJ,CAAC;AAjBD,sCAiBC;AAED,SAAgB,qBAAqB,CAAC,IAAY,EAAE,KAAU;IAC5D,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;AAC5B,CAAC;AAFD,sDAEC"}
1
+ {"version":3,"file":"mount.js","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":";;;AAEA,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEvC,SAAgB,aAAa,CAC3B,EAAe,EACf,IAAkB,EAClB,KAAQ,EACR,GAAQ,EACR,KAAU,EACV,OAAY;IAEZ,GAAG,iCAEI,GAAG,GACH,KAAK,GAEV,OAAO,EACP,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EACpB,EAAE,CACH,CAAC;AACJ,CAAC;AAjBD,sCAiBC;AAED,SAAgB,qBAAqB,CAAC,IAAY,EAAE,KAAU;IAC5D,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;AAC5B,CAAC;AAFD,sDAEC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piral-hyperapp",
3
- "version": "0.13.7",
3
+ "version": "0.14.0-alpha.3154",
4
4
  "description": "Plugin for integrating hyperapp components in Piral.",
5
5
  "keywords": [
6
6
  "piral",
@@ -25,7 +25,6 @@
25
25
  "lib",
26
26
  "src",
27
27
  "convert.d.ts",
28
- "convert.ts",
29
28
  "convert.js"
30
29
  ],
31
30
  "repository": {
@@ -45,11 +44,11 @@
45
44
  },
46
45
  "devDependencies": {
47
46
  "hyperapp": "^1.2.10",
48
- "piral-core": "^0.13.7"
47
+ "piral-core": "^0.14.0-alpha.3154"
49
48
  },
50
49
  "peerDependencies": {
51
50
  "hyperapp": "^1.0.0",
52
- "piral-core": "0.13.x"
51
+ "piral-core": "0.14.x"
53
52
  },
54
- "gitHead": "201de6c1cddaacb1e5f9646bdd17dc43acf09e8e"
53
+ "gitHead": "bc6cc60a59e6a8b1a154d187883cb794e8609939"
55
54
  }
package/src/converter.ts CHANGED
@@ -1,8 +1,19 @@
1
- import { ForeignComponent, BaseComponentProps } from 'piral-core';
1
+ import type { ForeignComponent, BaseComponentProps } from 'piral-core';
2
2
  import { mountHyperapp } from './mount';
3
- import { Component } from './types';
3
+ import { createExtension } from './extension';
4
+ import type { Component } from './types';
4
5
 
5
- export function createConverter() {
6
+ export interface HyperappConverterOptions {
7
+ /**
8
+ * Defines the name of the root element.
9
+ * @default slot
10
+ */
11
+ rootName?: string;
12
+ }
13
+
14
+ export function createConverter(config: HyperappConverterOptions = {}) {
15
+ const { rootName = 'slot' } = config;
16
+ const Extension = createExtension(rootName);
6
17
  const convert = <TProps extends BaseComponentProps>(
7
18
  root: Component<TProps>,
8
19
  state: any,
@@ -17,5 +28,6 @@ export function createConverter() {
17
28
  },
18
29
  };
19
30
  };
31
+ convert.Extension = Extension;
20
32
  return convert;
21
33
  }
package/src/create.ts CHANGED
@@ -1,41 +1,30 @@
1
1
  import type { PiralPlugin } from 'piral-core';
2
- import { createConverter } from './converter';
3
- import { createExtension } from './extension';
2
+ import { createConverter, HyperappConverterOptions } from './converter';
4
3
  import type { PiletHyperappApi } from './types';
5
4
 
6
5
  /**
7
6
  * Available configuration options for the Hyperapp plugin.
8
7
  */
9
- export interface HyperappConfig {
10
- /**
11
- * Defines the name of the root element.
12
- * @default slot
13
- */
14
- rootName?: string;
15
- }
8
+ export interface HyperappConfig extends HyperappConverterOptions {}
16
9
 
17
10
  /**
18
11
  * Creates new Pilet API extensions for the Hyperapp integration.
19
12
  */
20
13
  export function createHyperappApi(config: HyperappConfig = {}): PiralPlugin<PiletHyperappApi> {
21
- const { rootName } = config;
22
-
23
14
  return (context) => {
24
- const convert = createConverter();
15
+ const convert = createConverter(config);
25
16
  context.converters.hyperapp = ({ root, state, actions }) => convert(root, state, actions);
26
17
 
27
- return (api) => {
28
- return {
29
- fromHyperapp(root, state, actions) {
30
- return {
31
- type: 'hyperapp',
32
- root,
33
- state,
34
- actions,
35
- };
36
- },
37
- HyperappExtension: createExtension(api, rootName),
38
- };
18
+ return {
19
+ fromHyperapp(root, state, actions) {
20
+ return {
21
+ type: 'hyperapp',
22
+ root,
23
+ state,
24
+ actions,
25
+ };
26
+ },
27
+ HyperappExtension: convert.Extension,
39
28
  };
40
29
  };
41
30
  }
package/src/extension.ts CHANGED
@@ -1,12 +1,20 @@
1
- import type { PiletApi, ExtensionSlotProps } from 'piral-core';
1
+ import type { ExtensionSlotProps } from 'piral-core';
2
2
  import { createHyperappElement } from './mount';
3
3
  import type { Component } from './types';
4
4
 
5
- export function createExtension(api: PiletApi, rootName = 'slot'): Component<ExtensionSlotProps> {
5
+ export function createExtension(rootName: string): Component<ExtensionSlotProps> {
6
6
  return (props) =>
7
7
  createHyperappElement(rootName, {
8
8
  oncreate(element: HTMLElement) {
9
- api.renderHtmlExtension(element, props);
9
+ element.dispatchEvent(
10
+ new CustomEvent('render-html', {
11
+ bubbles: true,
12
+ detail: {
13
+ target: element,
14
+ props,
15
+ },
16
+ }),
17
+ );
10
18
  },
11
19
  });
12
20
  }
package/src/mount.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Component } from './types';
1
+ import type { Component } from './types';
2
2
 
3
3
  const { h, app } = require('hyperapp');
4
4
 
package/convert.ts DELETED
@@ -1,16 +0,0 @@
1
- import type { HtmlComponent } from 'piral-core';
2
- import { createConverter } from './lib/converter';
3
- import { createExtension } from './lib/extension';
4
-
5
- const convert = createConverter();
6
-
7
- export interface HyperappConverter {
8
- (...params: Parameters<typeof convert>): HtmlComponent<any>;
9
- }
10
-
11
- export const fromHyperapp: HyperappConverter = (root, state, actions) => ({
12
- type: 'html',
13
- component: convert(root, state, actions),
14
- });
15
-
16
- export const createHyperappExtension = createExtension;