piral-cycle 0.15.0-alpha.3816 → 0.15.0-alpha.3905

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # [Piral Cycle](https://piral.io) · [![GitHub License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/smapiot/piral/blob/main/LICENSE) [![npm version](https://img.shields.io/npm/v/piral-cycle.svg?style=flat)](https://www.npmjs.com/package/piral-cycle) [![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://jestjs.io) [![Gitter Chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/piral-io/community)
4
4
 
5
- This is a plugin that only has a peer dependency to `piral-core`. What `piral-cycle` brings to the table is a set of Pilet API extensions that can be used with `piral` or `piral-core`.
5
+ This is a plugin that only has a peer dependency to `@cycle/dom` and related packages. What `piral-cycle` brings to the table is a set of Pilet API extensions that can be used with `piral` or `piral-core`.
6
6
 
7
7
  The set includes a Cycle.js converter for any component registration, as well as a `fromCycle` shortcut and a `CycleExtension` component.
8
8
 
package/esm/converter.js CHANGED
@@ -5,32 +5,29 @@ import { createExtension } from './extension';
5
5
  export function createConverter(config = {}) {
6
6
  const { rootName = 'slot' } = config;
7
7
  const Extension = createExtension(rootName);
8
- const convert = (main) => {
9
- let props$ = xs.create();
10
- let dispose = () => { };
11
- return {
12
- mount(el, props) {
13
- // The Cycle DOM element is not directly rendered into parent, but into a nested container.
14
- // This is done because Cycle "erases" information on the host element. If parent was used,
15
- // Piral related properties like data-portal-id could be removed, leading to things not working.
16
- const host = el.appendChild(document.createElement('slot'));
17
- const drivers = {
18
- DOM: makeDOMDriver(host),
19
- props: () => props$,
20
- };
21
- dispose = run(main, drivers);
22
- props$.shamefullySendNext(props);
23
- },
24
- update(_, props) {
25
- props$.shamefullySendNext(props);
26
- },
27
- unmount() {
28
- props$.shamefullySendComplete();
29
- dispose();
30
- props$ = xs.create();
31
- },
32
- };
33
- };
8
+ const convert = (main) => ({
9
+ mount(el, props, ctx, locals) {
10
+ locals.props$ = xs.create();
11
+ // The Cycle DOM element is not directly rendered into parent, but into a nested container.
12
+ // This is done because Cycle "erases" information on the host element. If parent was used,
13
+ // Piral related properties like data-portal-id could be removed, leading to things not working.
14
+ const host = el.appendChild(document.createElement('slot'));
15
+ const drivers = {
16
+ DOM: makeDOMDriver(host),
17
+ props: () => locals.props$,
18
+ };
19
+ locals.dispose = run(main, drivers);
20
+ locals.props$.shamefullySendNext(props);
21
+ },
22
+ update(el, props, ctx, locals) {
23
+ locals.props$.shamefullySendNext(props);
24
+ },
25
+ unmount(el, locals) {
26
+ locals.props$.shamefullySendComplete();
27
+ locals.dispose();
28
+ locals.props$ = undefined;
29
+ },
30
+ });
34
31
  convert.Extension = Extension;
35
32
  return convert;
36
33
  }
@@ -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;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAW9C,MAAM,UAAU,eAAe,CAAC,SAAgC,EAAE;IAChE,MAAM,EAAE,QAAQ,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC;IACrC,MAAM,SAAS,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,CACd,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,EAAE,EAAE,KAAK;gBACb,2FAA2F;gBAC3F,2FAA2F;gBAC3F,gGAAgG;gBAChG,MAAM,IAAI,GAAG,EAAE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,EAAU,CAAC;YAEpC,2FAA2F;YAC3F,2FAA2F;YAC3F,gGAAgG;YAChG,MAAM,IAAI,GAAG,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;YAE5D,MAAM,OAAO,GAA4B;gBACvC,GAAG,EAAE,aAAa,CAAC,IAAI,CAAC;gBACxB,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM;aAC3B,CAAC;YAEF,MAAM,CAAC,OAAO,GAAG,GAAG,CAAC,IAAY,EAAE,OAAO,CAAC,CAAC;YAC5C,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAC1C,CAAC;QACD,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAA0B;YAC/C,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAC1C,CAAC;QACD,OAAO,CAAC,EAAE,EAAE,MAA0B;YACpC,MAAM,CAAC,MAAM,CAAC,sBAAsB,EAAE,CAAC;YACvC,MAAM,CAAC,OAAO,EAAE,CAAC;YACjB,MAAM,CAAC,MAAM,GAAG,SAAS,CAAC;QAC5B,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC"}
package/esm/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Stream } from 'xstream';
2
2
  import { Driver, Drivers, MatchingMain, Main } from '@cycle/run';
