@plaidev/karte-action-sdk 1.1.122 → 1.1.124

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.
@@ -878,6 +878,42 @@ declare function onScroll(rate: number | number[], fn: OnScrollFunction): () =>
878
878
  * @public
879
879
  */
880
880
  declare function onTime(time: number, fn: Function): () => void;
881
+ /**
882
+ * アクションのログの記録の管理
883
+ */
884
+ type LogLevel = "info" | "error" | "warn";
885
+ type Log = {
886
+ level: LogLevel;
887
+ message: string;
888
+ date?: Date;
889
+ };
890
+ type Event = {
891
+ name: string;
892
+ values?: any;
893
+ date?: Date;
894
+ };
895
+ declare function getLogs(): Log[];
896
+ declare function getEvents(): Event[];
897
+ /**
898
+ * ログを送信する関数群
899
+ */
900
+ declare const logger: {
901
+ info: (...messages: any[]) => void;
902
+ log: (...messages: any[]) => void;
903
+ error: (...messages: any[]) => void;
904
+ warn: (...messages: any[]) => void;
905
+ event: (name: string, values: any) => void;
906
+ clear: () => void;
907
+ clearEvents: () => void;
908
+ };
909
+ /**
910
+ * loggerのログを実行ログに表示する
911
+ */
912
+ declare function listenLogger(): () => void;
913
+ /**
914
+ * consoleログを実行ログに表示する
915
+ */
916
+ declare function listenConsoleLogger(): () => void;
881
917
  /**
882
918
  * プロパティ
883
919
  *
@@ -2840,8 +2876,8 @@ declare namespace widget {
2840
2876
  */
2841
2877
  export { showAction as show, closeAction as hide };
2842
2878
  }
