@plaidev/karte-action-sdk 1.1.183 → 1.1.184-28093385.169b3110
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 +110 -18
- package/dist/hydrate/index.es.js +124 -2
- package/dist/index.es.d.ts +110 -18
- package/dist/index.es.js +124 -2
- package/dist/templates.cjs.js +2 -1
- package/dist/templates.js +2 -1
- package/package.json +1 -1
@@ -36,15 +36,6 @@ type ActionEventHandler = (...args: any[]) => any | Promise<any>;
|
|
36
36
|
type ActionVariables = {
|
37
37
|
[key: string]: any;
|
38
38
|
};
|
39
|
-
/**
|
40
|
-
* アクション設定
|
41
|
-
*
|
42
|
-
* @public
|
43
|
-
*/
|
44
|
-
type ActionSetting = {
|
45
|
-
send?: (event_name: string, values?: any) => void;
|
46
|
-
initialState?: string;
|
47
|
-
};
|
48
39
|
/**
|
49
40
|
* アクションの send 関数
|
50
41
|
*
|
@@ -57,6 +48,16 @@ type SendFunction = (event_name: string, values?: any) => void;
|
|
57
48
|
* @public
|
58
49
|
*/
|
59
50
|
type PublishFunction = (topic: string, values?: any) => void;
|
51
|
+
/**
|
52
|
+
* アクション設定
|
53
|
+
*
|
54
|
+
* @public
|
55
|
+
*/
|
56
|
+
type ActionSetting = {
|
57
|
+
send?: SendFunction;
|
58
|
+
publish?: PublishFunction;
|
59
|
+
initialState?: string;
|
60
|
+
};
|
60
61
|
/**
|
61
62
|
* アクションのライフサイクル changeState で呼び出されるフック関数
|
62
63
|
*
|
@@ -151,6 +152,10 @@ interface ActionOptions<Props, Variables, VariablesQuery> {
|
|
151
152
|
karteTemplate?: {
|
152
153
|
[key: string]: any;
|
153
154
|
};
|
155
|
+
/**
|
156
|
+
* アクション実行時のコンテキスト
|
157
|
+
*/
|
158
|
+
context: ActionRunnerContext;
|
154
159
|
}
|
155
160
|
/**
|
156
161
|
* KARTE のシステム設定情報
|
@@ -173,6 +178,13 @@ type ActionHookLog = {
|
|
173
178
|
name: string;
|
174
179
|
values?: any;
|
175
180
|
};
|
181
|
+
/**
|
182
|
+
* アクション実行時のコンテキスト
|
183
|
+
*/
|
184
|
+
type ActionRunnerContext = {
|
185
|
+
api_key: string;
|
186
|
+
target?: "web" | "native";
|
187
|
+
};
|
176
188
|
type ActionTableResult = number | string | boolean | Date | null | undefined;
|
177
189
|
type ActionTableQueryParam = string | number | boolean | Date;
|
178
190
|
type ActionTableQueryParams = {
|
@@ -732,6 +744,7 @@ type OperationArgumentTypes = {
|
|
732
744
|
NumberKeyword: number;
|
733
745
|
TransitState: string;
|
734
746
|
Url: string;
|
747
|
+
Color: string;
|
735
748
|
Handler: string;
|
736
749
|
Trigger: string;
|
737
750
|
};
|
@@ -740,6 +753,7 @@ type OperationArgumentType = keyof OperationArgumentTypes;
|
|
740
753
|
type BaseOperationOptions = ReadonlyArray<{
|
741
754
|
operation: string;
|
742
755
|
args: ReadonlyArray<{
|
756
|
+
name: string;
|
743
757
|
type: OperationArgumentType;
|
744
758
|
default: any;
|
745
759
|
}>;
|
@@ -765,10 +779,12 @@ declare const OnClickOperationOptions: readonly [
|
|
765
779
|
readonly operation: "linkTo";
|
766
780
|
readonly args: readonly [
|
767
781
|
{
|
782
|
+
readonly name: "url";
|
768
783
|
readonly type: "Url";
|
769
784
|
readonly default: "";
|
770
785
|
},
|
771
786
|
{
|
787
|
+
readonly name: "open_new_tab";
|
772
788
|
readonly type: "BooleanKeyword";
|
773
789
|
readonly default: true;
|
774
790
|
}
|
@@ -778,6 +794,7 @@ declare const OnClickOperationOptions: readonly [
|
|
778
794
|
readonly operation: "moveTo";
|
779
795
|
readonly args: readonly [
|
780
796
|
{
|
797
|
+
readonly name: "state";
|
781
798
|
readonly type: "TransitState";
|
782
799
|
readonly default: "/";
|
783
800
|
}
|
@@ -787,6 +804,7 @@ declare const OnClickOperationOptions: readonly [
|
|
787
804
|
readonly operation: "closeApp";
|
788
805
|
readonly args: readonly [
|
789
806
|
{
|
807
|
+
readonly name: "trigger";
|
790
808
|
readonly type: "Trigger";
|
791
809
|
readonly default: "button";
|
792
810
|
}
|
@@ -796,6 +814,7 @@ declare const OnClickOperationOptions: readonly [
|
|
796
814
|
readonly operation: "runScript";
|
797
815
|
readonly args: readonly [
|
798
816
|
{
|
817
|
+
readonly name: "handler";
|
799
818
|
readonly type: "Handler";
|
800
819
|
readonly default: "";
|
801
820
|
}
|
@@ -805,10 +824,71 @@ declare const OnClickOperationOptions: readonly [
|
|
805
824
|
readonly operation: "submitForm";
|
806
825
|
readonly args: readonly [
|
807
826
|
{
|
827
|
+
readonly name: "state";
|
808
828
|
readonly type: "TransitState";
|
809
829
|
readonly default: "/";
|
810
830
|
}
|
811
831
|
];
|
832
|
+
},
|
833
|
+
{
|
834
|
+
readonly operation: "bootChat";
|
835
|
+
readonly args: readonly [
|
836
|
+
{
|
837
|
+
readonly name: "hide_launcher";
|
838
|
+
readonly type: "BooleanKeyword";
|
839
|
+
readonly default: false;
|
840
|
+
},
|
841
|
+
{
|
842
|
+
readonly name: "placement_pc";
|
843
|
+
readonly type: "StringKeyword";
|
844
|
+
readonly default: "left";
|
845
|
+
},
|
846
|
+
{
|
847
|
+
readonly name: "placement_mobile";
|
848
|
+
readonly type: "StringKeyword";
|
849
|
+
readonly default: "left";
|
850
|
+
},
|
851
|
+
{
|
852
|
+
readonly name: "horizontal_spacing_pc";
|
853
|
+
readonly type: "NumberKeyword";
|
854
|
+
readonly default: 20;
|
855
|
+
},
|
856
|
+
{
|
857
|
+
readonly name: "horizontal_spacing_mobile";
|
858
|
+
readonly type: "NumberKeyword";
|
859
|
+
readonly default: 20;
|
860
|
+
},
|
861
|
+
{
|
862
|
+
readonly name: "vertical_spacing_pc";
|
863
|
+
readonly type: "NumberKeyword";
|
864
|
+
readonly default: 20;
|
865
|
+
},
|
866
|
+
{
|
867
|
+
readonly name: "vertical_spacing_mobile";
|
868
|
+
readonly type: "NumberKeyword";
|
869
|
+
readonly default: 20;
|
870
|
+
},
|
871
|
+
{
|
872
|
+
readonly name: "theme_color";
|
873
|
+
readonly type: "Color";
|
874
|
+
readonly default: "#2aab9f";
|
875
|
+
},
|
876
|
+
{
|
877
|
+
readonly name: "header_title";
|
878
|
+
readonly type: "StringKeyword";
|
879
|
+
readonly default: "KARTE\u30B5\u30DD\u30FC\u30C8\u30C1\u30FC\u30E0";
|
880
|
+
},
|
881
|
+
{
|
882
|
+
readonly name: "header_description";
|
883
|
+
readonly type: "StringKeyword";
|
884
|
+
readonly default: "\u3054\u8CEA\u554F\u304C\u3042\u308C\u3070\u304A\u5C0B\u306D\u304F\u3060\u3055\u3044\u3002\nKARTE\u30B5\u30DD\u30FC\u30C8\u62C5\u5F53\u8005\u306B\u3064\u306A\u304C\u308A\u307E\u3059\u3002\u30B5\u30DD\u30FC\u30C8\u53D7\u4ED8\u6642\u9593\u306F\u5E73\u65E510:30-17:30\u3067\u3059\u3002";
|
885
|
+
},
|
886
|
+
{
|
887
|
+
readonly name: "launcher_image";
|
888
|
+
readonly type: "StringKeyword";
|
889
|
+
readonly default: "";
|
890
|
+
}
|
891
|
+
];
|
812
892
|
}
|
813
893
|
];
|
814
894
|
/** @internal */
|
@@ -1397,15 +1477,6 @@ declare namespace widget {
|
|
1397
1477
|
type ActionVariables = {
|
1398
1478
|
[key: string]: any;
|
1399
1479
|
};
|
1400
|
-
/**
|
1401
|
-
* アクション設定
|
1402
|
-
*
|
1403
|
-
* @public
|
1404
|
-
*/
|
1405
|
-
type ActionSetting = {
|
1406
|
-
send?: (event_name: string, values?: any) => void;
|
1407
|
-
initialState?: string;
|
1408
|
-
};
|
1409
1480
|
/**
|
1410
1481
|
* アクションの send 関数
|
1411
1482
|
*
|
@@ -1418,6 +1489,16 @@ declare namespace widget {
|
|
1418
1489
|
* @public
|
1419
1490
|
*/
|
1420
1491
|
type PublishFunction = (topic: string, values?: any) => void;
|
1492
|
+
/**
|
1493
|
+
* アクション設定
|
1494
|
+
*
|
1495
|
+
* @public
|
1496
|
+
*/
|
1497
|
+
type ActionSetting = {
|
1498
|
+
send?: SendFunction;
|
1499
|
+
publish?: PublishFunction;
|
1500
|
+
initialState?: string;
|
1501
|
+
};
|
1421
1502
|
/**
|
1422
1503
|
* アクションのライフサイクル changeState で呼び出されるフック関数
|
1423
1504
|
*
|
@@ -1512,6 +1593,10 @@ declare namespace widget {
|
|
1512
1593
|
karteTemplate?: {
|
1513
1594
|
[key: string]: any;
|
1514
1595
|
};
|
1596
|
+
/**
|
1597
|
+
* アクション実行時のコンテキスト
|
1598
|
+
*/
|
1599
|
+
context: ActionRunnerContext;
|
1515
1600
|
}
|
1516
1601
|
/**
|
1517
1602
|
* KARTE のシステム設定情報
|
@@ -1534,6 +1619,13 @@ declare namespace widget {
|
|
1534
1619
|
name: string;
|
1535
1620
|
values?: any;
|
1536
1621
|
};
|
1622
|
+
/**
|
1623
|
+
* アクション実行時のコンテキスト
|
1624
|
+
*/
|
1625
|
+
type ActionRunnerContext = {
|
1626
|
+
api_key: string;
|
1627
|
+
target?: "web" | "native";
|
1628
|
+
};
|
1537
1629
|
type ActionTableResult = number | string | boolean | Date | null | undefined;
|
1538
1630
|
type ActionTableQueryParam = string | number | boolean | Date;
|
1539
1631
|
type ActionTableQueryParams = {
|
package/dist/hydrate/index.es.js
CHANGED
@@ -340,10 +340,12 @@ const OnClickOperationOptions = [
|
|
340
340
|
operation: 'linkTo',
|
341
341
|
args: [
|
342
342
|
{
|
343
|
+
name: 'url',
|
343
344
|
type: 'Url',
|
344
345
|
default: '',
|
345
346
|
},
|
346
347
|
{
|
348
|
+
name: 'open_new_tab',
|
347
349
|
type: 'BooleanKeyword',
|
348
350
|
default: true,
|
349
351
|
},
|
@@ -353,6 +355,7 @@ const OnClickOperationOptions = [
|
|
353
355
|
operation: 'moveTo',
|
354
356
|
args: [
|
355
357
|
{
|
358
|
+
name: 'state',
|
356
359
|
type: 'TransitState',
|
357
360
|
default: '/',
|
358
361
|
},
|
@@ -362,6 +365,7 @@ const OnClickOperationOptions = [
|
|
362
365
|
operation: 'closeApp',
|
363
366
|
args: [
|
364
367
|
{
|
368
|
+
name: 'trigger',
|
365
369
|
type: 'Trigger',
|
366
370
|
default: 'button',
|
367
371
|
},
|
@@ -371,6 +375,7 @@ const OnClickOperationOptions = [
|
|
371
375
|
operation: 'runScript',
|
372
376
|
args: [
|
373
377
|
{
|
378
|
+
name: 'handler',
|
374
379
|
type: 'Handler',
|
375
380
|
default: '',
|
376
381
|
},
|
@@ -380,11 +385,73 @@ const OnClickOperationOptions = [
|
|
380
385
|
operation: 'submitForm',
|
381
386
|
args: [
|
382
387
|
{
|
388
|
+
name: 'state',
|
383
389
|
type: 'TransitState',
|
384
390
|
default: '/',
|
385
391
|
},
|
386
392
|
],
|
387
393
|
},
|
394
|
+
{
|
395
|
+
operation: 'bootChat',
|
396
|
+
args: [
|
397
|
+
{
|
398
|
+
name: 'hide_launcher',
|
399
|
+
type: 'BooleanKeyword',
|
400
|
+
default: false,
|
401
|
+
},
|
402
|
+
{
|
403
|
+
name: 'placement_pc',
|
404
|
+
type: 'StringKeyword',
|
405
|
+
default: 'left',
|
406
|
+
},
|
407
|
+
{
|
408
|
+
name: 'placement_mobile',
|
409
|
+
type: 'StringKeyword',
|
410
|
+
default: 'left',
|
411
|
+
},
|
412
|
+
{
|
413
|
+
name: 'horizontal_spacing_pc',
|
414
|
+
type: 'NumberKeyword',
|
415
|
+
default: 20,
|
416
|
+
},
|
417
|
+
{
|
418
|
+
name: 'horizontal_spacing_mobile',
|
419
|
+
type: 'NumberKeyword',
|
420
|
+
default: 20,
|
421
|
+
},
|
422
|
+
{
|
423
|
+
name: 'vertical_spacing_pc',
|
424
|
+
type: 'NumberKeyword',
|
425
|
+
default: 20,
|
426
|
+
},
|
427
|
+
{
|
428
|
+
name: 'vertical_spacing_mobile',
|
429
|
+
type: 'NumberKeyword',
|
430
|
+
default: 20,
|
431
|
+
},
|
432
|
+
{
|
433
|
+
name: 'theme_color',
|
434
|
+
type: 'Color',
|
435
|
+
default: '#2aab9f',
|
436
|
+
},
|
437
|
+
{
|
438
|
+
name: 'header_title',
|
439
|
+
type: 'StringKeyword',
|
440
|
+
default: 'KARTEサポートチーム',
|
441
|
+
},
|
442
|
+
{
|
443
|
+
name: 'header_description',
|
444
|
+
type: 'StringKeyword',
|
445
|
+
default: `ご質問があればお尋ねください。
|
446
|
+
KARTEサポート担当者につながります。サポート受付時間は平日10:30-17:30です。`,
|
447
|
+
},
|
448
|
+
{
|
449
|
+
name: 'launcher_image',
|
450
|
+
type: 'StringKeyword',
|
451
|
+
default: '',
|
452
|
+
},
|
453
|
+
],
|
454
|
+
},
|
388
455
|
];
|
389
456
|
/** @internal */
|
390
457
|
const LengthUnits = ['px', 'em', 'rem', 'vw', 'fr', '%'];
|
@@ -564,6 +631,28 @@ function getSystem() {
|
|
564
631
|
function setSystem(config) {
|
565
632
|
system.set(config);
|
566
633
|
}
|
634
|
+
/**
|
635
|
+
* アクション実行時のコンテキストを保存するストア
|
636
|
+
*
|
637
|
+
* @internal
|
638
|
+
*/
|
639
|
+
const actionRunnerContext = writable(null);
|
640
|
+
/**
|
641
|
+
* アクション実行時のコンテキストを取得する
|
642
|
+
*
|
643
|
+
* @internal
|
644
|
+
*/
|
645
|
+
function getActionRunnerContext() {
|
646
|
+
return get(actionRunnerContext);
|
647
|
+
}
|
648
|
+
/**
|
649
|
+
* アクション実行時のコンテキストを保存する
|
650
|
+
*
|
651
|
+
* @internal
|
652
|
+
*/
|
653
|
+
function setActionRunnerContext(value) {
|
654
|
+
return actionRunnerContext.set(value);
|
655
|
+
}
|
567
656
|
/**
|
568
657
|
* Store to handle current state ID
|
569
658
|
*
|
@@ -1043,6 +1132,11 @@ const send_event = (event_name, values) => {
|
|
1043
1132
|
setting?.send?.(event_name, values);
|
1044
1133
|
};
|
1045
1134
|
/** @internal */
|
1135
|
+
const publish_edge = (topic, values) => {
|
1136
|
+
const setting = getSetting();
|
1137
|
+
setting?.publish?.(topic, values);
|
1138
|
+
};
|
1139
|
+
/** @internal */
|
1046
1140
|
const initialize = (setting) => {
|
1047
1141
|
const newSetting = setSetting(setting);
|
1048
1142
|
if (newSetting.initialState) {
|
@@ -1459,6 +1553,7 @@ function createModal(App, options = {
|
|
1459
1553
|
variables: {},
|
1460
1554
|
localVariablesQuery: undefined,
|
1461
1555
|
karteTemplate: {},
|
1556
|
+
context: { api_key: '' },
|
1462
1557
|
}) {
|
1463
1558
|
let app = null;
|
1464
1559
|
const data = {
|
@@ -1658,6 +1753,7 @@ function createApp(App, options = {
|
|
1658
1753
|
props: {},
|
1659
1754
|
variables: {},
|
1660
1755
|
localVariablesQuery: undefined,
|
1756
|
+
context: { api_key: '' },
|
1661
1757
|
}) {
|
1662
1758
|
let app = null;
|
1663
1759
|
const close = () => {
|
@@ -1738,6 +1834,7 @@ async function runScript$1(options = {
|
|
1738
1834
|
variables: {},
|
1739
1835
|
localVariablesQuery: undefined,
|
1740
1836
|
karteTemplate: {},
|
1837
|
+
context: { api_key: '' },
|
1741
1838
|
}) {
|
1742
1839
|
if (!options.onCreate)
|
1743
1840
|
return;
|
@@ -1848,6 +1945,7 @@ function create(App, options = {
|
|
1848
1945
|
variables: {},
|
1849
1946
|
localVariablesQuery: undefined,
|
1850
1947
|
karteTemplate: {},
|
1948
|
+
context: { api_key: '' },
|
1851
1949
|
}) {
|
1852
1950
|
const data = {
|
1853
1951
|
...options.props,
|
@@ -1879,6 +1977,7 @@ function create(App, options = {
|
|
1879
1977
|
shortenId: data.shorten_id || null,
|
1880
1978
|
campaignId: data.campaign_id || null,
|
1881
1979
|
});
|
1980
|
+
setActionRunnerContext(options.context);
|
1882
1981
|
const loggerCleanup = listenConsoleLogger() ;
|
1883
1982
|
window.addEventListener(ACTION_DESTROY_EVENT, handleDestroy);
|
1884
1983
|
window.addEventListener('beforeunload', dispatchDestroyEvent, false);
|
@@ -2723,6 +2822,7 @@ const moveTo = (to) => () => {
|
|
2723
2822
|
};
|
2724
2823
|
/** @internal */
|
2725
2824
|
const linkTo = (to, targetBlank = true) => () => {
|
2825
|
+
const { target } = getActionRunnerContext() ?? {};
|
2726
2826
|
async function sleep(ms) {
|
2727
2827
|
return new Promise(resolve => setTimeout(resolve, ms));
|
2728
2828
|
}
|
@@ -2731,11 +2831,12 @@ const linkTo = (to, targetBlank = true) => () => {
|
|
2731
2831
|
// # edge.js の retransmitter が送るのを待つ
|
2732
2832
|
await sleep(450);
|
2733
2833
|
}
|
2734
|
-
|
2834
|
+
const isRequiredWindowOpen = target === 'native' || targetBlank;
|
2835
|
+
if (isRequiredWindowOpen) {
|
2735
2836
|
window.open(to);
|
2736
2837
|
}
|
2737
2838
|
Promise.race([_send(), sleep(650)]).then(() => {
|
2738
|
-
if (!
|
2839
|
+
if (!isRequiredWindowOpen) {
|
2739
2840
|
location.href = to;
|
2740
2841
|
}
|
2741
2842
|
});
|
@@ -2764,6 +2865,24 @@ const submitForm = (to) => () => {
|
|
2764
2865
|
_moveTo(to);
|
2765
2866
|
};
|
2766
2867
|
/** @internal */
|
2868
|
+
const bootChat = (hide_launcher, placement_pc, placement_mobile, horizontal_spacing_pc, horizontal_spacing_mobile, vertical_spacing_pc, vertical_spacing_mobile, theme_color, header_title, header_description, launcher_image) => () => {
|
2869
|
+
const options = {
|
2870
|
+
hide_launcher,
|
2871
|
+
placement_pc,
|
2872
|
+
placement_mobile,
|
2873
|
+
horizontal_spacing_pc,
|
2874
|
+
horizontal_spacing_mobile,
|
2875
|
+
vertical_spacing_pc,
|
2876
|
+
vertical_spacing_mobile,
|
2877
|
+
theme_color,
|
2878
|
+
header_title,
|
2879
|
+
header_description: header_description.replace(/<br\s*\/?>/gi, '\n'),
|
2880
|
+
};
|
2881
|
+
if (launcher_image && launcher_image !== '')
|
2882
|
+
options.launcher_image = launcher_image;
|
2883
|
+
publish_edge('talk', { actionName: 'boot', args: [options] });
|
2884
|
+
};
|
2885
|
+
/** @internal */
|
2767
2886
|
const execOnClickOperation = (onClickOperation) => {
|
2768
2887
|
if (onClickOperation.operation === 'linkTo') {
|
2769
2888
|
linkTo(...onClickOperation.args)();
|
@@ -2780,6 +2899,9 @@ const execOnClickOperation = (onClickOperation) => {
|
|
2780
2899
|
else if (onClickOperation.operation === 'submitForm') {
|
2781
2900
|
submitForm(onClickOperation.args[0])();
|
2782
2901
|
}
|
2902
|
+
else if (onClickOperation.operation === 'bootChat') {
|
2903
|
+
bootChat(...onClickOperation.args)();
|
2904
|
+
}
|
2783
2905
|
};
|
2784
2906
|
/** @internal */
|
2785
2907
|
const haveFunction = (onClickOperation) => {
|
package/dist/index.es.d.ts
CHANGED
@@ -36,15 +36,6 @@ type ActionEventHandler = (...args: any[]) => any | Promise<any>;
|
|
36
36
|
type ActionVariables = {
|
37
37
|
[key: string]: any;
|
38
38
|
};
|
39
|
-
/**
|
40
|
-
* アクション設定
|
41
|
-
*
|
42
|
-
* @public
|
43
|
-
*/
|
44
|
-
type ActionSetting = {
|
45
|
-
send?: (event_name: string, values?: any) => void;
|
46
|
-
initialState?: string;
|
47
|
-
};
|
48
39
|
/**
|
49
40
|
* アクションの send 関数
|
50
41
|
*
|
@@ -57,6 +48,16 @@ type SendFunction = (event_name: string, values?: any) => void;
|
|
57
48
|
* @public
|
58
49
|
*/
|
59
50
|
type PublishFunction = (topic: string, values?: any) => void;
|
51
|
+
/**
|
52
|
+
* アクション設定
|
53
|
+
*
|
54
|
+
* @public
|
55
|
+
*/
|
56
|
+
type ActionSetting = {
|
57
|
+
send?: SendFunction;
|
58
|
+
publish?: PublishFunction;
|
59
|
+
initialState?: string;
|
60
|
+
};
|
60
61
|
/**
|
61
62
|
* アクションのライフサイクル changeState で呼び出されるフック関数
|
62
63
|
*
|
@@ -151,6 +152,10 @@ interface ActionOptions<Props, Variables, VariablesQuery> {
|
|
151
152
|
karteTemplate?: {
|
152
153
|
[key: string]: any;
|
153
154
|
};
|
155
|
+
/**
|
156
|
+
* アクション実行時のコンテキスト
|
157
|
+
*/
|
158
|
+
context: ActionRunnerContext;
|
154
159
|
}
|
155
160
|
/**
|
156
161
|
* KARTE のシステム設定情報
|
@@ -173,6 +178,13 @@ type ActionHookLog = {
|
|
173
178
|
name: string;
|
174
179
|
values?: any;
|
175
180
|
};
|
181
|
+
/**
|
182
|
+
* アクション実行時のコンテキスト
|
183
|
+
*/
|
184
|
+
type ActionRunnerContext = {
|
185
|
+
api_key: string;
|
186
|
+
target?: "web" | "native";
|
187
|
+
};
|
176
188
|
type ActionTableResult = number | string | boolean | Date | null | undefined;
|
177
189
|
type ActionTableQueryParam = string | number | boolean | Date;
|
178
190
|
type ActionTableQueryParams = {
|
@@ -732,6 +744,7 @@ type OperationArgumentTypes = {
|
|
732
744
|
NumberKeyword: number;
|
733
745
|
TransitState: string;
|
734
746
|
Url: string;
|
747
|
+
Color: string;
|
735
748
|
Handler: string;
|
736
749
|
Trigger: string;
|
737
750
|
};
|
@@ -740,6 +753,7 @@ type OperationArgumentType = keyof OperationArgumentTypes;
|
|
740
753
|
type BaseOperationOptions = ReadonlyArray<{
|
741
754
|
operation: string;
|
742
755
|
args: ReadonlyArray<{
|
756
|
+
name: string;
|
743
757
|
type: OperationArgumentType;
|
744
758
|
default: any;
|
745
759
|
}>;
|
@@ -765,10 +779,12 @@ declare const OnClickOperationOptions: readonly [
|
|
765
779
|
readonly operation: "linkTo";
|
766
780
|
readonly args: readonly [
|
767
781
|
{
|
782
|
+
readonly name: "url";
|
768
783
|
readonly type: "Url";
|
769
784
|
readonly default: "";
|
770
785
|
},
|
771
786
|
{
|
787
|
+
readonly name: "open_new_tab";
|
772
788
|
readonly type: "BooleanKeyword";
|
773
789
|
readonly default: true;
|
774
790
|
}
|
@@ -778,6 +794,7 @@ declare const OnClickOperationOptions: readonly [
|
|
778
794
|
readonly operation: "moveTo";
|
779
795
|
readonly args: readonly [
|
780
796
|
{
|
797
|
+
readonly name: "state";
|
781
798
|
readonly type: "TransitState";
|
782
799
|
readonly default: "/";
|
783
800
|
}
|
@@ -787,6 +804,7 @@ declare const OnClickOperationOptions: readonly [
|
|
787
804
|
readonly operation: "closeApp";
|
788
805
|
readonly args: readonly [
|
789
806
|
{
|
807
|
+
readonly name: "trigger";
|
790
808
|
readonly type: "Trigger";
|
791
809
|
readonly default: "button";
|
792
810
|
}
|
@@ -796,6 +814,7 @@ declare const OnClickOperationOptions: readonly [
|
|
796
814
|
readonly operation: "runScript";
|
797
815
|
readonly args: readonly [
|
798
816
|
{
|
817
|
+
readonly name: "handler";
|
799
818
|
readonly type: "Handler";
|
800
819
|
readonly default: "";
|
801
820
|
}
|
@@ -805,10 +824,71 @@ declare const OnClickOperationOptions: readonly [
|
|
805
824
|
readonly operation: "submitForm";
|
806
825
|
readonly args: readonly [
|
807
826
|
{
|
827
|
+
readonly name: "state";
|
808
828
|
readonly type: "TransitState";
|
809
829
|
readonly default: "/";
|
810
830
|
}
|
811
831
|
];
|
832
|
+
},
|
833
|
+
{
|
834
|
+
readonly operation: "bootChat";
|
835
|
+
readonly args: readonly [
|
836
|
+
{
|
837
|
+
readonly name: "hide_launcher";
|
838
|
+
readonly type: "BooleanKeyword";
|
839
|
+
readonly default: false;
|
840
|
+
},
|
841
|
+
{
|
842
|
+
readonly name: "placement_pc";
|
843
|
+
readonly type: "StringKeyword";
|
844
|
+
readonly default: "left";
|
845
|
+
},
|
846
|
+
{
|
847
|
+
readonly name: "placement_mobile";
|
848
|
+
readonly type: "StringKeyword";
|
849
|
+
readonly default: "left";
|
850
|
+
},
|
851
|
+
{
|
852
|
+
readonly name: "horizontal_spacing_pc";
|
853
|
+
readonly type: "NumberKeyword";
|
854
|
+
readonly default: 20;
|
855
|
+
},
|
856
|
+
{
|
857
|
+
readonly name: "horizontal_spacing_mobile";
|
858
|
+
readonly type: "NumberKeyword";
|
859
|
+
readonly default: 20;
|
860
|
+
},
|
861
|
+
{
|
862
|
+
readonly name: "vertical_spacing_pc";
|
863
|
+
readonly type: "NumberKeyword";
|
864
|
+
readonly default: 20;
|
865
|
+
},
|
866
|
+
{
|
867
|
+
readonly name: "vertical_spacing_mobile";
|
868
|
+
readonly type: "NumberKeyword";
|
869
|
+
readonly default: 20;
|
870
|
+
},
|
871
|
+
{
|
872
|
+
readonly name: "theme_color";
|
873
|
+
readonly type: "Color";
|
874
|
+
readonly default: "#2aab9f";
|
875
|
+
},
|
876
|
+
{
|
877
|
+
readonly name: "header_title";
|
878
|
+
readonly type: "StringKeyword";
|
879
|
+
readonly default: "KARTE\u30B5\u30DD\u30FC\u30C8\u30C1\u30FC\u30E0";
|
880
|
+
},
|
881
|
+
{
|
882
|
+
readonly name: "header_description";
|
883
|
+
readonly type: "StringKeyword";
|
884
|
+
readonly default: "\u3054\u8CEA\u554F\u304C\u3042\u308C\u3070\u304A\u5C0B\u306D\u304F\u3060\u3055\u3044\u3002\nKARTE\u30B5\u30DD\u30FC\u30C8\u62C5\u5F53\u8005\u306B\u3064\u306A\u304C\u308A\u307E\u3059\u3002\u30B5\u30DD\u30FC\u30C8\u53D7\u4ED8\u6642\u9593\u306F\u5E73\u65E510:30-17:30\u3067\u3059\u3002";
|
885
|
+
},
|
886
|
+
{
|
887
|
+
readonly name: "launcher_image";
|
888
|
+
readonly type: "StringKeyword";
|
889
|
+
readonly default: "";
|
890
|
+
}
|
891
|
+
];
|
812
892
|
}
|
813
893
|
];
|
814
894
|
/** @internal */
|
@@ -1397,15 +1477,6 @@ declare namespace widget {
|
|
1397
1477
|
type ActionVariables = {
|
1398
1478
|
[key: string]: any;
|
1399
1479
|
};
|
1400
|
-
/**
|
1401
|
-
* アクション設定
|
1402
|
-
*
|
1403
|
-
* @public
|
1404
|
-
*/
|
1405
|
-
type ActionSetting = {
|
1406
|
-
send?: (event_name: string, values?: any) => void;
|
1407
|
-
initialState?: string;
|
1408
|
-
};
|
1409
1480
|
/**
|
1410
1481
|
* アクションの send 関数
|
1411
1482
|
*
|
@@ -1418,6 +1489,16 @@ declare namespace widget {
|
|
1418
1489
|
* @public
|
1419
1490
|
*/
|
1420
1491
|
type PublishFunction = (topic: string, values?: any) => void;
|
1492
|
+
/**
|
1493
|
+
* アクション設定
|
1494
|
+
*
|
1495
|
+
* @public
|
1496
|
+
*/
|
1497
|
+
type ActionSetting = {
|
1498
|
+
send?: SendFunction;
|
1499
|
+
publish?: PublishFunction;
|
1500
|
+
initialState?: string;
|
1501
|
+
};
|
1421
1502
|
/**
|
1422
1503
|
* アクションのライフサイクル changeState で呼び出されるフック関数
|
1423
1504
|
*
|
@@ -1512,6 +1593,10 @@ declare namespace widget {
|
|
1512
1593
|
karteTemplate?: {
|
1513
1594
|
[key: string]: any;
|
1514
1595
|
};
|
1596
|
+
/**
|
1597
|
+
* アクション実行時のコンテキスト
|
1598
|
+
*/
|
1599
|
+
context: ActionRunnerContext;
|
1515
1600
|
}
|
1516
1601
|
/**
|
1517
1602
|
* KARTE のシステム設定情報
|
@@ -1534,6 +1619,13 @@ declare namespace widget {
|
|
1534
1619
|
name: string;
|
1535
1620
|
values?: any;
|
1536
1621
|
};
|
1622
|
+
/**
|
1623
|
+
* アクション実行時のコンテキスト
|
1624
|
+
*/
|
1625
|
+
type ActionRunnerContext = {
|
1626
|
+
api_key: string;
|
1627
|
+
target?: "web" | "native";
|
1628
|
+
};
|
1537
1629
|
type ActionTableResult = number | string | boolean | Date | null | undefined;
|
1538
1630
|
type ActionTableQueryParam = string | number | boolean | Date;
|
1539
1631
|
type ActionTableQueryParams = {
|
package/dist/index.es.js
CHANGED
@@ -344,10 +344,12 @@ const OnClickOperationOptions = [
|
|
344
344
|
operation: 'linkTo',
|
345
345
|
args: [
|
346
346
|
{
|
347
|
+
name: 'url',
|
347
348
|
type: 'Url',
|
348
349
|
default: '',
|
349
350
|
},
|
350
351
|
{
|
352
|
+
name: 'open_new_tab',
|
351
353
|
type: 'BooleanKeyword',
|
352
354
|
default: true,
|
353
355
|
},
|
@@ -357,6 +359,7 @@ const OnClickOperationOptions = [
|
|
357
359
|
operation: 'moveTo',
|
358
360
|
args: [
|
359
361
|
{
|
362
|
+
name: 'state',
|
360
363
|
type: 'TransitState',
|
361
364
|
default: '/',
|
362
365
|
},
|
@@ -366,6 +369,7 @@ const OnClickOperationOptions = [
|
|
366
369
|
operation: 'closeApp',
|
367
370
|
args: [
|
368
371
|
{
|
372
|
+
name: 'trigger',
|
369
373
|
type: 'Trigger',
|
370
374
|
default: 'button',
|
371
375
|
},
|
@@ -375,6 +379,7 @@ const OnClickOperationOptions = [
|
|
375
379
|
operation: 'runScript',
|
376
380
|
args: [
|
377
381
|
{
|
382
|
+
name: 'handler',
|
378
383
|
type: 'Handler',
|
379
384
|
default: '',
|
380
385
|
},
|
@@ -384,11 +389,73 @@ const OnClickOperationOptions = [
|
|
384
389
|
operation: 'submitForm',
|
385
390
|
args: [
|
386
391
|
{
|
392
|
+
name: 'state',
|
387
393
|
type: 'TransitState',
|
388
394
|
default: '/',
|
389
395
|
},
|
390
396
|
],
|
391
397
|
},
|
398
|
+
{
|
399
|
+
operation: 'bootChat',
|
400
|
+
args: [
|
401
|
+
{
|
402
|
+
name: 'hide_launcher',
|
403
|
+
type: 'BooleanKeyword',
|
404
|
+
default: false,
|
405
|
+
},
|
406
|
+
{
|
407
|
+
name: 'placement_pc',
|
408
|
+
type: 'StringKeyword',
|
409
|
+
default: 'left',
|
410
|
+
},
|
411
|
+
{
|
412
|
+
name: 'placement_mobile',
|
413
|
+
type: 'StringKeyword',
|
414
|
+
default: 'left',
|
415
|
+
},
|
416
|
+
{
|
417
|
+
name: 'horizontal_spacing_pc',
|
418
|
+
type: 'NumberKeyword',
|
419
|
+
default: 20,
|
420
|
+
},
|
421
|
+
{
|
422
|
+
name: 'horizontal_spacing_mobile',
|
423
|
+
type: 'NumberKeyword',
|
424
|
+
default: 20,
|
425
|
+
},
|
426
|
+
{
|
427
|
+
name: 'vertical_spacing_pc',
|
428
|
+
type: 'NumberKeyword',
|
429
|
+
default: 20,
|
430
|
+
},
|
431
|
+
{
|
432
|
+
name: 'vertical_spacing_mobile',
|
433
|
+
type: 'NumberKeyword',
|
434
|
+
default: 20,
|
435
|
+
},
|
436
|
+
{
|
437
|
+
name: 'theme_color',
|
438
|
+
type: 'Color',
|
439
|
+
default: '#2aab9f',
|
440
|
+
},
|
441
|
+
{
|
442
|
+
name: 'header_title',
|
443
|
+
type: 'StringKeyword',
|
444
|
+
default: 'KARTEサポートチーム',
|
445
|
+
},
|
446
|
+
{
|
447
|
+
name: 'header_description',
|
448
|
+
type: 'StringKeyword',
|
449
|
+
default: `ご質問があればお尋ねください。
|
450
|
+
KARTEサポート担当者につながります。サポート受付時間は平日10:30-17:30です。`,
|
451
|
+
},
|
452
|
+
{
|
453
|
+
name: 'launcher_image',
|
454
|
+
type: 'StringKeyword',
|
455
|
+
default: '',
|
456
|
+
},
|
457
|
+
],
|
458
|
+
},
|
392
459
|
];
|
393
460
|
/** @internal */
|
394
461
|
const LengthUnits = ['px', 'em', 'rem', 'vw', 'fr', '%'];
|
@@ -568,6 +635,28 @@ function getSystem() {
|
|
568
635
|
function setSystem(config) {
|
569
636
|
system.set(config);
|
570
637
|
}
|
638
|
+
/**
|
639
|
+
* アクション実行時のコンテキストを保存するストア
|
640
|
+
*
|
641
|
+
* @internal
|
642
|
+
*/
|
643
|
+
const actionRunnerContext = writable(null);
|
644
|
+
/**
|
645
|
+
* アクション実行時のコンテキストを取得する
|
646
|
+
*
|
647
|
+
* @internal
|
648
|
+
*/
|
649
|
+
function getActionRunnerContext() {
|
650
|
+
return get(actionRunnerContext);
|
651
|
+
}
|
652
|
+
/**
|
653
|
+
* アクション実行時のコンテキストを保存する
|
654
|
+
*
|
655
|
+
* @internal
|
656
|
+
*/
|
657
|
+
function setActionRunnerContext(value) {
|
658
|
+
return actionRunnerContext.set(value);
|
659
|
+
}
|
571
660
|
/**
|
572
661
|
* Store to handle current state ID
|
573
662
|
*
|
@@ -1016,6 +1105,11 @@ const send_event = (event_name, values) => {
|
|
1016
1105
|
setting?.send?.(event_name, values);
|
1017
1106
|
};
|
1018
1107
|
/** @internal */
|
1108
|
+
const publish_edge = (topic, values) => {
|
1109
|
+
const setting = getSetting();
|
1110
|
+
setting?.publish?.(topic, values);
|
1111
|
+
};
|
1112
|
+
/** @internal */
|
1019
1113
|
const initialize = (setting) => {
|
1020
1114
|
const newSetting = setSetting(setting);
|
1021
1115
|
if (newSetting.initialState) {
|
@@ -1497,6 +1591,7 @@ function createModal(App, options = {
|
|
1497
1591
|
variables: {},
|
1498
1592
|
localVariablesQuery: undefined,
|
1499
1593
|
karteTemplate: {},
|
1594
|
+
context: { api_key: '' },
|
1500
1595
|
}) {
|
1501
1596
|
let app = null;
|
1502
1597
|
const data = {
|
@@ -1723,6 +1818,7 @@ function createApp(App, options = {
|
|
1723
1818
|
props: {},
|
1724
1819
|
variables: {},
|
1725
1820
|
localVariablesQuery: undefined,
|
1821
|
+
context: { api_key: '' },
|
1726
1822
|
}) {
|
1727
1823
|
let app = null;
|
1728
1824
|
const close = () => {
|
@@ -1802,6 +1898,7 @@ async function runScript$1(options = {
|
|
1802
1898
|
variables: {},
|
1803
1899
|
localVariablesQuery: undefined,
|
1804
1900
|
karteTemplate: {},
|
1901
|
+
context: { api_key: '' },
|
1805
1902
|
}) {
|
1806
1903
|
if (!options.onCreate)
|
1807
1904
|
return;
|
@@ -1912,6 +2009,7 @@ function create(App, options = {
|
|
1912
2009
|
variables: {},
|
1913
2010
|
localVariablesQuery: undefined,
|
1914
2011
|
karteTemplate: {},
|
2012
|
+
context: { api_key: '' },
|
1915
2013
|
}) {
|
1916
2014
|
const data = {
|
1917
2015
|
...options.props,
|
@@ -1943,6 +2041,7 @@ function create(App, options = {
|
|
1943
2041
|
shortenId: data.shorten_id || null,
|
1944
2042
|
campaignId: data.campaign_id || null,
|
1945
2043
|
});
|
2044
|
+
setActionRunnerContext(options.context);
|
1946
2045
|
window.addEventListener(ACTION_DESTROY_EVENT, handleDestroy);
|
1947
2046
|
window.addEventListener('beforeunload', dispatchDestroyEvent, false);
|
1948
2047
|
let modalCleanup = NOOP;
|
@@ -2747,6 +2846,7 @@ const moveTo = (to) => () => {
|
|
2747
2846
|
};
|
2748
2847
|
/** @internal */
|
2749
2848
|
const linkTo = (to, targetBlank = true) => () => {
|
2849
|
+
const { target } = getActionRunnerContext() ?? {};
|
2750
2850
|
async function sleep(ms) {
|
2751
2851
|
return new Promise(resolve => setTimeout(resolve, ms));
|
2752
2852
|
}
|
@@ -2755,11 +2855,12 @@ const linkTo = (to, targetBlank = true) => () => {
|
|
2755
2855
|
// # edge.js の retransmitter が送るのを待つ
|
2756
2856
|
await sleep(450);
|
2757
2857
|
}
|
2758
|
-
|
2858
|
+
const isRequiredWindowOpen = target === 'native' || targetBlank;
|
2859
|
+
if (isRequiredWindowOpen) {
|
2759
2860
|
window.open(to);
|
2760
2861
|
}
|
2761
2862
|
Promise.race([_send(), sleep(650)]).then(() => {
|
2762
|
-
if (!
|
2863
|
+
if (!isRequiredWindowOpen) {
|
2763
2864
|
location.href = to;
|
2764
2865
|
}
|
2765
2866
|
});
|
@@ -2788,6 +2889,24 @@ const submitForm = (to) => () => {
|
|
2788
2889
|
_moveTo(to);
|
2789
2890
|
};
|
2790
2891
|
/** @internal */
|
2892
|
+
const bootChat = (hide_launcher, placement_pc, placement_mobile, horizontal_spacing_pc, horizontal_spacing_mobile, vertical_spacing_pc, vertical_spacing_mobile, theme_color, header_title, header_description, launcher_image) => () => {
|
2893
|
+
const options = {
|
2894
|
+
hide_launcher,
|
2895
|
+
placement_pc,
|
2896
|
+
placement_mobile,
|
2897
|
+
horizontal_spacing_pc,
|
2898
|
+
horizontal_spacing_mobile,
|
2899
|
+
vertical_spacing_pc,
|
2900
|
+
vertical_spacing_mobile,
|
2901
|
+
theme_color,
|
2902
|
+
header_title,
|
2903
|
+
header_description: header_description.replace(/<br\s*\/?>/gi, '\n'),
|
2904
|
+
};
|
2905
|
+
if (launcher_image && launcher_image !== '')
|
2906
|
+
options.launcher_image = launcher_image;
|
2907
|
+
publish_edge('talk', { actionName: 'boot', args: [options] });
|
2908
|
+
};
|
2909
|
+
/** @internal */
|
2791
2910
|
const execOnClickOperation = (onClickOperation) => {
|
2792
2911
|
if (onClickOperation.operation === 'linkTo') {
|
2793
2912
|
linkTo(...onClickOperation.args)();
|
@@ -2804,6 +2923,9 @@ const execOnClickOperation = (onClickOperation) => {
|
|
2804
2923
|
else if (onClickOperation.operation === 'submitForm') {
|
2805
2924
|
submitForm(onClickOperation.args[0])();
|
2806
2925
|
}
|
2926
|
+
else if (onClickOperation.operation === 'bootChat') {
|
2927
|
+
bootChat(...onClickOperation.args)();
|
2928
|
+
}
|
2807
2929
|
};
|
2808
2930
|
/** @internal */
|
2809
2931
|
const haveFunction = (onClickOperation) => {
|
package/dist/templates.cjs.js
CHANGED
@@ -100,7 +100,7 @@ import { props, localVariablesQuery, karteTemplate } from './gen';
|
|
100
100
|
import App from './App.svelte';
|
101
101
|
import onCreate from './customScript';
|
102
102
|
${script}
|
103
|
-
const action = (options: { send: Send; publish: Publish, props: Props; variables: Variables }): KarteAction => {
|
103
|
+
const action = (options: { send: Send; publish: Publish, props: Props; variables: Variables, context: any }): KarteAction => {
|
104
104
|
return create(App, {
|
105
105
|
props,
|
106
106
|
send: options.send,
|
@@ -109,6 +109,7 @@ const action = (options: { send: Send; publish: Publish, props: Props; variables
|
|
109
109
|
localVariablesQuery,
|
110
110
|
karteTemplate,
|
111
111
|
onCreate,
|
112
|
+
context: options.context,
|
112
113
|
});
|
113
114
|
};
|
114
115
|
|
package/dist/templates.js
CHANGED
@@ -98,7 +98,7 @@ import { props, localVariablesQuery, karteTemplate } from './gen';
|
|
98
98
|
import App from './App.svelte';
|
99
99
|
import onCreate from './customScript';
|
100
100
|
${script}
|
101
|
-
const action = (options: { send: Send; publish: Publish, props: Props; variables: Variables }): KarteAction => {
|
101
|
+
const action = (options: { send: Send; publish: Publish, props: Props; variables: Variables, context: any }): KarteAction => {
|
102
102
|
return create(App, {
|
103
103
|
props,
|
104
104
|
send: options.send,
|
@@ -107,6 +107,7 @@ const action = (options: { send: Send; publish: Publish, props: Props; variables
|
|
107
107
|
localVariablesQuery,
|
108
108
|
karteTemplate,
|
109
109
|
onCreate,
|
110
|
+
context: options.context,
|
110
111
|
});
|
111
112
|
};
|
112
113
|
|