3
3
  import { MainDOMSource, VNode } from '@cycle/dom';
4
- import { ForeignComponent, ExtensionSlotProps } from 'piral-core';
4
+ import type { ForeignComponent, ExtensionSlotProps } from 'piral-core';
5
5
  declare module 'piral-core/lib/types/custom' {
6
6
  interface PiletCustomApi extends PiletCycleApi {
7
7
  }
package/lib/converter.js CHANGED
@@ -8,32 +8,29 @@ const extension_1 = require("./extension");
8
8
  function createConverter(config = {}) {
9
9
  const { rootName = 'slot' } = config;
10
10
  const Extension = (0, extension_1.createExtension)(rootName);
11
- const convert = (main) => {
12
- let props$ = xstream_1.default.create();
13
- let dispose = () => { };
14
- return {
15
- mount(el, props) {
16
- // The Cycle DOM element is not directly rendered into parent, but into a nested container.
17
- // This is done because Cycle "erases" information on the host element. If parent was used,
18
- // Piral related properties like data-portal-id could be removed, leading to things not working.
19
- const host = el.appendChild(document.createElement('slot'));
20
- const drivers = {
21
- DOM: (0, dom_1.makeDOMDriver)(host),
22
- props: () => props$,
23
- };
24
- dispose = (0, run_1.default)(main, drivers);
25
- props$.shamefullySendNext(props);
26
- },
27
- update(_, props) {
28
- props$.shamefullySendNext(props);
29
- },
30
- unmount() {
31
- props$.shamefullySendComplete();
32
- dispose();
33
- props$ = xstream_1.default.create();
34
- },
35
- };
36
- };
11
+ const convert = (main) => ({
12
+ mount(el, props, ctx, locals) {
13
+ locals.props$ = xstream_1.default.create();
14
+ // The Cycle DOM element is not directly rendered into parent, but into a nested container.
15
+ // This is done because Cycle "erases" information on the host element. If parent was used,
16
+ // Piral related properties like data-portal-id could be removed, leading to things not working.
17
+ const host = el.appendChild(document.createElement('slot'));
18
+ const drivers = {
19
+ DOM: (0, dom_1.makeDOMDriver)(host),
20
+ props: () => locals.props$,
21
+ };
22
+ locals.dispose = (0, run_1.default)(main, drivers);
23
+ locals.props$.shamefullySendNext(props);
24
+ },
25
+ update(el, props, ctx, locals) {
26
+ locals.props$.shamefullySendNext(props);
27
+ },
28
+ unmount(el, locals) {
29
+ locals.props$.shamefullySendComplete();
30
+ locals.dispose();
31
+ locals.props$ = undefined;
32
+ },
33
+ });
37
34
  convert.Extension = Extension;
38
35
  return convert;
39
36
  }
@@ -1 +1 @@
1
- {"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":";;;AACA,oCAA2C;AAC3C,oCAAqD;AACrD,qCAAyB;AACzB,2CAA8C;AAW9C,SAAgB,eAAe,CAAC,SAAgC,EAAE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ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Stream } from 'xstream';
2
2
  import { Driver, Drivers, MatchingMain, Main } from '@cycle/run';
3
3
  import { MainDOMSource, VNode } from '@cycle/dom';
4
- import { ForeignComponent, ExtensionSlotProps } from 'piral-core';
4
+ import type { ForeignComponent, ExtensionSlotProps } from 'piral-core';
5
5
  declare module 'piral-core/lib/types/custom' {
6
6
  interface PiletCustomApi extends PiletCycleApi {
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piral-cycle",
3
- "version": "0.15.0-alpha.3816",
3
+ "version": "0.15.0-alpha.3905",
4
4
  "description": "Plugin for integrating Cycle.js components in Piral.",
5
5
  "keywords": [
6
6
  "piral",
@@ -46,14 +46,13 @@
46
46
  "devDependencies": {
47
47
  "@cycle/dom": "^22.7.0",
48
48
  "@cycle/run": "^5.4.0",
49
- "piral-core": "0.15.0-alpha.3816",
49
+ "piral-core": "0.15.0-alpha.3905",
50
50
  "xstream": "^11.12.0"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "@cycle/dom": "^22.0.0",
54
54
  "@cycle/run": "^5.0.0",
55
- "piral-core": "0.14.x",
56
55
  "xstream": "^11.0.0"
57
56
  },
58
- "gitHead": "cfd7ed44c6b73655be56587aeaf774692e0c94ad"
57
+ "gitHead": "533d09963cfd8c901df797958ca386dbae0286e1"
59
58
  }
package/src/converter.ts CHANGED
@@ -1,7 +1,7 @@
1
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
- import xs from 'xstream';
4
+ import xs, { Stream } from 'xstream';
5
5
  import { createExtension } from './extension';
6
6
  import type { PiralDomDrivers } from './types';
7
7
 
@@ -13,40 +13,42 @@ export interface CycleConverterOptions {
13
13
  rootName?: string;
14
14
  }
15
15
 
16
+ interface CycleState<TProps> {
17
+ props$: Stream<TProps>;
18
+ dispose(): void;
19
+ }
20
+
16
21
  export function createConverter(config: CycleConverterOptions = {}) {
17
22
  const { rootName = 'slot' } = config;
18
23
  const Extension = createExtension(rootName);
19
24
  const convert = <TProps extends BaseComponentProps, M extends MatchingMain<PiralDomDrivers<TProps>, M>>(
20
25
  main: M,
21
- ): ForeignComponent<TProps> => {
22
- let props$ = xs.create<TProps>();
23
- let dispose = () => {};
26
+ ): ForeignComponent<TProps> => ({
27
+ mount(el, props, ctx, locals: CycleState<TProps>) {
28
+ locals.props$ = xs.create<TProps>();
24
29
 
25
- return {
26
- mount(el, props) {
27
- // The Cycle DOM element is not directly rendered into parent, but into a nested container.
28
- // This is done because Cycle "erases" information on the host element. If parent was used,
29
- // Piral related properties like data-portal-id could be removed, leading to things not working.
30
- const host = el.appendChild(document.createElement('slot'));
30
+ // The Cycle DOM element is not directly rendered into parent, but into a nested container.
31
+ // This is done because Cycle "erases" information on the host element. If parent was used,
32
+ // Piral related properties like data-portal-id could be removed, leading to things not working.
33
+ const host = el.appendChild(document.createElement('slot'));
31
34
 
32
- const drivers: PiralDomDrivers<TProps> = {
33
- DOM: makeDOMDriver(host),
34
- props: () => props$,
35
- };
35
+ const drivers: PiralDomDrivers<TProps> = {
36
+ DOM: makeDOMDriver(host),
37
+ props: () => locals.props$,
38
+ };
36
39
 
37
- dispose = run(main as Main, drivers);
38
- props$.shamefullySendNext(props);
39
- },
40
- update(_, props) {
41
- props$.shamefullySendNext(props);
42
- },
43
- unmount() {
44
- props$.shamefullySendComplete();
45
- dispose();
46
- props$ = xs.create<TProps>();
47
- },
48
- };
49
- };
40
+ locals.dispose = run(main as Main, drivers);
41
+ locals.props$.shamefullySendNext(props);
42
+ },
43
+ update(el, props, ctx, locals: CycleState<TProps>) {
44
+ locals.props$.shamefullySendNext(props);
45
+ },
46
+ unmount(el, locals: CycleState<TProps>) {
47
+ locals.props$.shamefullySendComplete();
48
+ locals.dispose();
49
+ locals.props$ = undefined;
50
+ },
51
+ });
50
52
 
51
53
  convert.Extension = Extension;
52
54
  return convert;
package/src/types.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Stream } from 'xstream';
2
2
  import { Driver, Drivers, MatchingMain, Main } from '@cycle/run';
3
3
  import { MainDOMSource, VNode } from '@cycle/dom';
4
- import { ForeignComponent, ExtensionSlotProps } from 'piral-core';
4
+ import type { ForeignComponent, ExtensionSlotProps } from 'piral-core';
5
5
 
6
6
  declare module 'piral-core/lib/types/custom' {
7
7
  interface PiletCustomApi extends PiletCycleApi {}