piral-riot 0.13.6 → 0.14.0-alpha.3152
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 +12 -2
- package/esm/converter.js +12 -8
- package/esm/converter.js.map +1 -1
- package/esm/create.d.ts +2 -7
- package/esm/create.js +10 -16
- package/esm/create.js.map +1 -1
- package/esm/extension.d.ts +2 -2
- package/esm/extension.js +15 -10
- package/esm/extension.js.map +1 -1
- package/lib/converter.d.ts +12 -2
- package/lib/converter.js +13 -9
- package/lib/converter.js.map +1 -1
- package/lib/create.d.ts +2 -7
- package/lib/create.js +11 -17
- package/lib/create.js.map +1 -1
- package/lib/extension.d.ts +2 -2
- package/lib/extension.js +15 -10
- package/lib/extension.js.map +1 -1
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/package.json +4 -5
- package/src/converter.ts +15 -2
- package/src/create.ts +7 -16
- package/src/extension.ts +11 -6
- package/convert.ts +0 -16
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>(component: import("riot").RiotComponentShell<TProps, object>, captured?: Record<string, any>) => import("piral-core").ForeignComponent<TProps>;
|
|
2
|
+
import { createConverter } from './lib/converter';
|
|
4
3
|
export interface RiotConverter {
|
|
5
|
-
(...params: Parameters<typeof
|
|
4
|
+
(...params: Parameters<ReturnType<typeof createConverter>>): HtmlComponent<any>;
|
|
6
5
|
}
|
|
7
|
-
export declare
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
export declare function createRiotConverter(...params: Parameters<typeof createConverter>): {
|
|
7
|
+
from: RiotConverter;
|
|
8
|
+
Extension: import("riot").RiotComponentShell<import("piral-core").ExtensionSlotProps<string>, object>;
|
|
9
|
+
};
|
|
10
|
+
declare const fromRiot: RiotConverter, RiotExtension: import("riot").RiotComponentShell<import("piral-core").ExtensionSlotProps<string>, object>;
|
|
11
|
+
export { fromRiot, RiotExtension };
|
package/convert.js
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
exports.__esModule = true;
|
|
3
|
-
exports.
|
|
3
|
+
exports.RiotExtension = exports.fromRiot = exports.createRiotConverter = void 0;
|
|
4
4
|
var converter_1 = require("./lib/converter");
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
function createRiotConverter() {
|
|
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 (component, captured) { return ({
|
|
13
|
+
type: 'html',
|
|
14
|
+
component: convert(component, captured)
|
|
15
|
+
}); };
|
|
16
|
+
return { from: from, Extension: Extension };
|
|
17
|
+
}
|
|
18
|
+
exports.createRiotConverter = createRiotConverter;
|
|
19
|
+
var _a = createRiotConverter(), fromRiot = _a.from, RiotExtension = _a.Extension;
|
|
11
20
|
exports.fromRiot = fromRiot;
|
|
12
|
-
exports.
|
|
21
|
+
exports.RiotExtension = RiotExtension;
|
package/esm/converter.d.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
import * as Riot from 'riot';
|
|
2
|
-
import { ForeignComponent, BaseComponentProps } from 'piral-core';
|
|
3
|
-
export
|
|
2
|
+
import type { ForeignComponent, BaseComponentProps } from 'piral-core';
|
|
3
|
+
export interface RiotConverterOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Defines the name of the Riot extension element.
|
|
6
|
+
* @default riot-extension
|
|
7
|
+
*/
|
|
8
|
+
extensionName?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function createConverter(config?: RiotConverterOptions): {
|
|
11
|
+
<TProps extends BaseComponentProps>(component: Riot.RiotComponentShell<TProps, object>, captured?: Record<string, any>): ForeignComponent<TProps>;
|
|
12
|
+
Extension: Riot.RiotComponentShell<import("piral-core").ExtensionSlotProps<string>, object>;
|
|
13
|
+
};
|
package/esm/converter.js
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
1
|
import * as Riot from 'riot';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { createExtension } from './extension';
|
|
3
|
+
export function createConverter(config = {}) {
|
|
4
|
+
const { extensionName = 'riot-extension' } = config;
|
|
5
|
+
const Extension = createExtension(extensionName);
|
|
6
|
+
const convert = (component, captured) => {
|
|
7
|
+
const mountApp = Riot.component(component);
|
|
8
|
+
let app = undefined;
|
|
7
9
|
return {
|
|
8
|
-
mount
|
|
9
|
-
app = mountApp(el,
|
|
10
|
+
mount(el, props, ctx) {
|
|
11
|
+
app = mountApp(el, Object.assign(Object.assign(Object.assign({}, captured), ctx), props));
|
|
10
12
|
},
|
|
11
|
-
unmount
|
|
13
|
+
unmount(el) {
|
|
12
14
|
app.unmount(true);
|
|
13
15
|
el.innerHTML = '';
|
|
16
|
+
app = undefined;
|
|
14
17
|
},
|
|
15
18
|
};
|
|
16
19
|
};
|
|
20
|
+
convert.Extension = Extension;
|
|
17
21
|
return convert;
|
|
18
22
|
}
|
|
19
23
|
//# 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":"
|
|
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"}
|
package/esm/create.d.ts
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import { PiralPlugin } from 'piral-core';
|
|
2
|
-
import { PiletRiotApi } from './types';
|
|
1
|
+
import type { PiralPlugin } from 'piral-core';
|
|
2
|
+
import type { PiletRiotApi } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Available configuration options for the Riot.js plugin.
|
|
5
5
|
*/
|
|
6
6
|
export interface RiotConfig {
|
|
7
|
-
/**
|
|
8
|
-
* Defines the name of the Riot extension element.
|
|
9
|
-
* @default riot-extension
|
|
10
|
-
*/
|
|
11
|
-
extensionName?: string;
|
|
12
7
|
}
|
|
13
8
|
/**
|
|
14
9
|
* Creates new Pilet API extensions for integrating Riot.js.
|
package/esm/create.js
CHANGED
|
@@ -1,27 +1,21 @@
|
|
|
1
1
|
import { createConverter } from './converter';
|
|
2
|
-
import { createExtension } from './extension';
|
|
3
2
|
/**
|
|
4
3
|
* Creates new Pilet API extensions for integrating Riot.js.
|
|
5
4
|
*/
|
|
6
|
-
export function createRiotApi(config) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var component = _a.component, captured = _a.captured;
|
|
13
|
-
return convert(component, captured);
|
|
14
|
-
};
|
|
15
|
-
return function (api) { return ({
|
|
16
|
-
fromRiot: function (component, captured) {
|
|
5
|
+
export function createRiotApi(config = {}) {
|
|
6
|
+
return (context) => {
|
|
7
|
+
const convert = createConverter(config);
|
|
8
|
+
context.converters.riot = ({ component, captured }) => convert(component, captured);
|
|
9
|
+
return {
|
|
10
|
+
fromRiot(component, captured) {
|
|
17
11
|
return {
|
|
18
12
|
type: 'riot',
|
|
19
|
-
component
|
|
20
|
-
captured
|
|
13
|
+
component,
|
|
14
|
+
captured,
|
|
21
15
|
};
|
|
22
16
|
},
|
|
23
|
-
RiotExtension:
|
|
24
|
-
}
|
|
17
|
+
RiotExtension: convert.Extension,
|
|
18
|
+
};
|
|
25
19
|
};
|
|
26
20
|
}
|
|
27
21
|
//# sourceMappingURL=create.js.map
|
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;
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAQ9C;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,SAAqB,EAAE;IACnD,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,MAAM,OAAO,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;QACxC,OAAO,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAEpF,OAAO;YACL,QAAQ,CAAC,SAAS,EAAE,QAAQ;gBAC1B,OAAO;oBACL,IAAI,EAAE,MAAM;oBACZ,SAAS;oBACT,QAAQ;iBACT,CAAC;YACJ,CAAC;YACD,aAAa,EAAE,OAAO,CAAC,SAAS;SACjC,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 { RiotComponentShell } from 'riot';
|
|
3
|
-
export declare function createExtension(
|
|
3
|
+
export declare function createExtension(extensionName: string): RiotComponentShell<ExtensionSlotProps>;
|
package/esm/extension.js
CHANGED
|
@@ -1,23 +1,28 @@
|
|
|
1
|
-
export function createExtension(
|
|
2
|
-
if (extensionName === void 0) { extensionName = 'riot-extension'; }
|
|
1
|
+
export function createExtension(extensionName) {
|
|
3
2
|
return {
|
|
4
3
|
name: extensionName,
|
|
5
|
-
template
|
|
6
|
-
|
|
7
|
-
mount
|
|
8
|
-
|
|
4
|
+
template() {
|
|
5
|
+
const templateChunk = {
|
|
6
|
+
mount(element, scope) {
|
|
7
|
+
element.dispatchEvent(new CustomEvent('render-html', {
|
|
8
|
+
bubbles: true,
|
|
9
|
+
detail: {
|
|
10
|
+
target: element,
|
|
11
|
+
props: scope.props,
|
|
12
|
+
},
|
|
13
|
+
}));
|
|
9
14
|
return templateChunk;
|
|
10
15
|
},
|
|
11
|
-
update
|
|
16
|
+
update() {
|
|
12
17
|
return templateChunk;
|
|
13
18
|
},
|
|
14
|
-
unmount
|
|
19
|
+
unmount() {
|
|
15
20
|
return templateChunk;
|
|
16
21
|
},
|
|
17
|
-
createDOM
|
|
22
|
+
createDOM() {
|
|
18
23
|
return templateChunk;
|
|
19
24
|
},
|
|
20
|
-
clone
|
|
25
|
+
clone() {
|
|
21
26
|
return templateChunk;
|
|
22
27
|
},
|
|
23
28
|
};
|
package/esm/extension.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,eAAe,
|
|
1
|
+
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,eAAe,CAAC,aAAqB;IACnD,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,QAAQ;YACN,MAAM,aAAa,GAAkB;gBACnC,KAAK,CAAC,OAAO,EAAE,KAAK;oBAClB,OAAO,CAAC,aAAa,CACnB,IAAI,WAAW,CAAC,aAAa,EAAE;wBAC7B,OAAO,EAAE,IAAI;wBACb,MAAM,EAAE;4BACN,MAAM,EAAE,OAAO;4BACf,KAAK,EAAE,KAAK,CAAC,KAAK;yBACnB;qBACF,CAAC,CACH,CAAC;oBACF,OAAO,aAAa,CAAC;gBACvB,CAAC;gBACD,MAAM;oBACJ,OAAO,aAAa,CAAC;gBACvB,CAAC;gBACD,OAAO;oBACL,OAAO,aAAa,CAAC;gBACvB,CAAC;gBACD,SAAS;oBACP,OAAO,aAAa,CAAC;gBACvB,CAAC;gBACD,KAAK;oBACH,OAAO,aAAa,CAAC;gBACvB,CAAC;aACF,CAAC;YACF,OAAO,aAAa,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/lib/converter.d.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
import * as Riot from 'riot';
|
|
2
|
-
import { ForeignComponent, BaseComponentProps } from 'piral-core';
|
|
3
|
-
export
|
|
2
|
+
import type { ForeignComponent, BaseComponentProps } from 'piral-core';
|
|
3
|
+
export interface RiotConverterOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Defines the name of the Riot extension element.
|
|
6
|
+
* @default riot-extension
|
|
7
|
+
*/
|
|
8
|
+
extensionName?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function createConverter(config?: RiotConverterOptions): {
|
|
11
|
+
<TProps extends BaseComponentProps>(component: Riot.RiotComponentShell<TProps, object>, captured?: Record<string, any>): ForeignComponent<TProps>;
|
|
12
|
+
Extension: Riot.RiotComponentShell<import("piral-core").ExtensionSlotProps<string>, object>;
|
|
13
|
+
};
|
package/lib/converter.js
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createConverter = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function createConverter() {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
const Riot = require("riot");
|
|
5
|
+
const extension_1 = require("./extension");
|
|
6
|
+
function createConverter(config = {}) {
|
|
7
|
+
const { extensionName = 'riot-extension' } = config;
|
|
8
|
+
const Extension = (0, extension_1.createExtension)(extensionName);
|
|
9
|
+
const convert = (component, captured) => {
|
|
10
|
+
const mountApp = Riot.component(component);
|
|
11
|
+
let app = undefined;
|
|
10
12
|
return {
|
|
11
|
-
mount
|
|
12
|
-
app = mountApp(el,
|
|
13
|
+
mount(el, props, ctx) {
|
|
14
|
+
app = mountApp(el, Object.assign(Object.assign(Object.assign({}, captured), ctx), props));
|
|
13
15
|
},
|
|
14
|
-
unmount
|
|
16
|
+
unmount(el) {
|
|
15
17
|
app.unmount(true);
|
|
16
18
|
el.innerHTML = '';
|
|
19
|
+
app = undefined;
|
|
17
20
|
},
|
|
18
21
|
};
|
|
19
22
|
};
|
|
23
|
+
convert.Extension = Extension;
|
|
20
24
|
return convert;
|
|
21
25
|
}
|
|
22
26
|
exports.createConverter = createConverter;
|
package/lib/converter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":"
|
|
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"}
|
package/lib/create.d.ts
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import { PiralPlugin } from 'piral-core';
|
|
2
|
-
import { PiletRiotApi } from './types';
|
|
1
|
+
import type { PiralPlugin } from 'piral-core';
|
|
2
|
+
import type { PiletRiotApi } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Available configuration options for the Riot.js plugin.
|
|
5
5
|
*/
|
|
6
6
|
export interface RiotConfig {
|
|
7
|
-
/**
|
|
8
|
-
* Defines the name of the Riot extension element.
|
|
9
|
-
* @default riot-extension
|
|
10
|
-
*/
|
|
11
|
-
extensionName?: string;
|
|
12
7
|
}
|
|
13
8
|
/**
|
|
14
9
|
* Creates new Pilet API extensions for integrating Riot.js.
|
package/lib/create.js
CHANGED
|
@@ -1,30 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createRiotApi = 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 integrating Riot.js.
|
|
8
7
|
*/
|
|
9
|
-
function createRiotApi(config) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var component = _a.component, captured = _a.captured;
|
|
16
|
-
return convert(component, captured);
|
|
17
|
-
};
|
|
18
|
-
return function (api) { return ({
|
|
19
|
-
fromRiot: function (component, captured) {
|
|
8
|
+
function createRiotApi(config = {}) {
|
|
9
|
+
return (context) => {
|
|
10
|
+
const convert = (0, converter_1.createConverter)(config);
|
|
11
|
+
context.converters.riot = ({ component, captured }) => convert(component, captured);
|
|
12
|
+
return {
|
|
13
|
+
fromRiot(component, captured) {
|
|
20
14
|
return {
|
|
21
15
|
type: 'riot',
|
|
22
|
-
component
|
|
23
|
-
captured
|
|
16
|
+
component,
|
|
17
|
+
captured,
|
|
24
18
|
};
|
|
25
19
|
},
|
|
26
|
-
RiotExtension:
|
|
27
|
-
}
|
|
20
|
+
RiotExtension: convert.Extension,
|
|
21
|
+
};
|
|
28
22
|
};
|
|
29
23
|
}
|
|
30
24
|
exports.createRiotApi = createRiotApi;
|
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,2CAA8C;AAQ9C;;GAEG;AACH,SAAgB,aAAa,CAAC,SAAqB,EAAE;IACnD,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,MAAM,OAAO,GAAG,IAAA,2BAAe,EAAC,MAAM,CAAC,CAAC;QACxC,OAAO,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAEpF,OAAO;YACL,QAAQ,CAAC,SAAS,EAAE,QAAQ;gBAC1B,OAAO;oBACL,IAAI,EAAE,MAAM;oBACZ,SAAS;oBACT,QAAQ;iBACT,CAAC;YACJ,CAAC;YACD,aAAa,EAAE,OAAO,CAAC,SAAS;SACjC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAhBD,sCAgBC"}
|
package/lib/extension.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ExtensionSlotProps } from 'piral-core';
|
|
2
2
|
import type { RiotComponentShell } from 'riot';
|
|
3
|
-
export declare function createExtension(
|
|
3
|
+
export declare function createExtension(extensionName: string): RiotComponentShell<ExtensionSlotProps>;
|
package/lib/extension.js
CHANGED
|
@@ -1,26 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createExtension = void 0;
|
|
4
|
-
function createExtension(
|
|
5
|
-
if (extensionName === void 0) { extensionName = 'riot-extension'; }
|
|
4
|
+
function createExtension(extensionName) {
|
|
6
5
|
return {
|
|
7
6
|
name: extensionName,
|
|
8
|
-
template
|
|
9
|
-
|
|
10
|
-
mount
|
|
11
|
-
|
|
7
|
+
template() {
|
|
8
|
+
const templateChunk = {
|
|
9
|
+
mount(element, scope) {
|
|
10
|
+
element.dispatchEvent(new CustomEvent('render-html', {
|
|
11
|
+
bubbles: true,
|
|
12
|
+
detail: {
|
|
13
|
+
target: element,
|
|
14
|
+
props: scope.props,
|
|
15
|
+
},
|
|
16
|
+
}));
|
|
12
17
|
return templateChunk;
|
|
13
18
|
},
|
|
14
|
-
update
|
|
19
|
+
update() {
|
|
15
20
|
return templateChunk;
|
|
16
21
|
},
|
|
17
|
-
unmount
|
|
22
|
+
unmount() {
|
|
18
23
|
return templateChunk;
|
|
19
24
|
},
|
|
20
|
-
createDOM
|
|
25
|
+
createDOM() {
|
|
21
26
|
return templateChunk;
|
|
22
27
|
},
|
|
23
|
-
clone
|
|
28
|
+
clone() {
|
|
24
29
|
return templateChunk;
|
|
25
30
|
},
|
|
26
31
|
};
|
package/lib/extension.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":";;;AAIA,SAAgB,eAAe,
|
|
1
|
+
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":";;;AAIA,SAAgB,eAAe,CAAC,aAAqB;IACnD,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,QAAQ;YACN,MAAM,aAAa,GAAkB;gBACnC,KAAK,CAAC,OAAO,EAAE,KAAK;oBAClB,OAAO,CAAC,aAAa,CACnB,IAAI,WAAW,CAAC,aAAa,EAAE;wBAC7B,OAAO,EAAE,IAAI;wBACb,MAAM,EAAE;4BACN,MAAM,EAAE,OAAO;4BACf,KAAK,EAAE,KAAK,CAAC,KAAK;yBACnB;qBACF,CAAC,CACH,CAAC;oBACF,OAAO,aAAa,CAAC;gBACvB,CAAC;gBACD,MAAM;oBACJ,OAAO,aAAa,CAAC;gBACvB,CAAC;gBACD,OAAO;oBACL,OAAO,aAAa,CAAC;gBACvB,CAAC;gBACD,SAAS;oBACP,OAAO,aAAa,CAAC;gBACvB,CAAC;gBACD,KAAK;oBACH,OAAO,aAAa,CAAC;gBACvB,CAAC;aACF,CAAC;YACF,OAAO,aAAa,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC;AAjCD,0CAiCC"}
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-riot",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0-alpha.3152",
|
|
4
4
|
"description": "Plugin for integrating Riot.js 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": {
|
|
@@ -44,12 +43,12 @@
|
|
|
44
43
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
45
44
|
},
|
|
46
45
|
"devDependencies": {
|
|
47
|
-
"piral-core": "^0.
|
|
46
|
+
"piral-core": "^0.14.0-alpha.3152",
|
|
48
47
|
"riot": "^4.7.2"
|
|
49
48
|
},
|
|
50
49
|
"peerDependencies": {
|
|
51
|
-
"piral-core": "0.
|
|
50
|
+
"piral-core": "0.14.x",
|
|
52
51
|
"riot": "^4.0.0"
|
|
53
52
|
},
|
|
54
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "4ad88a8b8bcdee17f22e7e1e2e8feb41df6210e5"
|
|
55
54
|
}
|
package/src/converter.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import * as Riot from 'riot';
|
|
2
|
-
import { ForeignComponent, BaseComponentProps } from 'piral-core';
|
|
2
|
+
import type { ForeignComponent, BaseComponentProps } from 'piral-core';
|
|
3
|
+
import { createExtension } from './extension';
|
|
3
4
|
|
|
4
|
-
export
|
|
5
|
+
export interface RiotConverterOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Defines the name of the Riot extension element.
|
|
8
|
+
* @default riot-extension
|
|
9
|
+
*/
|
|
10
|
+
extensionName?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function createConverter(config: RiotConverterOptions = {}) {
|
|
14
|
+
const { extensionName = 'riot-extension' } = config;
|
|
15
|
+
const Extension = createExtension(extensionName);
|
|
5
16
|
const convert = <TProps extends BaseComponentProps>(
|
|
6
17
|
component: Riot.RiotComponentShell<TProps>,
|
|
7
18
|
captured?: Record<string, any>,
|
|
@@ -20,8 +31,10 @@ export function createConverter() {
|
|
|
20
31
|
unmount(el) {
|
|
21
32
|
app.unmount(true);
|
|
22
33
|
el.innerHTML = '';
|
|
34
|
+
app = undefined;
|
|
23
35
|
},
|
|
24
36
|
};
|
|
25
37
|
};
|
|
38
|
+
convert.Extension = Extension;
|
|
26
39
|
return convert;
|
|
27
40
|
}
|
package/src/create.ts
CHANGED
|
@@ -1,30 +1,21 @@
|
|
|
1
|
-
import { PiralPlugin } from 'piral-core';
|
|
1
|
+
import type { PiralPlugin } from 'piral-core';
|
|
2
2
|
import { createConverter } from './converter';
|
|
3
|
-
import { PiletRiotApi } from './types';
|
|
4
|
-
import { createExtension } from './extension';
|
|
3
|
+
import type { PiletRiotApi } from './types';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* Available configuration options for the Riot.js plugin.
|
|
8
7
|
*/
|
|
9
|
-
export interface RiotConfig {
|
|
10
|
-
/**
|
|
11
|
-
* Defines the name of the Riot extension element.
|
|
12
|
-
* @default riot-extension
|
|
13
|
-
*/
|
|
14
|
-
extensionName?: string;
|
|
15
|
-
}
|
|
8
|
+
export interface RiotConfig {}
|
|
16
9
|
|
|
17
10
|
/**
|
|
18
11
|
* Creates new Pilet API extensions for integrating Riot.js.
|
|
19
12
|
*/
|
|
20
13
|
export function createRiotApi(config: RiotConfig = {}): PiralPlugin<PiletRiotApi> {
|
|
21
|
-
const { extensionName } = config;
|
|
22
|
-
|
|
23
14
|
return (context) => {
|
|
24
|
-
const convert = createConverter();
|
|
15
|
+
const convert = createConverter(config);
|
|
25
16
|
context.converters.riot = ({ component, captured }) => convert(component, captured);
|
|
26
17
|
|
|
27
|
-
return
|
|
18
|
+
return {
|
|
28
19
|
fromRiot(component, captured) {
|
|
29
20
|
return {
|
|
30
21
|
type: 'riot',
|
|
@@ -32,7 +23,7 @@ export function createRiotApi(config: RiotConfig = {}): PiralPlugin<PiletRiotApi
|
|
|
32
23
|
captured,
|
|
33
24
|
};
|
|
34
25
|
},
|
|
35
|
-
RiotExtension:
|
|
36
|
-
}
|
|
26
|
+
RiotExtension: convert.Extension,
|
|
27
|
+
};
|
|
37
28
|
};
|
|
38
29
|
}
|
package/src/extension.ts
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ExtensionSlotProps } from 'piral-core';
|
|
2
2
|
import type { RiotComponentShell } from 'riot';
|
|
3
3
|
import type { TemplateChunk } from '@riotjs/dom-bindings';
|
|
4
4
|
|
|
5
|
-
export function createExtension(
|
|
6
|
-
api: PiletApi,
|
|
7
|
-
extensionName = 'riot-extension',
|
|
8
|
-
): RiotComponentShell<ExtensionSlotProps> {
|
|
5
|
+
export function createExtension(extensionName: string): RiotComponentShell<ExtensionSlotProps> {
|
|
9
6
|
return {
|
|
10
7
|
name: extensionName,
|
|
11
8
|
template() {
|
|
12
9
|
const templateChunk: TemplateChunk = {
|
|
13
10
|
mount(element, scope) {
|
|
14
|
-
|
|
11
|
+
element.dispatchEvent(
|
|
12
|
+
new CustomEvent('render-html', {
|
|
13
|
+
bubbles: true,
|
|
14
|
+
detail: {
|
|
15
|
+
target: element,
|
|
16
|
+
props: scope.props,
|
|
17
|
+
},
|
|
18
|
+
}),
|
|
19
|
+
);
|
|
15
20
|
return templateChunk;
|
|
16
21
|
},
|
|
17
22
|
update() {
|
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 RiotConverter {
|
|
8
|
-
(...params: Parameters<typeof convert>): HtmlComponent<any>;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const fromRiot: RiotConverter = (component, captured) => ({
|
|
12
|
-
type: 'html',
|
|
13
|
-
component: convert(component, captured),
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
export const createRiotExtension = createExtension;
|