@plaidev/karte-action-sdk 1.1.123 → 1.1.124-27946655.bba7dcb4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/hydrate/index.es.d.ts +191 -62
- package/dist/hydrate/index.es.js +110 -94
- package/dist/index.es.d.ts +191 -62
- package/dist/index.es.js +122 -95
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
@@ -6,10 +6,6 @@ import { setContext, getContext, createEventDispatcher, onMount, onDestroy as on
|
|
6
6
|
/** @internal */
|
7
7
|
const NOOP = (_args) => { }; // eslint-disable-line @typescript-eslint/no-unused-vars
|
8
8
|
/** @internal */
|
9
|
-
const isPreview = () => {
|
10
|
-
return false;
|
11
|
-
};
|
12
|
-
/** @internal */
|
13
9
|
const handleFocus = (node) => (e) => {
|
14
10
|
if (node) {
|
15
11
|
// trap focus
|
@@ -292,13 +288,11 @@ const state = writable('/');
|
|
292
288
|
* 現在のステートを設定する
|
293
289
|
*
|
294
290
|
* @param stateId - 表示するステートID
|
295
|
-
* @param
|
291
|
+
* @param options - オプション。`options.disableInPreview`でプレビュー時のステート遷移を無効化できます。
|
296
292
|
*
|
297
293
|
* @public
|
298
294
|
*/
|
299
|
-
function setState$1(stateId,
|
300
|
-
if (!force && isPreview())
|
301
|
-
return;
|
295
|
+
function setState$1(stateId, options) {
|
302
296
|
state.set(stateId);
|
303
297
|
}
|
304
298
|
/**
|
@@ -703,15 +697,14 @@ const ACTION_CHANGE_STATE_EVENT = `KARTE-ACTION-CHANGE-STATE-${actionId}`;
|
|
703
697
|
/** @internal */
|
704
698
|
const handleState = (event) => {
|
705
699
|
if (event.detail.actionId === actionId || event.detail.actionId === ALL_ACTION_ID) {
|
706
|
-
setState$1(event.detail.to, event.detail.
|
700
|
+
setState$1(event.detail.to, { disableInPreview: event.detail.disableInPreview });
|
707
701
|
}
|
708
702
|
};
|
709
703
|
/** @internal */
|
710
704
|
const initialize = (setting) => {
|
711
705
|
const newSetting = setActionSetting(setting);
|
712
706
|
if (newSetting.initialState) {
|
713
|
-
|
714
|
-
setState$1(setting?.initialState, force);
|
707
|
+
setState$1(setting?.initialState);
|
715
708
|
}
|
716
709
|
if (newSetting.autoStart) {
|
717
710
|
setStopped(!newSetting.autoStart);
|
@@ -962,9 +955,15 @@ const setAutoStart = (on = true) => {
|
|
962
955
|
const MESSAGES_LIMIT = 1000;
|
963
956
|
const EVENTS_LIMIT = 1000;
|
964
957
|
// 実行ログ
|
965
|
-
let
|
958
|
+
let logs = [];
|
966
959
|
// KARTEイベント
|
967
960
|
let events = [];
|
961
|
+
function getLogs() {
|
962
|
+
return logs;
|
963
|
+
}
|
964
|
+
function getEvents() {
|
965
|
+
return events;
|
966
|
+
}
|
968
967
|
// iframe内の場合は親windowを参照する
|
969
968
|
function w(w) {
|
970
969
|
return w.parent === w ? w : w.parent;
|
@@ -987,7 +986,6 @@ const logger = {
|
|
987
986
|
},
|
988
987
|
warn: (...messages) => {
|
989
988
|
const log = { level: 'warn', message: formatLog(messages), date: new Date() };
|
990
|
-
console.log('aaaaaaaaa', w);
|
991
989
|
w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
|
992
990
|
},
|
993
991
|
event: (name, values) => {
|
@@ -1014,18 +1012,18 @@ function listenLogger() {
|
|
1014
1012
|
return;
|
1015
1013
|
}
|
1016
1014
|
if (detail.method === 'clear') {
|
1017
|
-
|
1015
|
+
logs = [];
|
1018
1016
|
}
|
1019
1017
|
else if (detail.method === 'clearEvents') {
|
1020
1018
|
events = [];
|
1021
1019
|
}
|
1022
1020
|
else if (detail.method === 'log') {
|
1023
|
-
if (MESSAGES_LIMIT <=
|
1024
|
-
|
1021
|
+
if (MESSAGES_LIMIT <= logs.length) {
|
1022
|
+
logs.shift();
|
1025
1023
|
}
|
1026
1024
|
const { level, message } = detail.log;
|
1027
1025
|
const log = { level, message, date: new Date() };
|
1028
|
-
|
1026
|
+
logs.push(log);
|
1029
1027
|
}
|
1030
1028
|
else if (detail.method === 'event') {
|
1031
1029
|
if (EVENTS_LIMIT <= events.length) {
|
@@ -1487,6 +1485,103 @@ const FormRatingButtonTypes = ['star', 'face'];
|
|
1487
1485
|
/** @internal */
|
1488
1486
|
const DefaultFormRatingButtonType = 'star';
|
1489
1487
|
|
1488
|
+
const DEFAULT_COLLECTION_ENDPOINT = typeof __FLYER_GEN_COLLECTION_API_ENDPOINT__ === 'string'
|
1489
|
+
? __FLYER_GEN_COLLECTION_API_ENDPOINT__
|
1490
|
+
: 'https://t.karte.io/collection';
|
1491
|
+
/**
|
1492
|
+
* アクションテーブルを管理するメソッドを取得する
|
1493
|
+
*
|
1494
|
+
* @param config - 設定情報
|
1495
|
+
*
|
1496
|
+
* @returns メソッドを返します
|
1497
|
+
*
|
1498
|
+
* @public
|
1499
|
+
*/
|
1500
|
+
function collection$1(config) {
|
1501
|
+
const endpoint = config.endpoint || DEFAULT_COLLECTION_ENDPOINT;
|
1502
|
+
const api_key = config.api_key;
|
1503
|
+
const table = config.table;
|
1504
|
+
return {
|
1505
|
+
get(key, cb) {
|
1506
|
+
if (Array.isArray(key)) {
|
1507
|
+
return request(`${endpoint}/getByKeys`, {
|
1508
|
+
api_key,
|
1509
|
+
name: table,
|
1510
|
+
keys: key,
|
1511
|
+
}, cb);
|
1512
|
+
}
|
1513
|
+
else {
|
1514
|
+
request(`${endpoint}/getByKey`, {
|
1515
|
+
api_key,
|
1516
|
+
name: table,
|
1517
|
+
key,
|
1518
|
+
}, cb);
|
1519
|
+
}
|
1520
|
+
},
|
1521
|
+
getByQuery(query_name, params, options, cb) {
|
1522
|
+
request(`${endpoint}/getByQuery`, {
|
1523
|
+
api_key,
|
1524
|
+
name: table,
|
1525
|
+
query_name,
|
1526
|
+
params,
|
1527
|
+
options,
|
1528
|
+
}, cb);
|
1529
|
+
},
|
1530
|
+
set(key, value, cb) {
|
1531
|
+
request(`${endpoint}/set`, {
|
1532
|
+
api_key,
|
1533
|
+
name: table,
|
1534
|
+
key,
|
1535
|
+
value,
|
1536
|
+
}, cb);
|
1537
|
+
},
|
1538
|
+
};
|
1539
|
+
}
|
1540
|
+
function request(url, data, cb) {
|
1541
|
+
fetch(url, {
|
1542
|
+
method: 'POST',
|
1543
|
+
headers: {
|
1544
|
+
'Content-Type': 'text/plain;charset=UTF-8',
|
1545
|
+
},
|
1546
|
+
body: JSON.stringify({ ...data }),
|
1547
|
+
}).then(response => {
|
1548
|
+
if (!response.ok) {
|
1549
|
+
return cb(new Error(`fail to request collection api. reason: ${response.status}`));
|
1550
|
+
}
|
1551
|
+
return cb(null, response.json());
|
1552
|
+
});
|
1553
|
+
}
|
1554
|
+
const loadActionTableRow = async (config, api_key, endpoint) => {
|
1555
|
+
return new Promise((resolve, reject) => collection$1({ endpoint, api_key, table: config.default.table_name }).get(config.default.key, (err, data) => (err ? reject(err) : resolve(data))));
|
1556
|
+
};
|
1557
|
+
const loadActionTableRows = async (config, api_key, endpoint) => {
|
1558
|
+
return new Promise((resolve, reject) => collection$1({ endpoint, api_key, table: config.default.table_name }).get(config.default.key, (err, data) => (err ? reject(err) : resolve(data))));
|
1559
|
+
};
|
1560
|
+
const loadActionTableQuery = async (config, api_key, endpoint) => {
|
1561
|
+
return new Promise((resolve, reject) => collection$1({ endpoint, api_key, table: config.default.table_name }).getByQuery(config.default.query_name, config.default.params, null, (err, data) => (err ? reject(err) : resolve(data))));
|
1562
|
+
};
|
1563
|
+
const loadActionTable = async (config, api_key, endpoint) => {
|
1564
|
+
const results = await Promise.all(config
|
1565
|
+
.filter(c => c.resolver === 'action-table-row' ||
|
1566
|
+
c.resolver === 'action-table-rows' ||
|
1567
|
+
c.resolver === 'action-table-query')
|
1568
|
+
.map(c => {
|
1569
|
+
if (c.resolver === 'action-table-row') {
|
1570
|
+
loadActionTableRow(c, api_key, endpoint);
|
1571
|
+
}
|
1572
|
+
else if (c.resolver === 'action-table-rows') {
|
1573
|
+
loadActionTableRows(c, api_key, endpoint);
|
1574
|
+
}
|
1575
|
+
else if (c.resolver === 'action-table-query') {
|
1576
|
+
loadActionTableQuery(c, api_key, endpoint);
|
1577
|
+
}
|
1578
|
+
}));
|
1579
|
+
return config.reduce((acc, c, i) => {
|
1580
|
+
acc[c.name] = results[i];
|
1581
|
+
return acc;
|
1582
|
+
}, {});
|
1583
|
+
};
|
1584
|
+
|
1490
1585
|
/**
|
1491
1586
|
* アクションが作成 (create) される前にフックする関数
|
1492
1587
|
*
|
@@ -1576,6 +1671,7 @@ function create(App, options = {
|
|
1576
1671
|
send: () => { },
|
1577
1672
|
props: {},
|
1578
1673
|
variables: {},
|
1674
|
+
localVariablesQuery: undefined,
|
1579
1675
|
}) {
|
1580
1676
|
let app = null;
|
1581
1677
|
const data = {
|
@@ -1588,7 +1684,7 @@ function create(App, options = {
|
|
1588
1684
|
// NOTE: onCreateより前にListenする必要がある
|
1589
1685
|
window.addEventListener(ACTION_DESTROY_EVENT, () => {
|
1590
1686
|
const { onDestroyHandlers } = getInternalHandlers();
|
1591
|
-
onDestroyHandlers
|
1687
|
+
onDestroyHandlers?.forEach(h => h(actionProps));
|
1592
1688
|
// 複数回onDestroyを呼ばないようにする処理
|
1593
1689
|
window.removeEventListener('beforeunload', dispatchDestroyEvent);
|
1594
1690
|
});
|
@@ -1599,6 +1695,10 @@ function create(App, options = {
|
|
1599
1695
|
shortenId: data.shorten_id || null,
|
1600
1696
|
campaignId: data.campaign_id || null,
|
1601
1697
|
});
|
1698
|
+
// ActionTable APIへの非同期リクエスト
|
1699
|
+
if (options.localVariablesQuery && data.api_key) {
|
1700
|
+
loadActionTable(options.localVariablesQuery, data.api_key).then(result => setCustomVariables(result));
|
1701
|
+
}
|
1602
1702
|
const close = (trigger = 'none') => {
|
1603
1703
|
if (!app) {
|
1604
1704
|
return;
|
@@ -1837,7 +1937,7 @@ function createFog({ color = '#000', opacity = '50%', zIndex = 999, onclick, })
|
|
1837
1937
|
*/
|
1838
1938
|
function getActionShadowRoot() {
|
1839
1939
|
const root = document.querySelector(`.${KARTE_ACTION_ROOT}[data-${KARTE_ACTION_RID}='${actionId}']`);
|
1840
|
-
if (!root
|
1940
|
+
if (!root?.shadowRoot) {
|
1841
1941
|
return null;
|
1842
1942
|
}
|
1843
1943
|
return root.shadowRoot;
|
@@ -1870,7 +1970,7 @@ async function fixFontFaceIssue(href, cssRules) {
|
|
1870
1970
|
const rules = [];
|
1871
1971
|
const fixedRules = [];
|
1872
1972
|
Array.from(css.cssRules).forEach(cssRule => {
|
1873
|
-
if (cssRule.type
|
1973
|
+
if (cssRule.type !== 5) {
|
1874
1974
|
rules.push(cssRule.cssText);
|
1875
1975
|
}
|
1876
1976
|
// type 5 is @font-face
|
@@ -1980,6 +2080,7 @@ function createApp(App, options = {
|
|
1980
2080
|
send: () => { },
|
1981
2081
|
props: {},
|
1982
2082
|
variables: {},
|
2083
|
+
localVariablesQuery: undefined,
|
1983
2084
|
}) {
|
1984
2085
|
let app = null;
|
1985
2086
|
const close = () => {
|
@@ -2015,80 +2116,6 @@ function createApp(App, options = {
|
|
2015
2116
|
};
|
2016
2117
|
}
|
2017
2118
|
|
2018
|
-
const DEFAULT_COLLECTION_ENDPOINT = typeof __FLYER_GEN_COLLECTION_API_ENDPOINT__ === 'string'
|
2019
|
-
? __FLYER_GEN_COLLECTION_API_ENDPOINT__
|
2020
|
-
: 'https://t.karte.io/collection';
|
2021
|
-
/**
|
2022
|
-
* アクションテーブルを管理するメソッドを取得する
|
2023
|
-
*
|
2024
|
-
* @param config - 設定情報
|
2025
|
-
*
|
2026
|
-
* @returns メソッドを返します
|
2027
|
-
*
|
2028
|
-
* @public
|
2029
|
-
*/
|
2030
|
-
function collection$1(config) {
|
2031
|
-
const endpoint = config.endpoint || DEFAULT_COLLECTION_ENDPOINT;
|
2032
|
-
const api_key = config.api_key;
|
2033
|
-
const table = config.table;
|
2034
|
-
return {
|
2035
|
-
get(key, cb) {
|
2036
|
-
if (Array.isArray(key)) {
|
2037
|
-
return request(`${endpoint}/getByKeys`, {
|
2038
|
-
api_key,
|
2039
|
-
name: table,
|
2040
|
-
keys: key,
|
2041
|
-
}, cb);
|
2042
|
-
}
|
2043
|
-
else {
|
2044
|
-
request(`${endpoint}/getByKey`, {
|
2045
|
-
api_key,
|
2046
|
-
name: table,
|
2047
|
-
key,
|
2048
|
-
}, cb);
|
2049
|
-
}
|
2050
|
-
},
|
2051
|
-
getByQuery(query_name, params, options, cb) {
|
2052
|
-
request(`${endpoint}/getByQuery`, {
|
2053
|
-
api_key,
|
2054
|
-
name: table,
|
2055
|
-
query_name,
|
2056
|
-
params,
|
2057
|
-
options,
|
2058
|
-
}, cb);
|
2059
|
-
},
|
2060
|
-
set(key, value, cb) {
|
2061
|
-
request(`${endpoint}/set`, {
|
2062
|
-
api_key,
|
2063
|
-
name: table,
|
2064
|
-
key,
|
2065
|
-
value,
|
2066
|
-
}, cb);
|
2067
|
-
},
|
2068
|
-
};
|
2069
|
-
}
|
2070
|
-
function request(url, data, cb) {
|
2071
|
-
const xhr = new XMLHttpRequest();
|
2072
|
-
xhr.onreadystatechange = () => {
|
2073
|
-
if (xhr.readyState != 4) {
|
2074
|
-
return;
|
2075
|
-
}
|
2076
|
-
if (xhr.status != 200) {
|
2077
|
-
return cb(new Error(`fail to send collection api request. reason: ${xhr.responseText}`));
|
2078
|
-
}
|
2079
|
-
try {
|
2080
|
-
data = JSON.parse(xhr.responseText);
|
2081
|
-
return cb(null, data);
|
2082
|
-
}
|
2083
|
-
catch (err) {
|
2084
|
-
return cb(err);
|
2085
|
-
}
|
2086
|
-
};
|
2087
|
-
xhr.open('POST', url);
|
2088
|
-
xhr.setRequestHeader('Content-Type', 'text/plain;charset=UTF-8');
|
2089
|
-
xhr.send(JSON.stringify({ ...data }));
|
2090
|
-
}
|
2091
|
-
|
2092
2119
|
/**
|
2093
2120
|
* Widget API 互換のインターフェース
|
2094
2121
|
*/
|
@@ -7887,4 +7914,4 @@ class ImageBlock extends SvelteComponent {
|
|
7887
7914
|
}
|
7888
7915
|
}
|
7889
7916
|
|
7890
|
-
export { Alignments, AnimationStyles, BackgroundSizes, ClipPaths, Cursors, DefaultFormButtonStyle, DefaultFormRatingButtonType, DefaultFormSelectStyle, DefaultListBackground, DefaultListBackgroundNone, DefaultListBackgroundStripe, DefaultListSeparator, DefaultListSeparatorBorder, DefaultListSeparatorGap, DefaultListSeparatorNone, DefaultModalPlacement, DefaultSlideButton, DefaultSlideNavigationButton, Directions, Elasticities, ElasticityStyle, EmbedElement, Flex, FlexItem, FormCheckBoxes, FormRadioButtons, FormRatingButtonTypes, FormRatingButtons, FormSelect, FormTextarea, Grid, GridItem, GridModalState, ImageBlock, ImageElement, Justifies, KARTE_MODAL_ROOT, LengthUnits, List, ListBackgroundTypes, ListDirections, ListItem, ListSeparatorTypes, MediaQueries, Modal, ModalPositions, MovieVimeoElement, MovieYouTubeElement, ObjectFits, OnClickOperationOptions, Overflows, PropTypes, Repeats, Slide, SlideItem, State, StateItem, TextBlock, TextButtonBlock, TextButtonElement, TextDirections, TextElement, WritingModes, applyCss, applyGlobalCss, close, closeAction, closed, collection$1 as collection, create, createApp, createFog, customHandlers, customVariables, destroy, destroyed, ensureModalRoot,
|
7917
|
+
export { Alignments, AnimationStyles, BackgroundSizes, ClipPaths, Cursors, DefaultFormButtonStyle, DefaultFormRatingButtonType, DefaultFormSelectStyle, DefaultListBackground, DefaultListBackgroundNone, DefaultListBackgroundStripe, DefaultListSeparator, DefaultListSeparatorBorder, DefaultListSeparatorGap, DefaultListSeparatorNone, DefaultModalPlacement, DefaultSlideButton, DefaultSlideNavigationButton, Directions, Elasticities, ElasticityStyle, EmbedElement, Flex, FlexItem, FormCheckBoxes, FormRadioButtons, FormRatingButtonTypes, FormRatingButtons, FormSelect, FormTextarea, Grid, GridItem, GridModalState, ImageBlock, ImageElement, Justifies, KARTE_MODAL_ROOT, LengthUnits, List, ListBackgroundTypes, ListDirections, ListItem, ListSeparatorTypes, MediaQueries, Modal, ModalPositions, MovieVimeoElement, MovieYouTubeElement, ObjectFits, OnClickOperationOptions, Overflows, PropTypes, Repeats, Slide, SlideItem, State, StateItem, TextBlock, TextButtonBlock, TextButtonElement, TextDirections, TextElement, WritingModes, applyCss, applyGlobalCss, close, closeAction, closed, collection$1 as collection, create, createApp, createFog, customHandlers, customVariables, destroy, destroyed, ensureModalRoot, finalize, formData, getActionShadowRoot, getCustomHandlers, getCustomVariables, getEvents, getLogs, getState$1 as getState, getStates, getStoreState, getSystem, hideOnScroll, hideOnTime, initialize, isClosed, isOpened, listenConsoleLogger, listenLogger, loadActionTable, loadActionTableQuery, loadActionTableRow, loadActionTableRows, loadGlobalScript, loadGlobalStyle, loadStyle, logger, onChangeState, onClose, onCreate, onDestroy, onScroll, onShow, onTime, opened, setActionSetting, setAutoStart, setClosed, setCustomHandlers, setCustomVariables, setState$1 as setState, show, showAction, showModal, showOnScroll, showOnTime, state, stopped, updateCustomHandlers, updateCustomVariables, widget };
|