piral-cycle 0.13.9 → 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 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, M extends import("@cycle/run").MatchingMain<import("./lib/types").PiralDomDrivers<TProps>, M>>(main: M) => import("piral-core").ForeignComponent<TProps>;
2
+ import { createConverter } from './lib/converter';
4
3
  export interface CycleConverter {
5
- (...params: Parameters<typeof convert>): HtmlComponent<any>;
4
+ (...params: Parameters<ReturnType<typeof createConverter>>): HtmlComponent<any>;
6
5
  }
7
- export declare const fromCycle: CycleConverter;
8
- export declare const createCycleExtension: typeof createExtension;
9
- export {};
6
+ export declare function createCycleConverter(...params: Parameters<typeof createConverter>): {
7
+ from: CycleConverter;
8
+ Extension: import("./lib/extension").CycleExtension;
9
+ };
10
+ declare const fromCycle: CycleConverter, CycleExtension: import("./lib/extension").CycleExtension;
11
+ export { fromCycle, CycleExtension };
package/convert.js CHANGED
@@ -1,12 +1,21 @@
1
1
  "use strict";
2
2
  exports.__esModule = true;
3
- exports.createCycleExtension = exports.fromCycle = void 0;
3
+ exports.CycleExtension = exports.fromCycle = exports.createCycleConverter = 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 fromCycle = function (main) { return ({
8
- type: 'html',
9
- component: convert(main)
10
- }); };
5
+ function createCycleConverter() {
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 (main) { return ({
13
+ type: 'html',
14
+ component: convert(main)
15
+ }); };
16
+ return { from: from, Extension: Extension };
17
+ }
18
+ exports.createCycleConverter = createCycleConverter;
19
+ var _a = createCycleConverter(), fromCycle = _a.from, CycleExtension = _a.Extension;
11
20
  exports.fromCycle = fromCycle;
12
- exports.createCycleExtension = extension_1.createExtension;
21
+ exports.CycleExtension = CycleExtension;
@@ -1,4 +1,14 @@
1
- import { BaseComponentProps, ForeignComponent } from 'piral-core';
1
+ import type { BaseComponentProps, ForeignComponent } from 'piral-core';
2
2
  import { MatchingMain } from '@cycle/run';
3
- import { PiralDomDrivers } from './types';
4
- export declare function createConverter(): <TProps extends BaseComponentProps, M extends MatchingMain<PiralDomDrivers<TProps>, M>>(main: M) => ForeignComponent<TProps>;
3
+ import type { PiralDomDrivers } from './types';
4
+ export interface CycleConverterOptions {
5
+ /**
6
+ * The tag name of the root element into which a CycleExtension is rendered.
7
+ * @default slot
8
+ */
9
+ rootName?: string;
10
+ }
11
+ export declare function createConverter(config?: CycleConverterOptions): {
12
+ <TProps extends BaseComponentProps, M extends MatchingMain<PiralDomDrivers<TProps>, M>>(main: M): ForeignComponent<TProps>;
13
+ Extension: import("./extension").CycleExtension;
14
+ };
package/esm/converter.js CHANGED
@@ -1,17 +1,19 @@
1
1
  import { makeDOMDriver } from '@cycle/dom';
2
2
  import run from '@cycle/run';
3
3
  import xs from 'xstream';
