@plaidev/karte-action-sdk 1.1.122 → 1.1.123

Sign up to get free protection for your applications and to get access to all the features.
@@ -878,6 +878,44 @@ 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
+ // 実行ログ
896
+ declare let messages: Log[];
897
+ // KARTEイベント
898
+ declare let events: Event[];
899
+ /**
900
+ * ログを送信する関数群
901
+ */
902
+ declare const logger: {
903
+ info: (...messages: any[]) => void;
904
+ log: (...messages: any[]) => void;
905
+ error: (...messages: any[]) => void;
906
+ warn: (...messages: any[]) => void;
907
+ event: (name: string, values: any) => void;
908
+ clear: () => void;
909
+ clearEvents: () => void;
910
+ };
911
+ /**
912
+ * loggerのログを実行ログに表示する
913
+ */
914
+ declare function listenLogger(): () => void;
915
+ /**
916
+ * consoleログを実行ログに表示する
917
+ */
918
+ declare function listenConsoleLogger(): () => void;
881
919
  /**
882
920
  * プロパティ
883
921
  *
@@ -2840,8 +2878,8 @@ declare namespace widget {
2840
2878
  */
2841
2879
  export { showAction as show, closeAction as hide };
2842
2880
  }
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 };
2881
+ 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, messages, events, 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 };
2882
+ export type { CloseTrigger, CustomVariables, ActionEventHandler, SystemConfig, OnScrollContext, OnScrollFunction, ScrollDirection, LogLevel, Log, Event, ActionProps, ActionOptions, ActionHook, ActionCloseHook, ActionChangeStateHook, SendFunction, CollectionConfig };
2845
2883
  export { default as State } from './components/State.svelte';
2846
2884
  export { default as StateItem } from './components/StateItem.svelte';
2847
2885
  export { default as Modal } from './components/Modal.svelte';
