@plaidev/karte-action-sdk 1.1.103 → 1.1.104-27910631.850a8338

Sign up to get free protection for your applications and to get access to all the features.
@@ -765,30 +765,6 @@ interface ActionOptions<Props, Variables> {
765
765
  * @default () => {}
766
766
  */
767
767
  onCreate?: (props: ActionProps<Props, Variables & CustomVariables>) => void | Promise<void>;
768
- /**
769
- * {@link onShow} function to hook the phase of showing action in KARTE action.
770
- *
771
- * @default () => {}
772
- */
773
- onShow?: (props: ActionProps<Props, Variables & CustomVariables>) => void | Promise<void>;
774
- /**
775
- * {@link onClose} function to hook the phase of closing action in KARTE action.
776
- *
777
- * @default () => {}
778
- */
779
- onClose?: (props: ActionProps<Props, Variables & CustomVariables>, trigger: CloseTrigger) => void | Promise<void>;
780
- /**
781
- * {@link onChangeState} function to hook the phase of changing action state in KARTE action.
782
- *
783
- * @default () => {}
784
- */
785
- onChangeState?: (props: ActionProps<Props, Variables & CustomVariables>, newState: string) => void | Promise<void>;
786
- /**
787
- * {@link onDestory} function to hook the phase of destroying action state in KARTE action.
788
- *
789
- * @default () => {}
790
- */
791
- onDestory?: (props: ActionProps<Props, Variables & CustomVariables>) => void | Promise<void>;
792
768
  }
793
769
  /**
794
770
  * Create the KARTE action
@@ -1596,30 +1572,6 @@ declare namespace widget {
1596
1572
  * @default () => {}
1597
1573
  */
1598
1574
  onCreate?: (props: ActionProps<Props, Variables & CustomVariables>) => void | Promise<void>;
1599
- /**
1600
- * {@link onShow} function to hook the phase of showing action in KARTE action.
1601
- *
1602
- * @default () => {}
1603
- */
1604
- onShow?: (props: ActionProps<Props, Variables & CustomVariables>) => void | Promise<void>;
1605
- /**
1606
- * {@link onClose} function to hook the phase of closing action in KARTE action.
1607
- *
1608
- * @default () => {}
1609
- */
1610
- onClose?: (props: ActionProps<Props, Variables & CustomVariables>, trigger: CloseTrigger) => void | Promise<void>;
1611
- /**
1612
- * {@link onChangeState} function to hook the phase of changing action state in KARTE action.
1613
- *
1614
- * @default () => {}
1615
- */
1616
- onChangeState?: (props: ActionProps<Props, Variables & CustomVariables>, newState: string) => void | Promise<void>;
1617
- /**
1618
- * {@link onDestory} function to hook the phase of destroying action state in KARTE action.
1619
- *
1620
- * @default () => {}
1621
- */
1622
- onDestory?: (props: ActionProps<Props, Variables & CustomVariables>) => void | Promise<void>;
1623
1575
  }
1624
1576
  /**
1625
1577
  * Create the KARTE action
@@ -364,7 +364,7 @@ function updateInternalHandlers(handlers) {
364
364
  internalHandlers.update(current => {
365
365
  return { ...current, ...handlers };
366
366
  });
367
- return getCustomVariables();
367
+ return getInternalHandlers();
368
368
  }
369
369
  /**
370
370
  * Store to handle custom event handlers
@@ -863,6 +863,7 @@ function create(App, options = {
863
863
  ...getCustomVariables(),
864
864
  };
865
865
  const actionProps = { send: options.send, data };
866
+ initialize({ send: options.send });
866
867
  // NOTE: onCreateより前にListenする必要がある
867
868
  window.addEventListener(ACTION_DESTROY_EVENT, () => {
868
869
  const { onDestroyHandlers } = getInternalHandlers();
@@ -877,22 +878,6 @@ function create(App, options = {
877
878
  shortenId: data.shorten_id || null,
878
879
  campaignId: data.campaign_id || null,
879
880
  });
880
- setInternalHandlers({});
881
- if (options.onCreate) {
882
- onCreate(options.onCreate);
883
- }
884
- if (options.onShow) {
885
- onShow(options.onShow);
886
- }
887
- if (options.onClose) {
888
- onClose(options.onClose);
889
- }
890
- if (options.onChangeState) {
891
- onChangeState(options.onChangeState);
892
- }
893
- if (options.onDestory) {
894
- onDestroy(options.onDestory);
895
- }
896
881
  const close = (trigger = 'none') => {
897
882
  if (!app) {
898
883
  return;
@@ -905,6 +890,7 @@ function create(App, options = {
905
890
  if (onCloseHandlers) {
906
891
  onCloseHandlers.forEach(h => h({ send: options.send, data }, trigger));
907
892
  }
893
+ finalize();
908
894
  app.$destroy();
909
895
  app = null;
910
896
  };
@@ -963,6 +949,9 @@ function create(App, options = {
963
949
  }
964
950
  return cleanup;
965
951
  };
952
+ if (options.onCreate) {
953
+ options.onCreate(actionProps);
954
+ }
966
955
  const { onCreateHandlers } = getInternalHandlers();
967
956
  if (onCreateHandlers) {
968
957
  onCreateHandlers.forEach(h => h({ send: options.send, data }));
@@ -765,30 +765,6 @@ interface ActionOptions<Props, Variables> {
765
765
  * @default () => {}
766
766
  */