2843
- export { loadGlobalScript, loadGlobalStyle, applyGlobalCss, initialize, finalize, setAutoStart, getState, setState, getStates, isOpened, getCustomVariables, setCustomVariables, updateCustomVariables, getCustomHandlers, setCustomHandlers, updateCustomHandlers, getSystem, setActionSetting, customHandlers, customVariables, formData, state, opened, closed, destroyed, stopped, isClosed, setClosed, getStoreState, onScroll, onTime, hideOnScroll, hideOnTime, showOnScroll, showOnTime, PropTypes, PropType, Code, MediaQueries, MediaQuery, Directions, Direction, AnimationStyles, AnimationStyle, ModalPositions, ModalPosition, ModalMargin, ModalPlacement, DefaultModalPlacement, Elasticities, Elasticity, ElasticityStyle, TextDirections, TextDirection, OperationArgumentType, Operation, OnClickOperationOptions, OnClickOperation, LongText, Url, Image, LengthUnits, LengthUnit, Length, Color, Justifies, Justify, Alignments, Alignment, ObjectFits, ObjectFit, ClipPaths, ClipPath, Repeats, Repeat, BackgroundSizes, BackgroundSize, Cursors, Cursor, Overflows, Overflow, Border, BorderStyle, BorderWidth, Style, StateName, WritingModes, WritingMode, ListSeparatorTypes, ListSeparatorNone, ListSeparatorBorder, ListSeparatorGap, ListSeparator, DefaultListSeparatorNone, DefaultListSeparatorBorder, DefaultListSeparatorGap, DefaultListSeparator, ListBackgroundTypes, ListBackgroundNone, ListBackgroundStripe, ListBackground, DefaultListBackgroundNone, DefaultListBackgroundStripe, DefaultListBackground, ListDirections, ListDirection, ListContext, SlideButtonIcon, SlideButtonText, SlideButton, DefaultSlideButton, SlideButtonPosition, SlideNavigationButton, DefaultSlideNavigationButton, FormInputName, FormButtonStyle, DefaultFormButtonStyle, FormSelectStyle, DefaultFormSelectStyle, FormRatingButtonType, FormRatingButtonTypes, DefaultFormRatingButtonType, create, destroy, closeAction, showAction, loadStyle, applyCss, getActionShadowRoot, onCreate, onShow, onClose, onDestroy, onChangeState, showModal, ensureModalRoot, show, close, createApp, createFog, KARTE_MODAL_ROOT, collection, widget };
2844
- export type { CloseTrigger, CustomVariables, ActionEventHandler, SystemConfig, OnScrollContext, OnScrollFunction, ScrollDirection, ActionProps, ActionOptions, ActionHook, ActionCloseHook, ActionChangeStateHook, SendFunction, CollectionConfig };
2879
+ export { loadGlobalScript, loadGlobalStyle, applyGlobalCss, initialize, finalize, setAutoStart, getState, setState, getStates, isOpened, getCustomVariables, setCustomVariables, updateCustomVariables, getCustomHandlers, setCustomHandlers, updateCustomHandlers, getSystem, setActionSetting, customHandlers, customVariables, formData, state, opened, closed, destroyed, stopped, isClosed, setClosed, getStoreState, onScroll, onTime, getLogs, getEvents, logger, listenLogger, listenConsoleLogger, hideOnScroll, hideOnTime, showOnScroll, showOnTime, PropTypes, PropType, Code, MediaQueries, MediaQuery, Directions, Direction, AnimationStyles, AnimationStyle, ModalPositions, ModalPosition, ModalMargin, ModalPlacement, DefaultModalPlacement, Elasticities, Elasticity, ElasticityStyle, TextDirections, TextDirection, OperationArgumentType, Operation, OnClickOperationOptions, OnClickOperation, LongText, Url, Image, LengthUnits, LengthUnit, Length, Color, Justifies, Justify, Alignments, Alignment, ObjectFits, ObjectFit, ClipPaths, ClipPath, Repeats, Repeat, BackgroundSizes, BackgroundSize, Cursors, Cursor, Overflows, Overflow, Border, BorderStyle, BorderWidth, Style, StateName, WritingModes, WritingMode, ListSeparatorTypes, ListSeparatorNone, ListSeparatorBorder, ListSeparatorGap, ListSeparator, DefaultListSeparatorNone, DefaultListSeparatorBorder, DefaultListSeparatorGap, DefaultListSeparator, ListBackgroundTypes, ListBackgroundNone, ListBackgroundStripe, ListBackground, DefaultListBackgroundNone, DefaultListBackgroundStripe, DefaultListBackground, ListDirections, ListDirection, ListContext, SlideButtonIcon, SlideButtonText, SlideButton, DefaultSlideButton, SlideButtonPosition, SlideNavigationButton, DefaultSlideNavigationButton, FormInputName, FormButtonStyle, DefaultFormButtonStyle, FormSelectStyle, DefaultFormSelectStyle, FormRatingButtonType, FormRatingButtonTypes, DefaultFormRatingButtonType, create, destroy, closeAction, showAction, loadStyle, applyCss, getActionShadowRoot, onCreate, onShow, onClose, onDestroy, onChangeState, showModal, ensureModalRoot, show, close, createApp, createFog, KARTE_MODAL_ROOT, collection, widget };
2880
+ export type { CloseTrigger, CustomVariables, ActionEventHandler, SystemConfig, OnScrollContext, OnScrollFunction, ScrollDirection, LogLevel, Log, Event, ActionProps, ActionOptions, ActionHook, ActionCloseHook, ActionChangeStateHook, SendFunction, CollectionConfig };
2845
2881
  export { default as State } from './components/State.svelte';
2846
2882
  export { default as StateItem } from './components/StateItem.svelte';
2847
2883
  export { default as Modal } from './components/Modal.svelte';
@@ -904,6 +904,162 @@ const setAutoStart = (on = true) => {
904
904
  setStopped();
905
905
  };
906
906
 