@@ -904,6 +904,157 @@ 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 messages = [];
914
+ // KARTEイベント
915
+ let events = [];
916
+ // iframe内の場合は親windowを参照する
917
+ function w(w) {
918
+ return w.parent === w ? w : w.parent;
919
+ }
920
+ /**
921
+ * ログを送信する関数群
922
+ */
923
+ const logger = {
924
+ info: (...messages) => {
925
+ const log = { level: 'info', message: formatLog(messages), date: new Date() };
926
+ w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
927
+ },
928
+ log: (...messages) => {
929
+ const log = { level: 'info', message: formatLog(messages), date: new Date() };
930
+ w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
931
+ },
932
+ error: (...messages) => {
933
+ const log = { level: 'error', message: formatLog(messages), date: new Date() };
934
+ w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
935
+ },
936
+ warn: (...messages) => {
937
+ const log = { level: 'warn', message: formatLog(messages), date: new Date() };
938
+ console.log('aaaaaaaaa', w);
939
+ w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
940
+ },
941
+ event: (name, values) => {
942
+ const event = values ? { name, values, date: new Date() } : { name, date: new Date() };
943
+ w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'event', event } }, '*');
944
+ },
945
+ clear: () => {
946
+ w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'clear' } }, '*');
947
+ },
948
+ clearEvents: () => {
949
+ w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'clearEvents' } }, '*');
950
+ },
951
+ };
952
+ /**
953
+ * loggerのログを実行ログに表示する
954
+ */
955
+ function listenLogger() {
956
+ const handler = (event) => {
957
+ const { type, detail } = event.data;
958
+ if (event.origin !== location.origin) {
959
+ return;
960
+ }
961
+ if (type !== 'KARTE-ACTION-LOGGER') {
962
+ return;
963
+ }
964
+ if (detail.method === 'clear') {
965
+ messages = [];
966
+ }
967
+ else if (detail.method === 'clearEvents') {
968
+ events = [];
969
+ }
970
+ else if (detail.method === 'log') {
971
+ if (MESSAGES_LIMIT <= messages.length) {
972
+ messages.shift();
973
+ }
974
+ const { level, message } = detail.log;
975
+ const log = { level, message, date: new Date() };
976
+ messages.push(log);
977
+ }
978
+ else if (detail.method === 'event') {
979
+ if (EVENTS_LIMIT <= events.length) {
980
+ events.shift();
981
+ }
982
+ const { name, values } = detail.event;
983
+ const karteEvent = values
984
+ ? { name, values, date: new Date() }
985
+ : { name, date: new Date() };
986
+ events.push(karteEvent);
987
+ }
988
+ };
989
+ window.addEventListener('message', handler, false);
990
+ return () => {
991
+ window.removeEventListener('message', handler, false);
992
+ };
993
+ }
994
+ const { info, log, error, warn } = console;
995
+ /**
996
+ * consoleログを実行ログに表示する
997
+ */
998
+ function listenConsoleLogger() {
999
+ const cleanup = listenLogger();
1000
+ console.info = function (...messages) {
1001
+ logger.info(...messages);
1002
+ info.apply(this, messages);
1003
+ };
1004
+ console.log = function (...messages) {
1005
+ logger.log(...messages);
1006
+ log.apply(this, messages);
1007
+ };
1008
+ console.error = function (...messages) {
1009
+ logger.error(...messages);
1010
+ error.apply(this, messages);
1011
+ };
1012
+ console.warn = function (...messages) {
1013
+ logger.warn(...messages);
1014
+ warn.apply(this, messages);
1015
+ };
1016
+ return () => {
1017
+ cleanup();
1018
+ console.info = info;
1019
+ console.log = log;
1020
+ console.error = error;
1021
+ console.warn = warn;
1022
+ };
1023
+ }
1024
+ function formatLog(texts) {
1025
+ if (!texts)
1026
+ return '';
1027
+ const s = texts
1028
+ .reduce((acc, t) => {
1029
+ let text = '';
1030
+ try {
1031
+ if (typeof t === 'string') {
1032
+ text += t;
1033
+ }
1034
+ else if (t instanceof Error) {
1035
+ text += formatError(t);
1036
+ }
1037
+ else {
1038
+ text += JSON.stringify(t, undefined, 2);
1039
+ }
1040
+ }
1041
+ catch (e) {
1042
+ //pass
1043
+ }
1044
+ acc += text + ' ';
1045
+ return acc;
1046
+ }, '')
1047
+ .trim();
1048
+ return s.length > 3000 ? s.substr(0, 3000) + '...' : s;
1049
+ }
1050
+ function formatError(error) {
1051
+ if (!error)
1052
+ return '';
1053
+ if (error.stack)
1054
+ return error.stack;
1055
+ return error.message;
1056
+ }
1057
+
907
1058
  function doPresent({ direction, deltaRate }, downFn, upFn, condition = false) {
908
1059
  if (direction === 'down' && deltaRate > 0) {
909
1060
  downFn();
@@ -1415,6 +1566,7 @@ function create(App, options = {
1415
1566
  }
1416
1567
  return cleanup;
1417
1568
  };
1569
+ const loggerCleanup = listenConsoleLogger() ;
1418
1570
  if (options.onCreate) {
1419
1571
  options.onCreate(actionProps);
1420
1572
  }
@@ -1440,6 +1592,7 @@ function create(App, options = {
1440
1592
  close();
1441
1593
  hideCleanup();
1442
1594
  showCleanup();
1595
+ loggerCleanup();
1443
1596
  window.removeEventListener(ACTION_SHOW_EVENT, show);
1444
1597
  window.removeEventListener(ACTION_CLOSE_EVENT, handleClose);
1445
1598
  };
@@ -1749,6 +1902,9 @@ function createApp(App, options = {
1749
1902
  };
1750
1903
  }
1751
1904
 
1905
+ const DEFAULT_COLLECTION_ENDPOINT = typeof __FLYER_GEN_COLLECTION_API_ENDPOINT__ === 'string'
1906
+ ? __FLYER_GEN_COLLECTION_API_ENDPOINT__
1907
+ : 'https://t.karte.io/collection';
1752
1908
  /**
1753
1909
  * アクションテーブルを管理するメソッドを取得する
1754
1910
  *
@@ -1759,7 +1915,7 @@ function createApp(App, options = {
1759
1915
  * @public
1760
1916
  */
1761
1917
  function collection$1(config) {
1762
- const endpoint = config.endpoint || "https://t.karte.test/collection";
1918
+ const endpoint = config.endpoint || DEFAULT_COLLECTION_ENDPOINT;
1763
1919
  const api_key = config.api_key;
1764
1920
  const table = config.table;
1765
1921
  return {
@@ -8233,4 +8389,4 @@ class ImageBlock extends SvelteComponent {
8233
8389
  }
8234
8390
  }
8235
8391
 
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 };
8392
+ 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, events, finalize, formData, getActionShadowRoot, getCustomHandlers, getCustomVariables, getState$1 as getState, getStates, getStoreState, getSystem, hideOnScroll, hideOnTime, initialize, isClosed, isOpened, listenConsoleLogger, listenLogger, loadGlobalScript, loadGlobalStyle, loadStyle, logger, messages, 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,44 @@ 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
+ // 実行ログ
896
+ declare let messages: Log[];
897
+ // KARTEイベント
898
+ declare let events: Event[];
899
+ /**
900
+ * ログを送信する関数群
901
+ */
902
+ declare const logger: {
903
+ info: (...messages: any[]) => void;
904
+ log: (...messages: any[]) => void;
905
+ error: (...messages: any[]) => void;
906
+ warn: (...messages: any[]) => void;
907
+ event: (name: string, values: any) => void;
908
+ clear: () => void;
909
+ clearEvents: () => void;
910
+ };
911
+ /**
912
+ * loggerのログを実行ログに表示する
913
+ */
914
+ declare function listenLogger(): () => void;
915
+ /**
916
+ * consoleログを実行ログに表示する
917
+ */
918
+ declare function listenConsoleLogger(): () => void;
881
919
  /**
882
920
  * プロパティ
883
921
  *
@@ -2840,8 +2878,8 @@ declare namespace widget {
2840
2878
  */
2841
2879
  export { showAction as show, closeAction as hide };
2842
2880
  }
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 };
2881
+ 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, messages, events, 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 };
2882
+ export type { CloseTrigger, CustomVariables, ActionEventHandler, SystemConfig, OnScrollContext, OnScrollFunction, ScrollDirection, LogLevel, Log, Event, ActionProps, ActionOptions, ActionHook, ActionCloseHook, ActionChangeStateHook, SendFunction, CollectionConfig };
2845
2883
  export { default as State } from './components/State.svelte';
