@plaidev/karte-action-sdk 1.1.149 → 1.1.151-27999696.f0ef8547
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/dist/hydrate/index.es.d.ts +34 -2
- package/dist/hydrate/index.es.js +16 -3
- package/dist/index.es.d.ts +34 -2
- package/dist/index.es.js +16 -3
- package/dist/templates.cjs.js +5 -2
- package/dist/templates.js +5 -2
- package/package.json +1 -1
@@ -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/hydrate/index.es.js
CHANGED
@@ -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 = {
|
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();
|
@@ -1550,11 +1555,16 @@ function create(App, options = {
|
|
1550
1555
|
options.send('message_open', { state: getState$1() });
|
1551
1556
|
setOpened(true);
|
1552
1557
|
setClosed(false); // deprecated
|
1558
|
+
// 非同期処理中にappが初期化されている可能性がある
|
1559
|
+
if (app) {
|
1560
|
+
return;
|
1561
|
+
}
|
1553
1562
|
app = new App({
|
1554
1563
|
target: ensureActionRoot(!true),
|
1555
1564
|
hydrate: true,
|
1556
1565
|
props: {
|
1557
1566
|
send: options.send,
|
1567
|
+
publish: options.publish,
|
1558
1568
|
data,
|
1559
1569
|
onShow: (props) => {
|
1560
1570
|
const { onShowHandlers } = getInternalHandlers();
|
@@ -1633,7 +1643,7 @@ function create(App, options = {
|
|
1633
1643
|
const { onCreateHandlers } = getInternalHandlers();
|
1634
1644
|
if (onCreateHandlers) {
|
1635
1645
|
onCreateHandlers.forEach(h => {
|
1636
|
-
h({ send: options.send, data });
|
1646
|
+
h({ send: options.send, publish: options.publish, data });
|
1637
1647
|
console.debug(`${ACTION_HOOK_LABEL}: onCreate`);
|
1638
1648
|
});
|
1639
1649
|
}
|
@@ -1642,6 +1652,7 @@ function create(App, options = {
|
|
1642
1652
|
options.onCreate(actionProps);
|
1643
1653
|
}
|
1644
1654
|
const appCleanup = () => {
|
1655
|
+
app?.$destroy();
|
1645
1656
|
actionTablePromise = null;
|
1646
1657
|
showTriggerCleanups.forEach((c) => c());
|
1647
1658
|
closeTriggerCleanups.forEach((c) => c());
|
@@ -1915,6 +1926,7 @@ const close = closeAction;
|
|
1915
1926
|
*/
|
1916
1927
|
function createApp(App, options = {
|
1917
1928
|
send: () => { },
|
1929
|
+
publish: () => { },
|
1918
1930
|
props: {},
|
1919
1931
|
variables: {},
|
1920
1932
|
localVariablesQuery: undefined,
|
@@ -1930,6 +1942,7 @@ function createApp(App, options = {
|
|
1930
1942
|
target: null,
|
1931
1943
|
props: {
|
1932
1944
|
send: options.send,
|
1945
|
+
publish: options.publish,
|
1933
1946
|
close,
|
1934
1947
|
data: {
|
1935
1948
|
...options.props,
|
package/dist/index.es.d.ts
CHANGED
@@ -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 = {
|
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();
|
@@ -1633,11 +1638,16 @@ function create(App, options = {
|
|
1633
1638
|
options.send('message_open', { state: getState$1() });
|
1634
1639
|
setOpened(true);
|
1635
1640
|
setClosed(false); // deprecated
|
1641
|
+
// 非同期処理中にappが初期化されている可能性がある
|
1642
|
+
if (app) {
|
1643
|
+
return;
|
1644
|
+
}
|
1636
1645
|
app = new App({
|
1637
1646
|
target: ensureActionRoot(!false),
|
1638
1647
|
hydrate: false,
|
1639
1648
|
props: {
|
1640
1649
|
send: options.send,
|
1650
|
+
publish: options.publish,
|
1641
1651
|
data,
|
1642
1652
|
onShow: (props) => {
|
1643
1653
|
const { onShowHandlers } = getInternalHandlers();
|
@@ -1742,7 +1752,7 @@ function create(App, options = {
|
|
1742
1752
|
const { onCreateHandlers } = getInternalHandlers();
|
1743
1753
|
if (onCreateHandlers) {
|
1744
1754
|
onCreateHandlers.forEach(h => {
|
1745
|
-
h({ send: options.send, data });
|
1755
|
+
h({ send: options.send, publish: options.publish, data });
|
1746
1756
|
console.debug(`${ACTION_HOOK_LABEL}: onCreate`);
|
1747
1757
|
});
|
1748
1758
|
}
|
@@ -1751,6 +1761,7 @@ function create(App, options = {
|
|
1751
1761
|
options.onCreate(actionProps);
|
1752
1762
|
}
|
1753
1763
|
const appCleanup = () => {
|
1764
|
+
app?.$destroy();
|
1754
1765
|
actionTablePromise = null;
|
1755
1766
|
showTriggerCleanups.forEach((c) => c());
|
1756
1767
|
closeTriggerCleanups.forEach((c) => c());
|
@@ -2023,6 +2034,7 @@ const close = closeAction;
|
|
2023
2034
|
*/
|
2024
2035
|
function createApp(App, options = {
|
2025
2036
|
send: () => { },
|
2037
|
+
publish: () => { },
|
2026
2038
|
props: {},
|
2027
2039
|
variables: {},
|
2028
2040
|
localVariablesQuery: undefined,
|
@@ -2038,6 +2050,7 @@ function createApp(App, options = {
|
|
2038
2050
|
target: null,
|
2039
2051
|
props: {
|
2040
2052
|
send: options.send,
|
2053
|
+
publish: options.publish,
|
2041
2054
|
close,
|
2042
2055
|
data: {
|
2043
2056
|
...options.props,
|
package/dist/templates.cjs.js
CHANGED
@@ -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";
|