piral-cycle 0.14.16 → 0.14.17-beta.3882

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/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":["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,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/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;IAChE,MAAM,EAAE,QAAQ,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC;IACrC,MAAM,SAAS,GAAG,IAAA,2BAAe,EAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,CACd,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,EAAE,EAAE,KAAK;gBACb,2FAA2F;gBAC3F,2FAA2F;gBAC3F,gGAAgG;gBAChG,MAAM,IAAI,GAAG,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;gBAE5D,MAAM,OAAO,GAA4B;oBACvC,GAAG,EAAE,IAAA,mBAAa,EAAC,IAAI,CAAC;oBACxB,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM;iBACpB,CAAC;gBAEF,OAAO,GAAG,IAAA,aAAG,EAAC,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,C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AkB,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;AAlCD,0CAkCC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piral-cycle",
3
- "version": "0.14.16",
3
+ "version": "0.14.17-beta.3882",
4
4
  "description": "Plugin for integrating Cycle.js components in Piral.",
5
5
  "keywords": [
6
6
  "piral",
@@ -45,7 +45,7 @@
45
45
  "devDependencies": {
46
46
  "@cycle/dom": "^22.7.0",
47
47
  "@cycle/run": "^5.4.0",
48
- "piral-core": "^0.14.16",
48
+ "piral-core": "0.14.17-beta.3882",
49
49
  "xstream": "^11.12.0"
50
50
  },
51
51
  "peerDependencies": {
@@ -54,5 +54,5 @@
54
54
  "piral-core": "0.14.x",
55
55
  "xstream": "^11.0.0"
56
56
  },
57
- "gitHead": "39ec6f4eb7b46a14530cb845371bf9e294be0171"
57
+ "gitHead": "baa86e46163bdf6ea51d84414a6fe64a913517c7"
58
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;