767
767
  onCreate?: (props: ActionProps<Props, Variables & CustomVariables>) => void | Promise<void>;
768
- /**
769
- * {@link onShow} function to hook the phase of showing action in KARTE action.
770
- *
771
- * @default () => {}
772
- */
773
- onShow?: (props: ActionProps<Props, Variables & CustomVariables>) => void | Promise<void>;
774
- /**
775
- * {@link onClose} function to hook the phase of closing action in KARTE action.
776
- *
777
- * @default () => {}
778
- */
779
- onClose?: (props: ActionProps<Props, Variables & CustomVariables>, trigger: CloseTrigger) => void | Promise<void>;
780
- /**
781
- * {@link onChangeState} function to hook the phase of changing action state in KARTE action.
782
- *
783
- * @default () => {}
784
- */
785
- onChangeState?: (props: ActionProps<Props, Variables & CustomVariables>, newState: string) => void | Promise<void>;
786
- /**
787
- * {@link onDestory} function to hook the phase of destroying action state in KARTE action.
788
- *
789
- * @default () => {}
790
- */
791
- onDestory?: (props: ActionProps<Props, Variables & CustomVariables>) => void | Promise<void>;
792
768
  }
793
769
  /**
794
770
  * Create the KARTE action
@@ -1596,30 +1572,6 @@ declare namespace widget {
1596
1572
  * @default () => {}
1597
1573
  */
1598
1574
  onCreate?: (props: ActionProps<Props, Variables & CustomVariables>) => void | Promise<void>;
1599
- /**
1600
- * {@link onShow} function to hook the phase of showing action in KARTE action.
1601
- *
1602
- * @default () => {}
1603
- */
1604
- onShow?: (props: ActionProps<Props, Variables & CustomVariables>) => void | Promise<void>;
1605
- /**
1606
- * {@link onClose} function to hook the phase of closing action in KARTE action.
1607
- *
1608
- * @default () => {}
1609
- */
1610
- onClose?: (props: ActionProps<Props, Variables & CustomVariables>, trigger: CloseTrigger) => void | Promise<void>;
1611
- /**
1612
- * {@link onChangeState} function to hook the phase of changing action state in KARTE action.
1613
- *
1614
- * @default () => {}
1615
- */
1616
- onChangeState?: (props: ActionProps<Props, Variables & CustomVariables>, newState: string) => void | Promise<void>;
1617
- /**
1618
- * {@link onDestory} function to hook the phase of destroying action state in KARTE action.
1619
- *
1620
- * @default () => {}
1621
- */
1622
- onDestory?: (props: ActionProps<Props, Variables & CustomVariables>) => void | Promise<void>;
1623
1575
  }