2846
2884
  export { default as StateItem } from './components/StateItem.svelte';
2847
2885
  export { default as Modal } from './components/Modal.svelte';
package/dist/index.es.js CHANGED
@@ -956,6 +956,157 @@ 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 messages = [];
966
+ // KARTEイベント
967
+ let events = [];
968
+ // iframe内の場合は親windowを参照する
969
+ function w(w) {
970
+ return w.parent === w ? w : w.parent;
971
+ }
972
+ /**
973
+ * ログを送信する関数群
974
+ */
975
+ const logger = {
976
+ info: (...messages) => {
977
+ const log = { level: 'info', message: formatLog(messages), date: new Date() };
978
+ w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
979
+ },
980
+ log: (...messages) => {
981
+ const log = { level: 'info', message: formatLog(messages), date: new Date() };
982
+ w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
983
+ },
984
+ error: (...messages) => {
985
+ const log = { level: 'error', message: formatLog(messages), date: new Date() };
986
+ w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
987
+ },
988
+ warn: (...messages) => {
989
+ const log = { level: 'warn', message: formatLog(messages), date: new Date() };
990
+ console.log('aaaaaaaaa', w);
991
+ w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'log', log } }, '*');
992
+ },
993
+ event: (name, values) => {
994
+ const event = values ? { name, values, date: new Date() } : { name, date: new Date() };
995
+ w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'event', event } }, '*');
996
+ },
997
+ clear: () => {
998
+ w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'clear' } }, '*');
999
+ },
1000
+ clearEvents: () => {
1001
+ w(window).postMessage({ type: 'KARTE-ACTION-LOGGER', detail: { method: 'clearEvents' } }, '*');
1002
+ },
1003
+ };
1004
+ /**
1005
+ * loggerのログを実行ログに表示する
1006
+ */
1007
+ function listenLogger() {
1008
+ const handler = (event) => {
1009
+ const { type, detail } = event.data;
1010
+ if (event.origin !== location.origin) {
1011
+ return;
1012
+ }
1013
+ if (type !== 'KARTE-ACTION-LOGGER') {
1014
+ return;
1015
+ }
1016
+ if (detail.method === 'clear') {
1017
+ messages = [];
1018
+ }
1019
+ else if (detail.method === 'clearEvents') {
1020
+ events = [];
1021
+ }
1022
+ else if (detail.method === 'log') {
1023
+ if (MESSAGES_LIMIT <= messages.length) {
1024
+ messages.shift();
1025
+ }
1026
+ const { level, message } = detail.log;
1027
+ const log = { level, message, date: new Date() };
1028
+ messages.push(log);
1029
+ }
1030
+ else if (detail.method === 'event') {
1031
+ if (EVENTS_LIMIT <= events.length) {
1032
+ events.shift();
1033
+ }
1034
+ const { name, values } = detail.event;
1035
+ const karteEvent = values
1036
+ ? { name, values, date: new Date() }
1037
+ : { name, date: new Date() };
1038
+ events.push(karteEvent);
1039
+ }
1040
+ };
1041
+ window.addEventListener('message', handler, false);
1042
+ return () => {
1043
+ window.removeEventListener('message', handler, false);
1044
+ };
1045
+ }
1046
+ const { info, log, error, warn } = console;
1047
+ /**
1048
+ * consoleログを実行ログに表示する
1049
+ */
1050
+ function listenConsoleLogger() {
1051
+ const cleanup = listenLogger();
1052
+ console.info = function (...messages) {
1053
+ logger.info(...messages);
1054
+ info.apply(this, messages);
1055
+ };
1056
+ console.log = function (...messages) {
1057
+ logger.log(...messages);
1058
+ log.apply(this, messages);
1059
+ };
1060
+ console.error = function (...messages) {
1061
+ logger.error(...messages);
1062
+ error.apply(this, messages);
1063
+ };
1064
+ console.warn = function (...messages) {
1065
+ logger.warn(...messages);
1066
+ warn.apply(this, messages);
1067
+ };
1068
+ return () => {
1069
+ cleanup();
1070
+ console.info = info;
1071
+ console.log = log;
1072
+ console.error = error;
1073
+ console.warn = warn;
1074
+ };
1075
+ }
1076
+ function formatLog(texts) {
1077
+ if (!texts)
1078
+ return '';
1079
+ const s = texts
1080
+ .reduce((acc, t) => {
1081
+ let text = '';
1082
+ try {
1083
+ if (typeof t === 'string') {
1084
+ text += t;
1085
+ }
1086
+ else if (t instanceof Error) {
1087
+ text += formatError(t);
1088
+ }
1089
+ else {
1090
+ text += JSON.stringify(t, undefined, 2);
1091
+ }
1092
+ }
1093
+ catch (e) {
1094
+ //pass
1095
+ }
1096
+ acc += text + ' ';
1097
+ return acc;
1098
+ }, '')
1099
+ .trim();
1100
+ return s.length > 3000 ? s.substr(0, 3000) + '...' : s;
1101
+ }
1102
+ function formatError(error) {
1103
+ if (!error)
1104
+ return '';
1105
+ if (error.stack)
1106
+ return error.stack;
1107
+ return error.message;
1108
+ }
1109
+
959
1110
  function doPresent({ direction, deltaRate }, downFn, upFn, condition = false) {
960
1111
  if (direction === 'down' && deltaRate > 0) {
961
1112
  downFn();
@@ -1864,6 +2015,9 @@ function createApp(App, options = {
1864
2015
  };
1865
2016
  }
1866
2017
 
2018
+ const DEFAULT_COLLECTION_ENDPOINT = typeof __FLYER_GEN_COLLECTION_API_ENDPOINT__ === 'string'
2019
+ ? __FLYER_GEN_COLLECTION_API_ENDPOINT__
2020
+ : 'https://t.karte.io/collection';
1867
2021
  /**
1868
2022
  * アクションテーブルを管理するメソッドを取得する
1869
2023
  *
@@ -1874,7 +2028,7 @@ function createApp(App, options = {
1874
2028
  * @public
1875
2029
  */
1876
2030
  function collection$1(config) {
1877
- const endpoint = config.endpoint || "https://t.karte.test/collection";
2031
+ const endpoint = config.endpoint || DEFAULT_COLLECTION_ENDPOINT;
1878
2032
  const api_key = config.api_key;
1879
2033
  const table = config.table;
1880
2034
  return {
@@ -7733,4 +7887,4 @@ class ImageBlock extends SvelteComponent {
7733
7887
  }
7734
7888
  }
7735
7889
 
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 };
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, events, finalize, formData, getActionShadowRoot, getCustomHandlers, getCustomVariables, getState$1 as getState, getStates, getStoreState, getSystem, hideOnScroll, hideOnTime, initialize, isClosed, isOpened, listenConsoleLogger, listenLogger, loadGlobalScript, loadGlobalStyle, loadStyle, logger, messages, 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.123",
4
4
  "author": "Plaid Inc.",
5
5
  "license": "Apache-2.0",
6
6
  "module": "./dist/index.es.js",