@plaidev/karte-action-sdk 1.1.149-27994064.949f9af2 → 1.1.149-27996838.2c24786b

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.
@@ -1116,6 +1116,12 @@ declare function onChangeState<Props extends _Props$0, Variables>(fn: ActionChan
1116
1116
  * @public
1117
1117
  */
1118
1118
  type SendFunction = (event_name: string, values?: any) => void;
1119
+ /**
1120
+ * アクションの publish 関数
1121
+ *
1122
+ * @public
1123
+ */
1124
+ type PublishFunction = (topic: string, values?: any) => void;
1119
1125
  /**
1120
1126
  * アクションのプロパティ
1121
1127
  *
@@ -1126,6 +1132,10 @@ interface ActionProps<Props, Variables> {
1126
1132
  * アクションでイベントがトリガーされたときに受信するための関数
1127
1133
  */
1128
1134
  send: SendFunction;
1135
+ /**
1136
+ * アクション内でタグのQueueにリクエストを発行する関数
1137
+ */
1138
+ publish: PublishFunction;
1129
1139
  /**
1130
1140
  * アクションで使用されるデータ
1131
1141
  */
@@ -1146,11 +1156,17 @@ interface ActionProps<Props, Variables> {
1146
1156
  */
1147
1157
  interface ActionOptions<Props, Variables, VariablesQuery> {
1148
1158
  /**
1149
- * アクションでイベントがトリガーされたときに受信するための関数
1159
+ * アクション内でイベントを発火する関数
1150
1160
  *
1151
1161
  * @defaultValue `() => {}`
1152
1162
  */
1153
1163
  send?: SendFunction;
1164
+ /**
1165
+ * アクション内でタグのQueueにリクエストを発行する関数
1166
+ *
1167
+ * @defaultValue `() => {}`
1168
+ */
1169
+ publish?: PublishFunction;
1154
1170
  /**
1155
1171
  * アクションで使用されるプロパティ
1156
1172
  *
@@ -2530,6 +2546,12 @@ declare namespace widget {
2530
2546
  * @public
2531
2547
  */
2532
2548
  type SendFunction = (event_name: string, values?: any) => void;
2549
+ /**
2550
+ * アクションの publish 関数
2551
+ *
2552
+ * @public
2553
+ */
2554
+ type PublishFunction = (topic: string, values?: any) => void;
2533
2555
  /**
2534
2556
  * アクションのプロパティ
2535
2557
  *
@@ -2540,6 +2562,10 @@ declare namespace widget {
2540
2562
  * アクションでイベントがトリガーされたときに受信するための関数
2541
2563
  */
2542
2564
  send: SendFunction;
2565
+ /**
2566
+ * アクション内でタグのQueueにリクエストを発行する関数
2567
+ */
2568
+ publish: PublishFunction;
2543
2569
  /**
2544
2570
  * アクションで使用されるデータ
2545
2571
  */
@@ -2560,11 +2586,17 @@ declare namespace widget {
2560
2586
  */
2561
2587
  interface ActionOptions<Props, Variables, VariablesQuery> {
2562
2588
  /**
2563
- * アクションでイベントがトリガーされたときに受信するための関数
2589
+ * アクション内でイベントを発火する関数
2564
2590
  *
2565
2591
  * @defaultValue `() => {}`
2566
2592
  */
2567
2593
  send?: SendFunction;
2594
+ /**
2595
+ * アクション内でタグのQueueにリクエストを発行する関数
2596
+ *
2597
+ * @defaultValue `() => {}`
2598
+ */
2599
+ publish?: PublishFunction;
2568
2600
  /**
2569
2601
  * アクションで使用されるプロパティ
2570
2602
  *
@@ -1486,6 +1486,7 @@ function onChangeState(fn) {
1486
1486
  */
1487
1487
  function create(App, options = {
1488
1488
  send: () => { },
1489
+ publish: () => { },
1489
1490
  props: {},
1490
1491
  variables: {},
1491
1492
  localVariablesQuery: undefined,
@@ -1496,7 +1497,11 @@ function create(App, options = {
1496
1497
  ...options.variables,
1497
1498
  ...getVariables(),
1498
1499
  };
1499
- const actionProps = { send: options.send, data };
1500
+ const actionProps = {
1501
+ send: options.send,
1502
+ publish: options.publish,
1503
+ data,
1504
+ };
1500
1505
  const handleDestroy = () => {
1501
1506
  const { onDestroyHandlers } = getInternalHandlers();
1502
1507
  onDestroyHandlers?.forEach(h => {
@@ -1522,7 +1527,7 @@ function create(App, options = {
1522
1527
  onCloseHandlers.forEach(h => {
1523
1528
  const actionHookLog = { name: 'onClose', values: { trigger } };
1524
1529
  console.info(`${ACTION_HOOK_LABEL}:${JSON.stringify(actionHookLog)}`);
1525
- h({ send: options.send, data }, trigger);
1530
+ h({ send: options.send, publish: options.publish, data }, trigger);
1526
1531
  });
1527
1532
  }
1528
1533
  finalize();
@@ -1555,6 +1560,7 @@ function create(App, options = {
1555
1560
  hydrate: true,
1556
1561
  props: {
1557
1562
  send: options.send,
1563
+ publish: options.publish,
1558
1564
  data,
1559
1565
  onShow: (props) => {
1560
1566
  const { onShowHandlers } = getInternalHandlers();
@@ -1633,7 +1639,7 @@ function create(App, options = {
1633
1639
  const { onCreateHandlers } = getInternalHandlers();
1634
1640
  if (onCreateHandlers) {
1635
1641
  onCreateHandlers.forEach(h => {
1636
- h({ send: options.send, data });
1642
+ h({ send: options.send, publish: options.publish, data });
1637
1643
  console.debug(`${ACTION_HOOK_LABEL}: onCreate`);
1638
1644
  });
1639
1645
  }
@@ -1915,6 +1921,7 @@ const close = closeAction;
1915
1921
  */
1916
1922
  function createApp(App, options = {
1917
1923
  send: () => { },
1924
+ publish: () => { },
1918
1925
  props: {},
1919
1926
  variables: {},
1920
1927
  localVariablesQuery: undefined,
@@ -1930,6 +1937,7 @@ function createApp(App, options = {
1930
1937
  target: null,
1931
1938
  props: {
1932
1939
  send: options.send,
1940
+ publish: options.publish,
1933
1941
  close,
1934
1942
  data: {
1935
1943
  ...options.props,
@@ -1116,6 +1116,12 @@ declare function onChangeState<Props extends _Props$0, Variables>(fn: ActionChan
1116
1116
  * @public
1117
1117
  */
1118
1118
  type SendFunction = (event_name: string, values?: any) => void;
1119
+ /**
1120
+ * アクションの publish 関数
1121
+ *
1122
+ * @public
1123
+ */
1124
+ type PublishFunction = (topic: string, values?: any) => void;
1119
1125
  /**
1120
1126
  * アクションのプロパティ
1121
1127
  *
@@ -1126,6 +1132,10 @@ interface ActionProps<Props, Variables> {
1126
1132
  * アクションでイベントがトリガーされたときに受信するための関数
1127
1133
  */
1128
1134
  send: SendFunction;
1135
+ /**
1136
+ * アクション内でタグのQueueにリクエストを発行する関数
1137
+ */
1138
+ publish: PublishFunction;
1129
1139
  /**
1130
1140
  * アクションで使用されるデータ
1131
1141
  */
@@ -1146,11 +1156,17 @@ interface ActionProps<Props, Variables> {
1146
1156
  */
1147
1157
  interface ActionOptions<Props, Variables, VariablesQuery> {
1148
1158
  /**
1149
- * アクションでイベントがトリガーされたときに受信するための関数
1159
+ * アクション内でイベントを発火する関数
1150
1160
  *
1151
1161
  * @defaultValue `() => {}`
1152
1162
  */
1153
1163
  send?: SendFunction;
1164
+ /**
1165
+ * アクション内でタグのQueueにリクエストを発行する関数
1166
+ *
1167
+ * @defaultValue `() => {}`
1168
+ */
1169
+ publish?: PublishFunction;
1154
1170
  /**
1155
1171
  * アクションで使用されるプロパティ
1156
1172
  *
@@ -2530,6 +2546,12 @@ declare namespace widget {
2530
2546
  * @public
2531
2547
  */
2532
2548
  type SendFunction = (event_name: string, values?: any) => void;
2549
+ /**
2550
+ * アクションの publish 関数
2551
+ *
2552
+ * @public
2553
+ */
2554
+ type PublishFunction = (topic: string, values?: any) => void;
2533
2555
  /**
2534
2556
  * アクションのプロパティ
2535
2557
  *
@@ -2540,6 +2562,10 @@ declare namespace widget {
2540
2562
  * アクションでイベントがトリガーされたときに受信するための関数
2541
2563
  */
2542
2564
  send: SendFunction;
2565
+ /**
2566
+ * アクション内でタグのQueueにリクエストを発行する関数
2567
+ */
2568
+ publish: PublishFunction;
2543
2569
  /**
2544
2570
  * アクションで使用されるデータ
2545
2571
  */
@@ -2560,11 +2586,17 @@ declare namespace widget {
2560
2586
  */
2561
2587
  interface ActionOptions<Props, Variables, VariablesQuery> {
2562
2588
  /**
2563
- * アクションでイベントがトリガーされたときに受信するための関数
2589
+ * アクション内でイベントを発火する関数
2564
2590
  *
2565
2591
  * @defaultValue `() => {}`
2566
2592
  */
2567
2593
  send?: SendFunction;
2594
+ /**
2595
+ * アクション内でタグのQueueにリクエストを発行する関数
2596
+ *
2597
+ * @defaultValue `() => {}`
2598
+ */
2599
+ publish?: PublishFunction;
2568
2600
  /**
2569
2601
  * アクションで使用されるプロパティ
2570
2602
  *
package/dist/index.es.js CHANGED
@@ -1569,6 +1569,7 @@ function onChangeState(fn) {
1569
1569
  */
1570
1570
  function create(App, options = {
1571
1571
  send: () => { },
1572
+ publish: () => { },
1572
1573
  props: {},
1573
1574
  variables: {},
1574
1575
  localVariablesQuery: undefined,
@@ -1579,7 +1580,11 @@ function create(App, options = {
1579
1580
  ...options.variables,
1580
1581
  ...getVariables(),
1581
1582
  };
1582
- const actionProps = { send: options.send, data };
1583
+ const actionProps = {
1584
+ send: options.send,
1585
+ publish: options.publish,
1586
+ data,
1587
+ };
1583
1588
  const handleDestroy = () => {
1584
1589
  const { onDestroyHandlers } = getInternalHandlers();
1585
1590
  onDestroyHandlers?.forEach(h => {
@@ -1605,7 +1610,7 @@ function create(App, options = {
1605
1610
  onCloseHandlers.forEach(h => {
1606
1611
  const actionHookLog = { name: 'onClose', values: { trigger } };
1607
1612
  console.info(`${ACTION_HOOK_LABEL}:${JSON.stringify(actionHookLog)}`);
1608
- h({ send: options.send, data }, trigger);
1613
+ h({ send: options.send, publish: options.publish, data }, trigger);
1609
1614
  });
1610
1615
  }
1611
1616
  finalize();
@@ -1638,6 +1643,7 @@ function create(App, options = {
1638
1643
  hydrate: false,
1639
1644
  props: {
1640
1645
  send: options.send,
1646
+ publish: options.publish,
1641
1647
  data,
1642
1648
  onShow: (props) => {
1643
1649
  const { onShowHandlers } = getInternalHandlers();
@@ -1742,7 +1748,7 @@ function create(App, options = {
1742
1748
  const { onCreateHandlers } = getInternalHandlers();
1743
1749
  if (onCreateHandlers) {
1744
1750
  onCreateHandlers.forEach(h => {
1745
- h({ send: options.send, data });
1751
+ h({ send: options.send, publish: options.publish, data });
1746
1752
  console.debug(`${ACTION_HOOK_LABEL}: onCreate`);
1747
1753
  });
1748
1754
  }
@@ -2023,6 +2029,7 @@ const close = closeAction;
2023
2029
  */
2024
2030
  function createApp(App, options = {
2025
2031
  send: () => { },
2032
+ publish: () => { },
2026
2033
  props: {},
2027
2034
  variables: {},
2028
2035
  localVariablesQuery: undefined,
@@ -2038,6 +2045,7 @@ function createApp(App, options = {
2038
2045
  target: null,
2039
2046
  props: {
2040
2047
  send: options.send,
2048
+ publish: options.publish,
2041
2049
  close,
2042
2050
  data: {
2043
2051
  ...options.props,
@@ -67,7 +67,7 @@ $: {
67
67
  }
68
68
  function createIndexTsx({ script = '', polyfill = false, } = {}) {
69
69
  // TODO: `script` should be validated!
70
- return `import type { KarteAction, Send, Props, Variables } from "./gen";
70
+ return `import type { KarteAction, Send, Publish, Props, Variables } from "./gen";
71
71
  ${polyfill ? `import "https://polyfill.io/v3/polyfill.min.js?features=IntersectionObserver";` : ''}
72
72
  import { create } from "@plaidev/karte-action-sdk";
73
73
 
@@ -75,10 +75,11 @@ import { props, localVariablesQuery } from "./gen";
75
75
  import App from "./App.svelte";
76
76
  import onCreate from "./customScript";
77
77
  ${script}
78
- const action = (options: { send: Send; props: Props; variables: Variables }): KarteAction => {
78
+ const action = (options: { send: Send; publish: Publish, props: Props; variables: Variables }): KarteAction => {
79
79
  return create(App, {
80
80
  props,
81
81
  send: options.send,
82
+ publish: options.publish,
82
83
  variables: options.variables,
83
84
  localVariablesQuery,
84
85
  onCreate,
@@ -88,6 +89,8 @@ const action = (options: { send: Send; props: Props; variables: Variables }): Ka
88
89
  export default action;`;
89
90
  }
90
91
  function createCustomScript(script = '') {
92
+ // export defaultの引数をシンプルにするため、標準のアクションで使わない変数をpropsに入れていない
93
+ // 標準以外の使い方をするケースはサポートドキュメントでフォローする
91
94
  // TODO: `script` should be validated!
92
95
  return `\
93
96
  import { showAction } from "@plaidev/karte-action-sdk";
package/dist/templates.js CHANGED
@@ -65,7 +65,7 @@ $: {
65
65
  }
66
66
  function createIndexTsx({ script = '', polyfill = false, } = {}) {
67
67
  // TODO: `script` should be validated!
68
- return `import type { KarteAction, Send, Props, Variables } from "./gen";
68
+ return `import type { KarteAction, Send, Publish, Props, Variables } from "./gen";
69
69
  ${polyfill ? `import "https://polyfill.io/v3/polyfill.min.js?features=IntersectionObserver";` : ''}
70
70
  import { create } from "@plaidev/karte-action-sdk";
71
71
 
@@ -73,10 +73,11 @@ import { props, localVariablesQuery } from "./gen";
73
73
  import App from "./App.svelte";
74
74
  import onCreate from "./customScript";
75
75
  ${script}
76
- const action = (options: { send: Send; props: Props; variables: Variables }): KarteAction => {
76
+ const action = (options: { send: Send; publish: Publish, props: Props; variables: Variables }): KarteAction => {
77
77
  return create(App, {
78
78
  props,
79
79
  send: options.send,
80
+ publish: options.publish,
80
81
  variables: options.variables,
81
82
  localVariablesQuery,
82
83
  onCreate,
@@ -86,6 +87,8 @@ const action = (options: { send: Send; props: Props; variables: Variables }): Ka
86
87
  export default action;`;
87
88
  }
88
89
  function createCustomScript(script = '') {
90
+ // export defaultの引数をシンプルにするため、標準のアクションで使わない変数をpropsに入れていない
91
+ // 標準以外の使い方をするケースはサポートドキュメントでフォローする
89
92
  // TODO: `script` should be validated!
90
93
  return `\
91
94
  import { showAction } from "@plaidev/karte-action-sdk";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaidev/karte-action-sdk",
3
- "version": "1.1.149-27994064.949f9af2",
3
+ "version": "1.1.149-27996838.2c24786b",
4
4
  "author": "Plaid Inc.",
5
5
  "license": "Apache-2.0",
6
6
  "module": "./dist/index.es.js",