4
- export function createConverter() {
5
- return (main) => {
4
+ import { createExtension } from './extension';
5
+ export function createConverter(config = {}) {
6
+ const { rootName = 'slot' } = config;
7
+ const Extension = createExtension(rootName);
8
+ const convert = (main) => {
6
9
  let props$ = xs.create();
7
10
  let dispose = () => { };
8
11
  return {
9
- mount(parent, props) {
12
+ mount(el, props) {
10
13
  // The Cycle DOM element is not directly rendered into parent, but into a nested container.
11
14
  // This is done because Cycle "erases" information on the host element. If parent was used,
12
15
  // Piral related properties like data-portal-id could be removed, leading to things not working.
13
- const host = document.createElement('slot');
14
- parent.appendChild(host);
16
+ const host = el.appendChild(document.createElement('slot'));
15
17
  const drivers = {
16
18
  DOM: makeDOMDriver(host),
17
19
  props: () => props$,
@@ -29,5 +31,7 @@ export function createConverter() {
29
31
  },
30
32
  };
31
33
  };
34
+ convert.Extension = Extension;
35
+ return convert;
32
36
  }
33
37
  //# 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,YAAY,CAAC;AAC3C,OAAO,GAA2B,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,MAAM,SAAS,CAAC;AAGzB,MAAM,UAAU,eAAe;IAC7B,OAAO,CACL,IAAO,EACmB,EAAE;QAC5B,IAAI,MAAM,GAAG,EAAE,CAAC,MAAM,EAAU,CAAC;QACjC,IAAI,OAAO,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;QAEvB,OAAO;YACL,KAAK,CAAC,MAAM,EAAE,KAAK;gBACjB,2FAA2F;gBAC3F,2FAA2F;gBAC3F,gGAAgG;gBAChG,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;gBAC5C,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBAEzB,MAAM,OAAO,GAA4B;oBACvC,GAAG,EAAE,aAAa,CAAC,IAAI,CAAC;oBACxB,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM;iBACpB,CAAC;gBAEF,OAAO,GAAG,GAAG,CAAC,IAAY,EAAE,OAAO,CAAC,CAAC;gBACrC,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;YACnC,CAAC;YACD,MAAM,CAAC,CAAC,EAAE,KAAK;gBACb,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;YACnC,CAAC;YACD,OAAO;gBACL,MAAM,CAAC,sBAAsB,EAAE,CAAC;gBAChC,OAAO,EAAE,CAAC;gBACV,MAAM,GAAG,EAAE,CAAC,MAAM,EAAU,CAAC;YAC/B,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
1
+ {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CAAC;IACJ,CAAC,CAAC;IAEF,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 { CycleConverterOptions } from './converter';
2
3
  import type { PiletCycleApi } from './types';
3
4
  /**
4
5
  * Available configuration options for the Cycle.js plugin.
5
6
  */
6
- export interface CycleConfig {
7
- /**
8
- * The tag name of the root element into which a CycleExtension is rendered.
9
- * @default slot
10
- */
11
- rootName?: string;
7
+ export interface CycleConfig extends CycleConverterOptions {
12
8
  }
13
9
  /**
14
10
  * Creates new Pilet API extensions for integration of Cycle.
package/esm/create.js CHANGED
@@ -1,22 +1,20 @@
1
- import { createExtension } from './extension';
2
1
  import { createConverter } from './converter';
3
2
  /**
4
3
  * Creates new Pilet API extensions for integration of Cycle.
5
4
  */
6
5
  export function createCycleApi(config = {}) {
7
- const { rootName } = config;
8
6
  return (context) => {
9
- const convert = createConverter();
7
+ const convert = createConverter(config);
10
8
  context.converters.cycle = ({ root }) => convert(root);
11
- return (api) => ({
9
+ return {
12
10
  fromCycle(root) {
13
11
  return {
14
12
  type: 'cycle',
15
13
  root,
16
14
  };
17
15
  },
18
- CycleExtension: createExtension(api, rootName),
19
- });
16
+ CycleExtension: convert.Extension,
17
+ };
20
18
  };
21
19
  }
22
20
  //# 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;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAc9C;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,SAAsB,EAAE;IACrD,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IAE5B,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,MAAM,OAAO,GAAG,eAAe,EAAE,CAAC;QAClC,OAAO,CAAC,UAAU,CAAC,KAAK,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAEvD,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YACf,SAAS,CAAC,IAAI;gBACZ,OAAO;oBACL,IAAI,EAAE,OAAO;oBACb,IAAI;iBACL,CAAC;YACJ,CAAC;YACD,cAAc,EAAE,eAAe,CAAC,GAAG,EAAE,QAAQ,CAAC;SAC/C,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAyB,MAAM,aAAa,CAAC;AAQrE;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,SAAsB,EAAE;IACrD,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,MAAM,OAAO,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;QACxC,OAAO,CAAC,UAAU,CAAC,KAAK,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAEvD,OAAO;YACL,SAAS,CAAC,IAAI;gBACZ,OAAO;oBACL,IAAI,EAAE,OAAO;oBACb,IAAI;iBACL,CAAC;YACJ,CAAC;YACD,cAAc,EAAE,OAAO,CAAC,SAAS;SAClC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { VNode } from '@cycle/dom';
2
- import type { PiletApi, ExtensionSlotProps } from 'piral-core';
2
+ import type { ExtensionSlotProps } from 'piral-core';
3
3
  export interface CycleExtension {
4
4
  (props: ExtensionSlotProps<unknown>): VNode;
5
5
  }
6
- export declare function createExtension(api: PiletApi, rootName?: string): CycleExtension;
6
+ export declare function createExtension(rootName: string): CycleExtension;
package/esm/extension.js CHANGED
@@ -1,10 +1,16 @@
1
1
  import { h } from '@cycle/dom';
2
- export function createExtension(api, rootName = 'slot') {
2
+ export function createExtension(rootName) {
3
3
  return (props) => h(rootName, {
4
4
  hook: {
5
5
  insert: (vnode) => {
6
6
  if (vnode.elm instanceof HTMLElement) {
7
- api.renderHtmlExtension(vnode.elm, props);
7
+ vnode.elm.dispatchEvent(new CustomEvent('render-html', {
8
+ bubbles: true,
9
+ detail: {
10
+ target: vnode.elm,
11
+ props,
12
+ },
13
+ }));
8
14
  }
9
15
  },
10
16
  },
@@ -1 +1 @@
1
- {"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAS,MAAM,YAAY,CAAC;AAOtC,MAAM,UAAU,eAAe,CAAC,GAAa,EAAE,QAAQ,GAAG,MAAM;IAC9D,OAAO,CAAC,KAAK,EAAE,EAAE,CACf,CAAC,CAAC,QAAQ,EAAE;QACV,IAAI,EAAE;YACJ,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;gBAChB,IAAI,KAAK,CAAC,GAAG,YAAY,WAAW,EAAE;oBACpC,GAAG,CAAC,mBAAmB,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;iBAC3C;YACH,CAAC;SACF;KACF,CAAC,CAAC;AACP,CAAC"}
1
+ {"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAS,MAAM,YAAY,CAAC;AAOtC,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,OAAO,CAAC,KAAK,EAAE,EAAE,CACf,CAAC,CAAC,QAAQ,EAAE;QACV,IAAI,EAAE;YACJ,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;gBAChB,IAAI,KAAK,CAAC,GAAG,YAAY,WAAW,EAAE;oBACpC,KAAK,CAAC,GAAG,CAAC,aAAa,CACrB,IAAI,WAAW,CAAC,aAAa,EAAE;wBAC7B,OAAO,EAAE,IAAI;wBACb,MAAM,EAAE;4BACN,MAAM,EAAE,KAAK,CAAC,GAAG;4BACjB,KAAK;yBACN;qBACF,CAAC,CACH,CAAC;iBACH;YACH,CAAC;SACF;KACF,CAAC,CAAC;AACP,CAAC"}
@@ -1,4 +1,14 @@
1
- import { BaseComponentProps, ForeignComponent } from 'piral-core';
1
+ import type { BaseComponentProps, ForeignComponent } from 'piral-core';
2
2
  import { MatchingMain } from '@cycle/run';
3
- import { PiralDomDrivers } from './types';
4
- export declare function createConverter(): <TProps extends BaseComponentProps, M extends MatchingMain<PiralDomDrivers<TProps>, M>>(main: M) => ForeignComponent<TProps>;
3
+ import type { PiralDomDrivers } from './types';
4
+ export interface CycleConverterOptions {
5
+ /**
6
+ * The tag name of the root element into which a CycleExtension is rendered.
7
+ * @default slot
8
+ */
9
+ rootName?: string;
10
+ }
11
+ export declare function createConverter(config?: CycleConverterOptions): {
12
+ <TProps extends BaseComponentProps, M extends MatchingMain<PiralDomDrivers<TProps>, M>>(main: M): ForeignComponent<TProps>;
13
+ Extension: import("./extension").CycleExtension;
14
+ };
package/lib/converter.js CHANGED
@@ -4,22 +4,24 @@ exports.createConverter = void 0;
4
4
  const dom_1 = require("@cycle/dom");
5
5
  const run_1 = require("@cycle/run");
6
6
  const xstream_1 = require("xstream");
7
- function createConverter() {
8
- return (main) => {
7
+ const extension_1 = require("./extension");
8
+ function createConverter(config = {}) {
9
+ const { rootName = 'slot' } = config;
10
+ const Extension = (0, extension_1.createExtension)(rootName);
11
+ const convert = (main) => {
9
12
  let props$ = xstream_1.default.create();
10
13
  let dispose = () => { };
11
14
  return {
12
- mount(parent, props) {
15
+ mount(el, props) {
13
16
  // The Cycle DOM element is not directly rendered into parent, but into a nested container.
14
17
  // This is done because Cycle "erases" information on the host element. If parent was used,
15
18
  // Piral related properties like data-portal-id could be removed, leading to things not working.
16
- const host = document.createElement('slot');
17
- parent.appendChild(host);
19
+ const host = el.appendChild(document.createElement('slot'));
18
20
  const drivers = {
19
- DOM: dom_1.makeDOMDriver(host),
21
+ DOM: (0, dom_1.makeDOMDriver)(host),
20
22
  props: () => props$,
21
23
  };
22
- dispose = run_1.default(main, drivers);
24
+ dispose = (0, run_1.default)(main, drivers);
23
25
  props$.shamefullySendNext(props);
24
26
  },
25
27
  update(_, props) {
@@ -32,6 +34,8 @@ function createConverter() {
32
34
  },
33
35
  };
34
36
  };
37
+ convert.Extension = Extension;
38
+ return convert;
35
39
  }
36
40
  exports.createConverter = createConverter;
37
41
  //# sourceMappingURL=converter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":";;;AACA,oCAA2C;AAC3C,oCAAqD;AACrD,qCAAyB;AAGzB,SAAgB,eAAe;IAC7B,OAAO,CACL,IAAO,EACmB,EAAE;QAC5B,IAAI,MAAM,GAAG,iBAAE,CAAC,MAAM,EAAU,CAAC;QACjC,IAAI,OAAO,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;QAEvB,OAAO;YACL,KAAK,CAAC,MAAM,EAAE,KAAK;gBACjB,2FAA2F;gBAC3F,2FAA2F;gBAC3F,gGAAgG;gBAChG,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;gBAC5C,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBAEzB,MAAM,OAAO,GAA4B;oBACvC,GAAG,EAAE,mBAAa,CAAC,IAAI,CAAC;oBACxB,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM;iBACpB,CAAC;gBAEF,OAAO,GAAG,aAAG,CAAC,IAAY,EAAE,OAAO,CAAC,CAAC;gBACrC,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;YACnC,CAAC;YACD,MAAM,CAAC,CAAC,EAAE,KAAK;gBACb,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;YACnC,CAAC;YACD,OAAO;gBACL,MAAM,CA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OAAO,EAAE,CAAC;gBACV,MAAM,GAAG,iBAAE,CAAC,MAAM,EAAU,CAAC;YAC/B,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC;AArCD,0CAqCC"}
package/lib/create.d.ts CHANGED
@@ -1,14 +1,10 @@
1
1
  import type { PiralPlugin } from 'piral-core';
2
+ import { CycleConverterOptions } from './converter';
2
3
  import type { PiletCycleApi } from './types';
3
4
  /**
4
5
  * Available configuration options for the Cycle.js plugin.
5
6
  */
6
- export interface CycleConfig {
7
- /**
8
- * The tag name of the root element into which a CycleExtension is rendered.
9
- * @default slot
10
- */
11
- rootName?: string;
7
+ export interface CycleConfig extends CycleConverterOptions {
12
8
  }
13
9
  /**
14
10
  * Creates new Pilet API extensions for integration of Cycle.
package/lib/create.js CHANGED
@@ -1,25 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createCycleApi = void 0;
4
- const extension_1 = require("./extension");
5
4
  const converter_1 = require("./converter");
6
5
  /**
7
6
  * Creates new Pilet API extensions for integration of Cycle.
8
7
  */
9
8
  function createCycleApi(config = {}) {
10
- const { rootName } = config;
11
9
  return (context) => {
12
- const convert = converter_1.createConverter();
10
+ const convert = (0, converter_1.createConverter)(config);
13
11
  context.converters.cycle = ({ root }) => convert(root);
14
- return (api) => ({
12
+ return {
15
13
  fromCycle(root) {
16
14
  return {
17
15
  type: 'cycle',
18
16
  root,
19
17
  };
20
18
  },
21
- CycleExtension: extension_1.createExtension(api, rootName),
22
- });
19
+ CycleExtension: convert.Extension,
20
+ };
23
21
  };
24
22
  }
25
23
  exports.createCycleApi = createCycleApi;
package/lib/create.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":";;;AACA,2CAA8C;AAC9C,2CAA8C;AAc9C;;GAEG;AACH,SAAgB,cAAc,CAAC,SAAsB,EAAE;IACrD,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IAE5B,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,MAAM,OAAO,GAAG,2BAAe,EAAE,CAAC;QAClC,OAAO,CAAC,UAAU,CAAC,KAAK,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAEvD,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YACf,SAAS,CAAC,IAAI;gBACZ,OAAO;oBACL,IAAI,EAAE,OAAO;oBACb,IAAI;iBACL,CAAC;YACJ,CAAC;YACD,cAAc,EAAE,2BAAe,CAAC,GAAG,EAAE,QAAQ,CAAC;SAC/C,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAjBD,wCAiBC"}
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":";;;AACA,2CAAqE;AAQrE;;GAEG;AACH,SAAgB,cAAc,CAAC,SAAsB,EAAE;IACrD,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,MAAM,OAAO,GAAG,IAAA,2BAAe,EAAC,MAAM,CAAC,CAAC;QACxC,OAAO,CAAC,UAAU,CAAC,KAAK,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAEvD,OAAO;YACL,SAAS,CAAC,IAAI;gBACZ,OAAO;oBACL,IAAI,EAAE,OAAO;oBACb,IAAI;iBACL,CAAC;YACJ,CAAC;YACD,cAAc,EAAE,OAAO,CAAC,SAAS;SAClC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAfD,wCAeC"}
@@ -1,6 +1,6 @@
1
1
  import { VNode } from '@cycle/dom';
2
- import type { PiletApi, ExtensionSlotProps } from 'piral-core';
2
+ import type { ExtensionSlotProps } from 'piral-core';
3
3
  export interface CycleExtension {
4
4
  (props: ExtensionSlotProps<unknown>): VNode;
5
5
  }
6
- export declare function createExtension(api: PiletApi, rootName?: string): CycleExtension;
6
+ export declare function createExtension(rootName: string): CycleExtension;
package/lib/extension.js CHANGED
@@ -2,12 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createExtension = void 0;
4
4
  const dom_1 = require("@cycle/dom");
5
- function createExtension(api, rootName = 'slot') {
6
- return (props) => dom_1.h(rootName, {
5
+ function createExtension(rootName) {
6
+ return (props) => (0, dom_1.h)(rootName, {
7
7
  hook: {
8
8
  insert: (vnode) => {
9
9
  if (vnode.elm instanceof HTMLElement) {
10
- api.renderHtmlExtension(vnode.elm, props);
10
+ vnode.elm.dispatchEvent(new CustomEvent('render-html', {
11
+ bubbles: true,
12
+ detail: {
13
+ target: vnode.elm,
14
+ props,
15
+ },
16
+ }));
11
17
  }
12
18
  },
13
19
  },
@@ -1 +1 @@
1
- {"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":";;;AAAA,oCAAsC;AAOtC,SAAgB,eAAe,CAAC,GAAa,EAAE,QAAQ,GAAG,MAAM;IAC9D,OAAO,CAAC,KAAK,EAAE,EAAE,CACf,OAAC,CAAC,QAAQ,EAAE;QACV,IAAI,EAAE;YACJ,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;gBAChB,IAAI,KAAK,CAAC,GAAG,YAAY,WAAW,EAAE;oBACpC,GAAG,CAAC,mBAAmB,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;iBAC3C;YACH,CAAC;SACF;KACF,CAAC,CAAC;AACP,CAAC;AAXD,0CAWC"}
1
+ {"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":";;;AAAA,oCAAsC;AAOtC,SAAgB,eAAe,CAAC,QAAgB;IAC9C,OAAO,CAAC,KAAK,EAAE,EAAE,CACf,IAAA,OAAC,EAAC,QAAQ,EAAE;QACV,IAAI,EAAE;YACJ,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;gBAChB,IAAI,KAAK,CAAC,GAAG,YAAY,WAAW,EAAE;oBACpC,KAAK,CAAC,GAAG,CAAC,aAAa,CACrB,IAAI,WAAW,CAAC,aAAa,EAAE;wBAC7B,OAAO,EAAE,IAAI;wBACb,MAAM,EAAE;4BACN,MAAM,EAAE,KAAK,CAAC,GAAG;4BACjB,KAAK;yBACN;qBACF,CAAC,CACH,CAAC;iBACH;YACH,CAAC;SACF;KACF,CAAC,CAAC;AACP,CAAC;AAnBD,0CAmBC"}
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./create"), exports);
5
- tslib_1.__exportStar(require("./types"), exports);
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piral-cycle",
3
- "version": "0.13.9",
3
+ "version": "0.14.0-alpha.3152",
4
4
  "description": "Plugin for integrating Cycle.js components in Piral.",
5
5
  "keywords": [
6
6
  "piral",
@@ -45,14 +45,14 @@
45
45
  "devDependencies": {
46
46
  "@cycle/dom": "^22.7.0",
47
47
  "@cycle/run": "^5.4.0",
48
- "piral-core": "^0.13.9",
48
+ "piral-core": "^0.14.0-alpha.3152",
49
49
  "xstream": "^11.12.0"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "@cycle/dom": "^22.0.0",
53
53
  "@cycle/run": "^5.0.0",
54
- "piral-core": "0.13.x",
54
+ "piral-core": "0.14.x",
55
55
  "xstream": "^11.0.0"
56
56
  },
57
- "gitHead": "80de9fb69430283bc90f380d3254e0e6aad4c6ad"
57
+ "gitHead": "4ad88a8b8bcdee17f22e7e1e2e8feb41df6210e5"
58
58
  }
package/src/converter.ts CHANGED
@@ -1,23 +1,33 @@
1
- import { BaseComponentProps, ForeignComponent } from 'piral-core';
1
+ import type { BaseComponentProps, ForeignComponent } from 'piral-core';
2
2
  import { makeDOMDriver } from '@cycle/dom';
3
3
  import run, { MatchingMain, Main } from '@cycle/run';
4
4
  import xs from 'xstream';
5
- import { PiralDomDrivers } from './types';
5
+ import { createExtension } from './extension';
6
+ import type { PiralDomDrivers } from './types';
6
7
 
7
- export function createConverter() {
8
- return <TProps extends BaseComponentProps, M extends MatchingMain<PiralDomDrivers<TProps>, M>>(
8
+ export interface CycleConverterOptions {
9
+ /**
10
+ * The tag name of the root element into which a CycleExtension is rendered.
11
+ * @default slot
12
+ */
13
+ rootName?: string;
14
+ }
15
+
16
+ export function createConverter(config: CycleConverterOptions = {}) {
17
+ const { rootName = 'slot' } = config;
18
+ const Extension = createExtension(rootName);
19
+ const convert = <TProps extends BaseComponentProps, M extends MatchingMain<PiralDomDrivers<TProps>, M>>(
9
20
  main: M,
10
21
  ): ForeignComponent<TProps> => {
11
22
  let props$ = xs.create<TProps>();
12
23
  let dispose = () => {};
13
24
 
14
25
  return {
15
- mount(parent, props) {
26
+ mount(el, props) {
16
27
  // The Cycle DOM element is not directly rendered into parent, but into a nested container.
17
28
  // This is done because Cycle "erases" information on the host element. If parent was used,
18
29
  // Piral related properties like data-portal-id could be removed, leading to things not working.
19
- const host = document.createElement('slot');
20
- parent.appendChild(host);
30
+ const host = el.appendChild(document.createElement('slot'));
21
31
 
22
32
  const drivers: PiralDomDrivers<TProps> = {
23
33
  DOM: makeDOMDriver(host),
@@ -37,4 +47,7 @@ export function createConverter() {
37
47
  },
38
48
  };
39
49
  };
50
+
51
+ convert.Extension = Extension;
52
+ return convert;
40
53
  }
package/src/create.ts CHANGED
@@ -1,37 +1,28 @@
1
1
  import type { PiralPlugin } from 'piral-core';
2
- import { createExtension } from './extension';
3
- import { createConverter } from './converter';
2
+ import { createConverter, CycleConverterOptions } from './converter';
4
3
  import type { PiletCycleApi } from './types';
5
4
 
6
5
  /**
7
6
  * Available configuration options for the Cycle.js plugin.
8
7
  */
9
- export interface CycleConfig {
10
- /**
11
- * The tag name of the root element into which a CycleExtension is rendered.
12
- * @default slot
13
- */
14
- rootName?: string;
15
- }
8
+ export interface CycleConfig extends CycleConverterOptions {}
16
9
 
17
10
  /**
18
11
  * Creates new Pilet API extensions for integration of Cycle.
19
12
  */
20
13
  export function createCycleApi(config: CycleConfig = {}): PiralPlugin<PiletCycleApi> {
21
- const { rootName } = config;
22
-
23
14
  return (context) => {
24
- const convert = createConverter();
15
+ const convert = createConverter(config);
25
16
  context.converters.cycle = ({ root }) => convert(root);
26
17
 
27
- return (api) => ({
18
+ return {
28
19
  fromCycle(root) {
29
20
  return {
30
21
  type: 'cycle',
31
22
  root,
32
23
  };
33
24
  },
34
- CycleExtension: createExtension(api, rootName),
35
- });
25
+ CycleExtension: convert.Extension,
26
+ };
36
27
  };
37
28
  }
package/src/extension.ts CHANGED
@@ -1,17 +1,25 @@
1
1
  import { h, VNode } from '@cycle/dom';
2
- import type { PiletApi, ExtensionSlotProps } from 'piral-core';
2
+ import type { ExtensionSlotProps } from 'piral-core';
3
3
 
4
4
  export interface CycleExtension {
5
5
  (props: ExtensionSlotProps<unknown>): VNode;
6
6
  }
7
7
 
8
- export function createExtension(api: PiletApi, rootName = 'slot'): CycleExtension {
8
+ export function createExtension(rootName: string): CycleExtension {
9
9
  return (props) =>
10
10
  h(rootName, {
11
11
  hook: {
12
12
  insert: (vnode) => {
13
13
  if (vnode.elm instanceof HTMLElement) {
14
- api.renderHtmlExtension(vnode.elm, props);
14
+ vnode.elm.dispatchEvent(
15
+ new CustomEvent('render-html', {
16
+ bubbles: true,
17
+ detail: {
18
+ target: vnode.elm,
19
+ props,
20
+ },
21
+ }),
22
+ );
15
23
  }
16
24
  },
17
25
  },