907
+ /**
908
+ * アクションのログの記録の管理
909
+ */
910
+ const MESSAGES_LIMIT = 1000;
911
+ const EVENTS_LIMIT = 1000;
912
+ // 実行ログ
913
+ let logs = [];
914
+ // KARTEイベント
915
+ let events = [];
916
+ function getLogs() {
917
+ return logs;
918
+ }
919
+ function getEvents() {
920
+ return events;
921
+ }
922
+ // iframe内の場合は親windowを参照する
923
+ function w(w) {
924
+ return w.parent === w ? w : w.parent;
925
+ }
926
+ /**
927
+ * ログを送信する関数群
928
+ */
929
+ const logger = {
930
+ info: (...messages) => {
931
+ const log = { level: 'info', message: formatLog(messages), date: new Date() };
932
+ w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
933
+ },
934
+ log: (...messages) => {
935
+ const log = { level: 'info', message: formatLog(messages), date: new Date() };
936
+ w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
937
+ },
938
+ error: (...messages) => {
939
+ const log = { level: 'error', message: formatLog(messages), date: new Date() };
940
+ w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
941
+ },
942
+ warn: (...messages) => {
943
+ const log = { level: 'warn', message: formatLog(messages), date: new Date() };
944
+ w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
945
+ },
946
+ event: (name, values) => {
947
+ const event = values ? { name, values, date: new Date() } : { name, date: new Date() };
948
+ w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'event', event } }, '*');
949
+ },
950
+ clear: () => {
951
+ w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'clear' } }, '*');
952
+ },
953
+ clearEvents: () => {
954
+ w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'clearEvents' } }, '*');
955
+ },
956
+ };
957
+ /**
958
+ * loggerのログを実行ログに表示する
959
+ */
960
+ function listenLogger() {
961
+ const handler = (event) => {
962
+ const { type, detail } = event.data;
963
+ if (event.origin !== location.origin) {
964
+ return;
965
+ }
966
+ if (type !== 'KARTE-ACTION-LOGGER') {
967
+ return;
968
+ }
969
+ if (detail.method === 'clear') {
970
+ logs = [];
971
+ }
972
+ else if (detail.method === 'clearEvents') {
973
+ events = [];
974
+ }
975
+ else if (detail.method === 'log') {
976
+ if (MESSAGES_LIMIT <= logs.length) {
977
+ logs.shift();
978
+ }
979
+ const { level, message } = detail.log;
980
+ const log = { level, message, date: new Date() };
981
+ logs.push(log);
982
+ }
983
+ else if (detail.method === 'event') {
984
+ if (EVENTS_LIMIT <= events.length) {
985
+ events.shift();
986
+ }
987
+ const { name, values } = detail.event;
988
+ const karteEvent = values
989
+ ? { name, values, date: new Date() }
990
+ : { name, date: new Date() };
991
+ events.push(karteEvent);
992
+ }
993
+ };
994
+ window.addEventListener('message', handler, false);
995
+ return () => {
996
+ window.removeEventListener('message', handler, false);
997
+ };
998
+ }
999
+ const { info, log, error, warn } = console;
1000
+ /**
1001
+ * consoleログを実行ログに表示する
1002
+ */
1003
+ function listenConsoleLogger() {
1004
+ const cleanup = listenLogger();
1005
+ console.info = function (...messages) {
1006
+ logger.info(...messages);
1007
+ info.apply(this, messages);
1008
+ };
1009
+ console.log = function (...messages) {
1010
+ logger.log(...messages);
1011
+ log.apply(this, messages);
1012
+ };
1013
+ console.error = function (...messages) {
1014
+ logger.error(...messages);
1015
+ error.apply(this, messages);
1016
+ };
1017
+ console.warn = function (...messages) {
1018
+ logger.warn(...messages);
1019
+ warn.apply(this, messages);
1020
+ };
1021
+ return () => {
1022
+ cleanup();
1023
+ console.info = info;
1024
+ console.log = log;
1025
+ console.error = error;
1026
+ console.warn = warn;
1027
+ };
1028
+ }
1029
+ function formatLog(texts) {
1030
+ if (!texts)
1031
+ return '';
1032
+ const s = texts
1033
+ .reduce((acc, t) => {
1034
+ let text = '';
1035
+ try {
1036
+ if (typeof t === 'string') {
1037
+ text += t;
1038
+ }
1039
+ else if (t instanceof Error) {
1040
+ text += formatError(t);
1041
+ }
1042
+ else {
1043
+ text += JSON.stringify(t, undefined, 2);
1044
+ }
1045
+ }
1046
+ catch (e) {
1047
+ //pass
1048
+ }
1049
+ acc += text + ' ';
1050
+ return acc;
1051
+ }, '')
1052
+ .trim();
1053
+ return s.length > 3000 ? s.substr(0, 3000) + '...' : s;
1054
+ }
1055
+ function formatError(error) {
1056
+ if (!error)
1057
+ return '';
1058
+ if (error.stack)
1059
+ return error.stack;
1060
+ return error.message;
1061
+ }
1062
+
907
1063
  function doPresent({ direction, deltaRate }, downFn, upFn, condition = false) {
908
1064
  if (direction === 'down' && deltaRate > 0) {
909
1065
  downFn();
@@ -1415,6 +1571,7 @@ function create(App, options = {
1415
1571
  }
1416
1572
  return cleanup;
1417
1573
  };
1574
+ const loggerCleanup = listenConsoleLogger() ;
1418
1575
  if (options.onCreate) {
1419
1576
  options.onCreate(actionProps);
1420
1577
  }
@@ -1440,6 +1597,7 @@ function create(App, options = {
1440
1597
  close();
1441
1598
  hideCleanup();
1442
1599
  showCleanup();
1600
+ loggerCleanup();
1443
1601
  window.removeEventListener(ACTION_SHOW_EVENT, show);
1444
1602
  window.removeEventListener(ACTION_CLOSE_EVENT, handleClose);
1445
1603
  };
@@ -1749,6 +1907,9 @@ function createApp(App, options = {
1749
1907
  };
1750
1908
  }
1751
1909
 
1910
+ const DEFAULT_COLLECTION_ENDPOINT = typeof __FLYER_GEN_COLLECTION_API_ENDPOINT__ === 'string'
1911
+ ? __FLYER_GEN_COLLECTION_API_ENDPOINT__
1912
+ : 'https://t.karte.io/collection';
1752
1913
  /**
1753
1914
  * アクションテーブルを管理するメソッドを取得する
1754
1915
  *
@@ -1759,7 +1920,7 @@ function createApp(App, options = {
1759
1920
  * @public
1760
1921
  */
1761
1922
  function collection$1(config) {
1762
- const endpoint = config.endpoint || "https://t.karte.test/collection";
1923
+ const endpoint = config.endpoint || DEFAULT_COLLECTION_ENDPOINT;
1763
1924
  const api_key = config.api_key;
1764
1925
  const table = config.table;
1765
1926
  return {
@@ -8233,4 +8394,4 @@ class ImageBlock extends SvelteComponent {
8233
8394
  }
8234
8395
  }
8235
8396
 
8236
- 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, getState$1 as getState, getStates, getStoreState, getSystem, hideOnScroll, hideOnTime, initialize, isClosed, isOpened, loadGlobalScript, loadGlobalStyle, loadStyle, 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 };
8397
+ 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, 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 };
@@ -878,6 +878,42 @@ declare function onScroll(rate: number | number[], fn: OnScrollFunction): () =>
878
878
  * @public
879
879
  */
880
880
  declare function onTime(time: number, fn: Function): () => void;
881
+ /**
882
+ * アクションのログの記録の管理
883
+ */
884
+ type LogLevel = "info" | "error" | "warn";
885
+ type Log = {
886
+ level: LogLevel;
887
+ message: string;
888
+ date?: Date;
889
+ };
890
+ type Event = {
891
+ name: string;
892
+ values?: any;
893
+ date?: Date;
894
+ };
895
+ declare function getLogs(): Log[];
896
+ declare function getEvents(): Event[];
897
+ /**
898
+ * ログを送信する関数群
899
+ */
900
+ declare const logger: {
901
+ info: (...messages: any[]) => void;
902
+ log: (...messages: any[]) => void;
903
+ error: (...messages: any[]) => void;
904
+ warn: (...messages: any[]) => void;
905
+ event: (name: string, values: any) => void;
906
+ clear: () => void;
907
+ clearEvents: () => void;
908
+ };
909
+ /**
910
+ * loggerのログを実行ログに表示する
911
+ */
912
+ declare function listenLogger(): () => void;
913
+ /**
914
+ * consoleログを実行ログに表示する
915
+ */
916
+ declare function listenConsoleLogger(): () => void;
881
917
  /**
882
918
  * プロパティ
883
919
  *
@@ -2840,8 +2876,8 @@ declare namespace widget {
2840
2876
  */
2841
2877
  export { showAction as show, closeAction as hide };
2842
2878
  }
2843
- export { loadGlobalScript, loadGlobalStyle, applyGlobalCss, initialize, finalize, setAutoStart, getState, setState, getStates, isOpened, getCustomVariables, setCustomVariables, updateCustomVariables, getCustomHandlers, setCustomHandlers, updateCustomHandlers, getSystem, setActionSetting, customHandlers, customVariables, formData, state, opened, closed, destroyed, stopped, isClosed, setClosed, getStoreState, onScroll, onTime, hideOnScroll, hideOnTime, showOnScroll, showOnTime, PropTypes, PropType, Code, MediaQueries, MediaQuery, Directions, Direction, AnimationStyles, AnimationStyle, ModalPositions, ModalPosition, ModalMargin, ModalPlacement, DefaultModalPlacement, Elasticities, Elasticity, ElasticityStyle, TextDirections, TextDirection, OperationArgumentType, Operation, OnClickOperationOptions, OnClickOperation, LongText, Url, Image, LengthUnits, LengthUnit, Length, Color, Justifies, Justify, Alignments, Alignment, ObjectFits, ObjectFit, ClipPaths, ClipPath, Repeats, Repeat, BackgroundSizes, BackgroundSize, Cursors, Cursor, Overflows, Overflow, Border, BorderStyle, BorderWidth, Style, StateName, WritingModes, WritingMode, ListSeparatorTypes, ListSeparatorNone, ListSeparatorBorder, ListSeparatorGap, ListSeparator, DefaultListSeparatorNone, DefaultListSeparatorBorder, DefaultListSeparatorGap, DefaultListSeparator, ListBackgroundTypes, ListBackgroundNone, ListBackgroundStripe, ListBackground, DefaultListBackgroundNone, DefaultListBackgroundStripe, DefaultListBackground, ListDirections, ListDirection, ListContext, SlideButtonIcon, SlideButtonText, SlideButton, DefaultSlideButton, SlideButtonPosition, SlideNavigationButton, DefaultSlideNavigationButton, FormInputName, FormButtonStyle, DefaultFormButtonStyle, FormSelectStyle, DefaultFormSelectStyle, FormRatingButtonType, FormRatingButtonTypes, DefaultFormRatingButtonType, create, destroy, closeAction, showAction, loadStyle, applyCss, getActionShadowRoot, onCreate, onShow, onClose, onDestroy, onChangeState, showModal, ensureModalRoot, show, close, createApp, createFog, KARTE_MODAL_ROOT, collection, widget };
2844
- export type { CloseTrigger, CustomVariables, ActionEventHandler, SystemConfig, OnScrollContext, OnScrollFunction, ScrollDirection, ActionProps, ActionOptions, ActionHook, ActionCloseHook, ActionChangeStateHook, SendFunction, CollectionConfig };
2879
+ export { loadGlobalScript, loadGlobalStyle, applyGlobalCss, initialize, finalize, setAutoStart, getState, setState, getStates, isOpened, getCustomVariables, setCustomVariables, updateCustomVariables, getCustomHandlers, setCustomHandlers, updateCustomHandlers, getSystem, setActionSetting, customHandlers, customVariables, formData, state, opened, closed, destroyed, stopped, isClosed, setClosed, getStoreState, onScroll, onTime, getLogs, getEvents, logger, listenLogger, listenConsoleLogger, hideOnScroll, hideOnTime, showOnScroll, showOnTime, PropTypes, PropType, Code, MediaQueries, MediaQuery, Directions, Direction, AnimationStyles, AnimationStyle, ModalPositions, ModalPosition, ModalMargin, ModalPlacement, DefaultModalPlacement, Elasticities, Elasticity, ElasticityStyle, TextDirections, TextDirection, OperationArgumentType, Operation, OnClickOperationOptions, OnClickOperation, LongText, Url, Image, LengthUnits, LengthUnit, Length, Color, Justifies, Justify, Alignments, Alignment, ObjectFits, ObjectFit, ClipPaths, ClipPath, Repeats, Repeat, BackgroundSizes, BackgroundSize, Cursors, Cursor, Overflows, Overflow, Border, BorderStyle, BorderWidth, Style, StateName, WritingModes, WritingMode, ListSeparatorTypes, ListSeparatorNone, ListSeparatorBorder, ListSeparatorGap, ListSeparator, DefaultListSeparatorNone, DefaultListSeparatorBorder, DefaultListSeparatorGap, DefaultListSeparator, ListBackgroundTypes, ListBackgroundNone, ListBackgroundStripe, ListBackground, DefaultListBackgroundNone, DefaultListBackgroundStripe, DefaultListBackground, ListDirections, ListDirection, ListContext, SlideButtonIcon, SlideButtonText, SlideButton, DefaultSlideButton, SlideButtonPosition, SlideNavigationButton, DefaultSlideNavigationButton, FormInputName, FormButtonStyle, DefaultFormButtonStyle, FormSelectStyle, DefaultFormSelectStyle, FormRatingButtonType, FormRatingButtonTypes, DefaultFormRatingButtonType, create, destroy, closeAction, showAction, loadStyle, applyCss, getActionShadowRoot, onCreate, onShow, onClose, onDestroy, onChangeState, showModal, ensureModalRoot, show, close, createApp, createFog, KARTE_MODAL_ROOT, collection, widget };
2880
+ export type { CloseTrigger, CustomVariables, ActionEventHandler, SystemConfig, OnScrollContext, OnScrollFunction, ScrollDirection, LogLevel, Log, Event, ActionProps, ActionOptions, ActionHook, ActionCloseHook, ActionChangeStateHook, SendFunction, CollectionConfig };
2845
2881
  export { default as State } from './components/State.svelte';
2846
2882
  export { default as StateItem } from './components/StateItem.svelte';
2847
2883
  export { default as Modal } from './components/Modal.svelte';
package/dist/index.es.js CHANGED
@@ -956,6 +956,162 @@ const setAutoStart = (on = true) => {
956
956
  setStopped(!on);
957
957
  };
958
958
 
959
+ /**
960
+ * アクションのログの記録の管理
961
+ */
962
+ const MESSAGES_LIMIT = 1000;
963
+ const EVENTS_LIMIT = 1000;
964
+ // 実行ログ
965
+ let logs = [];
966
+ // KARTEイベント
967
+ let events = [];
968
+ function getLogs() {
969
+ return logs;
970
+ }
971
+ function getEvents() {
972
+ return events;
973
+ }
974
+ // iframe内の場合は親windowを参照する
975
+ function w(w) {
976
+ return w.parent === w ? w : w.parent;
977
+ }
978
+ /**
979
+ * ログを送信する関数群
980
+ */
981
+ const logger = {
982
+ info: (...messages) => {
983
+ const log = { level: 'info', message: formatLog(messages), date: new Date() };
984
+ w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
985
+ },
986
+ log: (...messages) => {
987
+ const log = { level: 'info', message: formatLog(messages), date: new Date() };
988
+ w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
989
+ },
990
+ error: (...messages) => {
991
+ const log = { level: 'error', message: formatLog(messages), date: new Date() };
992
+ w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
993
+ },
994
+ warn: (...messages) => {
995
+ const log = { level: 'warn', message: formatLog(messages), date: new Date() };
996
+ w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
997
+ },
998
+ event: (name, values) => {
999
+ const event = values ? { name, values, date: new Date() } : { name, date: new Date() };
1000
+ w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'event', event } }, '*');
1001
+ },
1002
+ clear: () => {
1003
+ w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'clear' } }, '*');
1004
+ },
1005
+ clearEvents: () => {
1006
+ w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'clearEvents' } }, '*');
1007
+ },
1008
+ };
1009
+ /**
1010
+ * loggerのログを実行ログに表示する
1011
+ */
1012
+ function listenLogger() {
1013
+ const handler = (event) => {
1014
+ const { type, detail } = event.data;
1015
+ if (event.origin !== location.origin) {
1016
+ return;
1017
+ }
1018
+ if (type !== 'KARTE-ACTION-LOGGER') {
1019
+ return;
1020
+ }
1021
+ if (detail.method === 'clear') {
1022
+ logs = [];
1023
+ }
1024
+ else if (detail.method === 'clearEvents') {
1025
+ events = [];
1026
+ }
1027
+ else if (detail.method === 'log') {
1028
+ if (MESSAGES_LIMIT <= logs.length) {
1029
+ logs.shift();
1030
+ }
1031
+ const { level, message } = detail.log;
1032
+ const log = { level, message, date: new Date() };
1033
+ logs.push(log);
1034
+ }
1035
+ else if (detail.method === 'event') {
1036
+ if (EVENTS_LIMIT <= events.length) {
1037
+ events.shift();
1038
+ }
1039
+ const { name, values } = detail.event;
1040
+ const karteEvent = values
1041
+ ? { name, values, date: new Date() }
1042
+ : { name, date: new Date() };
1043
+ events.push(karteEvent);
1044
+ }
1045
+ };
1046
+ window.addEventListener('message', handler, false);
1047
+ return () => {
1048
+ window.removeEventListener('message', handler, false);
1049
+ };
1050
+ }
1051
+ const { info, log, error, warn } = console;
1052
+ /**
1053
+ * consoleログを実行ログに表示する
1054
+ */
1055
+ function listenConsoleLogger() {
1056
+ const cleanup = listenLogger();
1057
+ console.info = function (...messages) {
1058
+ logger.info(...messages);
1059
+ info.apply(this, messages);
1060
+ };
1061
+ console.log = function (...messages) {
1062
+ logger.log(...messages);
1063
+ log.apply(this, messages);
1064
+ };
1065
+ console.error = function (...messages) {
1066
+ logger.error(...messages);
1067
+ error.apply(this, messages);
1068
+ };
1069
+ console.warn = function (...messages) {
1070
+ logger.warn(...messages);
1071
+ warn.apply(this, messages);
1072
+ };
1073
+ return () => {
1074
+ cleanup();
1075
+ console.info = info;
1076
+ console.log = log;
1077
+ console.error = error;
1078
+ console.warn = warn;
1079
+ };
1080
+ }
1081
+ function formatLog(texts) {
1082
+ if (!texts)
1083
+ return '';
1084
+ const s = texts
1085
+ .reduce((acc, t) => {
1086
+ let text = '';
1087
+ try {
1088
+ if (typeof t === 'string') {
1089
+ text += t;
1090
+ }
1091
+ else if (t instanceof Error) {
1092
+ text += formatError(t);
1093
+ }
1094
+ else {
1095
+ text += JSON.stringify(t, undefined, 2);
1096
+ }
1097
+ }
1098
+ catch (e) {
1099
+ //pass
1100
+ }
1101
+ acc += text + ' ';
1102
+ return acc;
1103
+ }, '')
1104
+ .trim();
1105
+ return s.length > 3000 ? s.substr(0, 3000) + '...' : s;
1106
+ }
1107
+ function formatError(error) {
1108
+ if (!error)
1109
+ return '';
1110
+ if (error.stack)
1111
+ return error.stack;
1112
+ return error.message;
1113
+ }
1114
+
959
1115
  function doPresent({ direction, deltaRate }, downFn, upFn, condition = false) {
960
1116
  if (direction === 'down' && deltaRate > 0) {
961
1117
  downFn();
@@ -1864,6 +2020,9 @@ function createApp(App, options = {
1864
2020
  };
1865
2021
  }
1866
2022
 
2023
+ const DEFAULT_COLLECTION_ENDPOINT = typeof __FLYER_GEN_COLLECTION_API_ENDPOINT__ === 'string'
2024
+ ? __FLYER_GEN_COLLECTION_API_ENDPOINT__
2025
+ : 'https://t.karte.io/collection';
1867
2026
  /**
1868
2027
  * アクションテーブルを管理するメソッドを取得する
1869
2028
  *
@@ -1874,7 +2033,7 @@ function createApp(App, options = {
1874
2033
  * @public
1875
2034
  */
1876
2035
  function collection$1(config) {
1877
- const endpoint = config.endpoint || "https://t.karte.test/collection";
2036
+ const endpoint = config.endpoint || DEFAULT_COLLECTION_ENDPOINT;
1878
2037
  const api_key = config.api_key;
1879
2038
  const table = config.table;
1880
2039
  return {
@@ -7733,4 +7892,4 @@ class ImageBlock extends SvelteComponent {
7733
7892
  }
7734
7893
  }
7735
7894
 
7736
- 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, getState$1 as getState, getStates, getStoreState, getSystem, hideOnScroll, hideOnTime, initialize, isClosed, isOpened, loadGlobalScript, loadGlobalStyle, loadStyle, 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 };
7895
+ 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, 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 };
package/dist/templates.js CHANGED
@@ -1,6 +1,5 @@
1
1
  function createAppScript(script = '') {
2
- return `\
3
- <script lang="ts">
2
+ return `<script lang="ts">
4
3
  // SDK generated imports: DON'T TOUCH THIS
5
4
  // @ts-ignore
6
5
  import type { ActionProps, CustomVariables } from "@plaidev/karte-action-sdk";
@@ -8,11 +7,8 @@ import type { Data, Props, Variables } from './gen';
8
7
  import { onMount } from 'svelte';
9
8
  import { writable } from 'svelte/store';
10
9
  import {
11
- // functions
12
10
  state,
13
11
  customVariables,
14
-
15
- // Layout
16
12
  State,
17
13
  StateItem,
18
14
  Modal,
@@ -20,8 +16,8 @@ import {
20
16
  GridItem,
21
17
  List,
22
18
  ListItem,
23
-
24
- // Elements
19
+ Slide,
20
+ SlideItem,
25
21
  TextElement,
26
22
  ImageElement,
27
23
  TextButtonElement,
@@ -33,8 +29,6 @@ import {
33
29
  FormSelect,
34
30
  FormCheckBoxes,
35
31
  FormRatingButtons,
36
- Slide,
37
- SlideItem,
38
32
  } from '@plaidev/karte-action-sdk';
39
33
 
40
34
  export let send: (event_name: string, values?: any) => void;
@@ -63,8 +57,7 @@ $: {
63
57
  </script>`;
64
58
  }
65
59
  function createIndexTsx(script = '') {
66
- return `\
67
- import type { KarteAction, Send, Props, Variables } from "./gen";
60
+ return `import type { KarteAction, Send, Props, Variables } from "./gen";
68
61
 
69
62
  import "https://polyfill.io/v3/polyfill.min.js?features=IntersectionObserver";
70
63
  import { create } from "@plaidev/karte-action-sdk";
@@ -85,8 +78,7 @@ const action = (options: { send: Send; props: Props; variables: Variables }): Ka
85
78
  export default action;`;
86
79
  }
87
80
  function createCustomScript(script = '') {
88
- return `\
89
- /**
81
+ return `/**
90
82
  * アクションをカスタマイズするスクリプト
91
83
  */
92
84
  // ここでSDKをインポートしてください
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaidev/karte-action-sdk",
3
- "version": "1.1.122",
3
+ "version": "1.1.124",
4
4
  "author": "Plaid Inc.",
5
5
  "license": "Apache-2.0",
6
6
  "module": "./dist/index.es.js",