1624
1576
  /**
1625
1577
  * Create the KARTE action
package/dist/index.es.js CHANGED
@@ -364,7 +364,7 @@ function updateInternalHandlers(handlers) {
364
364
  internalHandlers.update(current => {
365
365
  return { ...current, ...handlers };
366
366
  });
367
- return getCustomVariables();
367
+ return getInternalHandlers();
368
368
  }
369
369
  /**
370
370
  * Store to handle custom event handlers
@@ -965,6 +965,7 @@ function create(App, options = {
965
965
  ...getCustomVariables(),
966
966
  };
967
967
  const actionProps = { send: options.send, data };
968
+ initialize({ send: options.send });
968
969
  // NOTE: onCreateより前にListenする必要がある
969
970
  window.addEventListener(ACTION_DESTROY_EVENT, () => {
970
971
  const { onDestroyHandlers } = getInternalHandlers();
@@ -979,22 +980,6 @@ function create(App, options = {
979
980
  shortenId: data.shorten_id || null,
980
981
  campaignId: data.campaign_id || null,
981
982
  });
982
- setInternalHandlers({});
983
- if (options.onCreate) {
984
- onCreate(options.onCreate);
985
- }
986
- if (options.onShow) {
987
- onShow(options.onShow);
988
- }
989
- if (options.onClose) {
990
- onClose(options.onClose);
991
- }
992
- if (options.onChangeState) {
993
- onChangeState(options.onChangeState);
994
- }
995
- if (options.onDestory) {
996
- onDestroy(options.onDestory);
997
- }
998
983
  const close = (trigger = 'none') => {
999
984
  if (!app) {
1000
985
  return;
@@ -1007,6 +992,7 @@ function create(App, options = {
1007
992
  if (onCloseHandlers) {
1008
993
  onCloseHandlers.forEach(h => h({ send: options.send, data }, trigger));
1009
994
  }
995
+ finalize();
1010
996
  app.$destroy();
1011
997
  app = null;
1012
998
  };
@@ -1077,6 +1063,9 @@ function create(App, options = {
1077
1063
  }
1078
1064
  return cleanup;
1079
1065
  };
1066
+ if (options.onCreate) {
1067
+ options.onCreate(actionProps);
1068
+ }
1080
1069
  const { onCreateHandlers } = getInternalHandlers();
1081
1070
  if (onCreateHandlers) {
1082
1071
  onCreateHandlers.forEach(h => h({ send: options.send, data }));
package/dist/templates.js CHANGED
@@ -9,7 +9,6 @@ import { onMount } from 'svelte';
9
9
  import { writable } from 'svelte/store';
10
10
  import {
11
11
  // functions
12
- // opened,
13
12
  state,
14
13
  customVariables,
15
14
 
@@ -31,10 +30,7 @@ import {
31
30
  FormTextarea,
32
31
  FormButton,
33
32
  FormRadioButtons,
34
-
35
- // svelte-ignore unused-export-let @ts-ignore
36
33
  } from '@plaidev/karte-action-sdk';
37
- // svelte-ignore unused-export-let @ts-ignore
38
34
 
39
35
  export let send: (event_name: string, values?: any) => void;
40
36
  let data_: Data;
@@ -43,6 +39,7 @@ let data = writable<Data & CustomVariables>({ ...data_ });
43
39
  export let onShow: (props: ActionProps<Props, Variables>) => void = _props => {};
44
40
  export let onChangeState: (props: ActionProps<Props, Variables>, stateId: string) => void = (_props, _state) => {};
45
41
  ${script}
42
+
46
43
  onMount(() => {
47
44
  onShow({ send, data: $data });
48
45
  });
@@ -65,21 +62,18 @@ function createIndexTsx(script = '') {
65
62
  import type { KarteAction, Send, Props, Variables } from "./gen";
66
63
 
67
64
  import "https://polyfill.io/v3/polyfill.min.js?features=IntersectionObserver";
68
- import { initialize, finalize, create } from "@plaidev/karte-action-sdk";
65
+ import { create } from "@plaidev/karte-action-sdk";
69
66
 
70
67
  import { props } from "./gen";
71
68
  import App from "./App.svelte";
72
69
  import onCreate from "./customScript";
73
70
  ${script}
74
71
  const action = (options: { send: Send; props: Props; variables: Variables }): KarteAction => {
75
- initialize({ send: options.send });
76
-
77
72
  return create(App, {
78
73
  props,
79
74
  send: options.send,
80
75
  variables: options.variables,
81
76
  onCreate,
82
- onClose: () => finalize(),
83
77
  });
84
78
  };
85
79
 
@@ -92,7 +86,14 @@ function createCustomScript(script = '') {
92
86
  */
93
87
  // ここでSDKをインポートしてください
94
88
  //import jQuery from "jquery";
95
- //import { onShow, onClose, onChangeState, onDestroy, customVariables } from "@plaidev/karte-action-sdk";
89
+ //import {
90
+ onShow,
91
+ onClose,
92
+ onChangeState,
93
+ onDestroy,
94
+ setCustomVariables,
95
+ setCustomHandlers,
96
+ } from "@plaidev/karte-action-sdk";
96
97
  ${script}
97
98
  const onCreate = ({ send, data }) => {
98
99
  // ここでアクションが作成される時のスクリプトを書いてください
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaidev/karte-action-sdk",
3
- "version": "1.1.103",
3
+ "version": "1.1.104-27910631.850a8338",
4
4
  "author": "Plaid Inc.",
5
5
  "license": "Apache-2.0",
6
6
  "module": "./dist/index.es.js",