piral-hyperapp 0.13.9 → 0.14.0-beta.3157
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 +8 -6
- package/convert.js +17 -8
- package/esm/converter.d.ts +13 -3
- package/esm/converter.js +8 -4
- package/esm/converter.js.map +1 -1
- package/esm/create.d.ts +2 -6
- package/esm/create.js +14 -22
- package/esm/create.js.map +1 -1
- package/esm/extension.d.ts +2 -2
- package/esm/extension.js +12 -9
- package/esm/extension.js.map +1 -1
- package/esm/mount.d.ts +1 -1
- package/esm/mount.js +2 -3
- package/esm/mount.js.map +1 -1
- package/lib/converter.d.ts +13 -3
- package/lib/converter.js +10 -6
- package/lib/converter.js.map +1 -1
- package/lib/create.d.ts +2 -6
- package/lib/create.js +15 -23
- package/lib/create.js.map +1 -1
- package/lib/extension.d.ts +2 -2
- package/lib/extension.js +13 -10
- package/lib/extension.js.map +1 -1
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/mount.d.ts +1 -1
- package/lib/mount.js +2 -3
- package/lib/mount.js.map +1 -1
- package/package.json +4 -4
- package/src/converter.ts +15 -3
- package/src/create.ts +13 -24
- package/src/extension.ts +11 -3
- package/src/mount.ts +1 -1
package/convert.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { HtmlComponent } from 'piral-core';
|
|
2
|
-
import {
|
|
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
|
|
4
|
+
(...params: Parameters<ReturnType<typeof createConverter>>): HtmlComponent<any>;
|
|
6
5
|
}
|
|
7
|
-
export declare
|
|
8
|
-
|
|
9
|
-
|
|
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.
|
|
3
|
+
exports.HyperExtension = exports.fromHyperapp = exports.createHyperappConverter = void 0;
|
|
4
4
|
var converter_1 = require("./lib/converter");
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
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.
|
|
21
|
+
exports.HyperExtension = HyperExtension;
|
package/esm/converter.d.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
import { ForeignComponent, BaseComponentProps } from 'piral-core';
|
|
2
|
-
import { Component } from './types';
|
|
3
|
-
export
|
|
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
|
-
|
|
3
|
-
|
|
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
|
|
8
|
+
mount(el, props, ctx) {
|
|
6
9
|
mountHyperapp(el, root, props, ctx, state, actions);
|
|
7
10
|
},
|
|
8
|
-
unmount
|
|
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
|
package/esm/converter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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,
|
|
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"}
|
package/esm/extension.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ExtensionSlotProps } from 'piral-core';
|
|
2
2
|
import type { Component } from './types';
|
|
3
|
-
export declare function createExtension(
|
|
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(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
package/esm/extension.js.map
CHANGED
|
@@ -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,
|
|
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
|
-
|
|
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(
|
|
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":"
|
|
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"}
|
package/lib/converter.d.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
import { ForeignComponent, BaseComponentProps } from 'piral-core';
|
|
2
|
-
import { Component } from './types';
|
|
3
|
-
export
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
|
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
|
|
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;
|
package/lib/converter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":";;;AACA,
|
|
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
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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,
|
|
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"}
|
package/lib/extension.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ExtensionSlotProps } from 'piral-core';
|
|
2
2
|
import type { Component } from './types';
|
|
3
|
-
export declare function createExtension(
|
|
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
|
-
|
|
5
|
-
function createExtension(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
package/lib/extension.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":";;;AACA,
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
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(
|
|
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":"
|
|
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.
|
|
3
|
+
"version": "0.14.0-beta.3157",
|
|
4
4
|
"description": "Plugin for integrating hyperapp components in Piral.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"piral",
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"hyperapp": "^1.2.10",
|
|
47
|
-
"piral-core": "^0.
|
|
47
|
+
"piral-core": "^0.14.0-beta.3157"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"hyperapp": "^1.0.0",
|
|
51
|
-
"piral-core": "0.
|
|
51
|
+
"piral-core": "0.14.x"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "1928e46becee1444f84df8e80a81aa12712d17e2"
|
|
54
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 {
|
|
3
|
+
import { createExtension } from './extension';
|
|
4
|
+
import type { Component } from './types';
|
|
4
5
|
|
|
5
|
-
export
|
|
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
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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 {
|
|
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(
|
|
5
|
+
export function createExtension(rootName: string): Component<ExtensionSlotProps> {
|
|
6
6
|
return (props) =>
|
|
7
7
|
createHyperappElement(rootName, {
|
|
8
8
|
oncreate(element: HTMLElement) {
|
|
9
|
-
|
|
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