@plaidev/karte-action-sdk 1.1.270-29410070.b86a3f94e → 1.1.270-29419384.246a50882

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/index.es.js CHANGED
@@ -5,12 +5,17 @@ import { cubicOut, elasticOut, linear } from "svelte/easing";
5
5
 
6
6
  //#region rolldown:runtime
7
7
  var __defProp = Object.defineProperty;
8
- var __export = (all) => {
8
+ var __export = (all, symbols) => {
9
9
  let target = {};
10
- for (var name in all) __defProp(target, name, {
11
- get: all[name],
12
- enumerable: true
13
- });
10
+ for (var name in all) {
11
+ __defProp(target, name, {
12
+ get: all[name],
13
+ enumerable: true
14
+ });
15
+ }
16
+ if (symbols) {
17
+ __defProp(target, Symbol.toStringTag, { value: "Module" });
18
+ }
14
19
  return target;
15
20
  };
16
21
 
@@ -188,17 +193,13 @@ function onScroll(rate, fn) {
188
193
  html.scrollHeight,
189
194
  html.clientHeight
190
195
  ]);
191
- const viewHeight = Math.min(...[html.clientHeight, body.clientHeight]);
192
- const scrollRate = (scrollTop + viewHeight) / pageHeight;
196
+ const scrollRate = (scrollTop + Math.min(...[html.clientHeight, body.clientHeight])) / pageHeight;
193
197
  contexts.forEach((ctx) => {
194
198
  ctx.scrollRate = scrollRate;
195
199
  ctx.deltaRate = ctx.scrollRate - ctx.previousRate;
196
200
  ctx.previousRate = ctx.scrollRate;
197
201
  ctx.scrollTop = scrollTop;
198
- if (canCall(ctx)) {
199
- const repeat = !!_fn(Object.assign({ direction: direction(ctx) }, ctx));
200
- updateStates(ctx, repeat);
201
- }
202
+ if (canCall(ctx)) updateStates(ctx, !!_fn(Object.assign({ direction: direction(ctx) }, ctx)));
202
203
  });
203
204
  };
204
205
  window.addEventListener("scroll", onScroll$1);
@@ -1426,6 +1427,9 @@ function dispatchDestroyEvent() {
1426
1427
 
1427
1428
  //#endregion
1428
1429
  //#region src/display-logic.ts
1430
+ /**
1431
+ * モーダル(ポップアップ)のロジックを管理する
1432
+ */
1429
1433
  function doPresent({ direction, deltaRate }, downFn, upFn, condition = false) {
1430
1434
  if (direction === "down" && deltaRate > 0) downFn();
1431
1435
  else if (condition && direction === "up" && deltaRate < 0) upFn();
@@ -1559,6 +1563,9 @@ function checkAndDo(checkFn, fn, ...conditionFns) {
1559
1563
 
1560
1564
  //#endregion
1561
1565
  //#region src/collection.ts
1566
+ /**
1567
+ * アクションテーブルに関連するコードの管理
1568
+ */
1562
1569
  const DEFAULT_COLLECTION_ENDPOINT = "https://action-table.karte.io/collection";
1563
1570
  /**
1564
1571
  * アクションテーブルを管理するメソッドを取得する
@@ -1752,6 +1759,11 @@ function initActionTable(localVariablesQuery) {
1752
1759
 
1753
1760
  //#endregion
1754
1761
  //#region src/modal.tsx
1762
+ /**
1763
+ * モーダル(ポップアップ)に関連するコードの管理
1764
+ *
1765
+ * アクションのShow, Close, ChangeStateの状態はここで管理する。
1766
+ */
1755
1767
  /** @internal */
1756
1768
  const handleState = (event) => {
1757
1769
  if (event.detail.actionId === actionId || event.detail.actionId === ALL_ACTION_ID) {
@@ -1970,8 +1982,7 @@ function createModal(App, options = {
1970
1982
  return NOOP;
1971
1983
  };
1972
1984
  const handleClose = (event) => {
1973
- const trigger = event?.detail?.trigger ? event.detail.trigger : "none";
1974
- close$2(trigger);
1985
+ close$2(event?.detail?.trigger ? event.detail.trigger : "none");
1975
1986
  };
1976
1987
  const show$2 = async (trigger = "none") => {
1977
1988
  if (app) return;
@@ -1992,21 +2003,21 @@ function createModal(App, options = {
1992
2003
  setOpened(true);
1993
2004
  setClosed(false);
1994
2005
  if (app) return;
1995
- const props = {
2006
+ app = new App({
1996
2007
  target: ensureActionRoot$1(true),
1997
2008
  hydrate: false,
1998
2009
  props: {
1999
2010
  send: options.send,
2000
2011
  publish: options.publish,
2001
2012
  data,
2002
- onShow: (props$1) => {
2013
+ onShow: (props) => {
2003
2014
  const { onShowHandlers } = getInternalHandlers();
2004
2015
  if (onShowHandlers) onShowHandlers.forEach((h$1) => {
2005
2016
  console.info(`${ACTION_HOOK_LABEL}:${JSON.stringify({ name: "onShow" })}`);
2006
- h$1(props$1);
2017
+ h$1(props);
2007
2018
  });
2008
2019
  },
2009
- onChangeState: (props$1, newState) => {
2020
+ onChangeState: (props, newState) => {
2010
2021
  const { onChangeStateHandlers } = getInternalHandlers();
2011
2022
  if (onChangeStateHandlers) onChangeStateHandlers.forEach((h$1) => {
2012
2023
  const actionHookLog = {
@@ -2014,18 +2025,16 @@ function createModal(App, options = {
2014
2025
  values: { newState }
2015
2026
  };
2016
2027
  console.info(`${ACTION_HOOK_LABEL}:${JSON.stringify(actionHookLog)}`);
2017
- h$1(props$1, newState);
2028
+ h$1(props, newState);
2018
2029
  });
2019
2030
  const { onChangeStateHandlers: onChangeWidgetStateHandlers } = getWidgetHandlers();
2020
- if (onChangeWidgetStateHandlers) onChangeStateHandlers.forEach((h$1) => h$1(props$1, newState));
2031
+ if (onChangeWidgetStateHandlers) onChangeStateHandlers.forEach((h$1) => h$1(props, newState));
2021
2032
  }
2022
2033
  }
2023
- };
2024
- app = new App(props);
2034
+ });
2025
2035
  };
2026
2036
  const handleShow = (event) => {
2027
- const trigger = event?.detail?.trigger ? event.detail.trigger : "none";
2028
- show$2(trigger);
2037
+ show$2(event?.detail?.trigger ? event.detail.trigger : "none");
2029
2038
  };
2030
2039
  const currying = (conditionFn, options$1) => (fn) => conditionFn(options$1.props, fn);
2031
2040
  const autoShow = () => {
@@ -2208,6 +2217,11 @@ function createFog({ color = "#000", opacity = "50%", zIndex = 999, onclick }) {
2208
2217
  //#endregion
2209
2218
  //#region src/modal.svelte5.tsx
2210
2219
  /**
2220
+ * モーダル(ポップアップ)に関連するコードの管理
2221
+ *
2222
+ * アクションのShow, Close, ChangeStateの状態はここで管理する。
2223
+ */
2224
+ /**
2211
2225
  * アクションが表示 (show) された後にフックする関数
2212
2226
  *
2213
2227
  * @param fn - 呼び出されるフック関数
@@ -2476,6 +2490,9 @@ function createFog$1({ color = "#000", opacity = "50%", zIndex = 999, onclick })
2476
2490
 
2477
2491
  //#endregion
2478
2492
  //#region src/script.ts
2493
+ /**
2494
+ * スクリプト接客が利用するコードの管理
2495
+ */
2479
2496
  /** @internal */
2480
2497
  async function runScript$1(options = {
2481
2498
  send: () => {},
@@ -2579,6 +2596,11 @@ async function loadGlobalStyle(href) {
2579
2596
 
2580
2597
  //#endregion
2581
2598
  //#region src/action.ts
2599
+ /**
2600
+ * Edgeが起動するアクションに関連するコードを管理する
2601
+ *
2602
+ * アクションのCreate, Destroyの状態はここで管理する。
2603
+ */
2582
2604
  const emptyOptions = {
2583
2605
  send: () => {},
2584
2606
  publish: () => {},
@@ -2765,8 +2787,7 @@ function validateFormData(formData$1, statePath) {
2765
2787
  /** @internal */
2766
2788
  const getValuesAreValidReadable = (statePath) => ({ subscribe(callback$5) {
2767
2789
  return formData.subscribe((formData$1) => identifyFormData.subscribe((identifyFormData$1) => {
2768
- const valuesAreValid = validateFormData(formData$1, statePath) && validateFormData(identifyFormData$1, statePath);
2769
- callback$5(valuesAreValid);
2790
+ callback$5(validateFormData(formData$1, statePath) && validateFormData(identifyFormData$1, statePath));
2770
2791
  }));
2771
2792
  } });
2772
2793
  function createAnswerValue$1(value) {
@@ -2789,8 +2810,7 @@ function formDataToEventValues$1(campaignId, formData$1) {
2789
2810
  }
2790
2811
  function formDataToIdentifyEventValues$1(formData$1) {
2791
2812
  return Object.fromEntries(Object.entries(formData$1).map(([name, dataItem]) => {
2792
- const value = dataItem.value;
2793
- return [name, value];
2813
+ return [name, dataItem.value];
2794
2814
  }));
2795
2815
  }
2796
2816
  /** @internal */
@@ -2911,6 +2931,9 @@ function sendAnswers() {
2911
2931
 
2912
2932
  //#endregion
2913
2933
  //#region src/widget.ts
2934
+ /**
2935
+ * エディタv1のWidget API 互換のインターフェース
2936
+ */
2914
2937
  var widget_exports = /* @__PURE__ */ __export({
2915
2938
  collection: () => collection$1,
2916
2939
  getState: () => getState$1,
@@ -3841,10 +3864,12 @@ function onSubmitForm(fn) {
3841
3864
 
3842
3865
  //#endregion
3843
3866
  //#region src/functions.ts
3867
+ /**
3868
+ * モーダル(ポップアップ)のコンポーネントが利用するコードの管理
3869
+ */
3844
3870
  function _moveTo(to) {
3845
- const currentState = getState();
3846
3871
  dispatchActionEvent(ACTION_CHANGE_STATE_EVENT, { detail: {
3847
- from: currentState,
3872
+ from: getState(),
3848
3873
  to,
3849
3874
  actionId
3850
3875
  } });
@@ -4013,36 +4038,12 @@ const haveFunction = (onClickOperation) => {
4013
4038
  function getAnimation(animation) {
4014
4039
  switch (animation.type) {
4015
4040
  case "fade": return `opacity: ${animation.progress}`;
4016
- case "bounce": {
4017
- const translateX = animation.x;
4018
- const translateY = animation.y;
4019
- return `transform: translate3d(${translateX}%, ${translateY}%, 0) scale(${animation.progress});`;
4020
- }
4021
- case "slide-down": {
4022
- const translateX = animation.x;
4023
- const translateY = animation.y - 100 * (1 - animation.progress);
4024
- return `transform: translate3d(${translateX}%, ${translateY}%, 0);`;
4025
- }
4026
- case "slide-up": {
4027
- const translateX = animation.x;
4028
- const translateY = animation.y + 100 * (1 - animation.progress);
4029
- return `transform: translate3d(${translateX}%, ${translateY}%, 0);`;
4030
- }
4031
- case "slide-left": {
4032
- const translateX = animation.x + 100 * (1 - animation.progress);
4033
- const translateY = animation.y;
4034
- return `transform: translate3d(${translateX}%, ${translateY}%, 0);`;
4035
- }
4036
- case "slide-right": {
4037
- const translateX = animation.x - 100 * (1 - animation.progress);
4038
- const translateY = animation.y;
4039
- return `transform: translate3d(${translateX}%, ${translateY}%, 0);`;
4040
- }
4041
- case "none": {
4042
- const translateX = animation.x;
4043
- const translateY = animation.y;
4044
- return `transform: translate3d(${translateX}%, ${translateY}%, 0);`;
4045
- }
4041
+ case "bounce": return `transform: translate3d(${animation.x}%, ${animation.y}%, 0) scale(${animation.progress});`;
4042
+ case "slide-down": return `transform: translate3d(${animation.x}%, ${animation.y - 100 * (1 - animation.progress)}%, 0);`;
4043
+ case "slide-up": return `transform: translate3d(${animation.x}%, ${animation.y + 100 * (1 - animation.progress)}%, 0);`;
4044
+ case "slide-left": return `transform: translate3d(${animation.x + 100 * (1 - animation.progress)}%, ${animation.y}%, 0);`;
4045
+ case "slide-right": return `transform: translate3d(${animation.x - 100 * (1 - animation.progress)}%, ${animation.y}%, 0);`;
4046
+ case "none": return `transform: translate3d(${animation.x}%, ${animation.y}%, 0);`;
4046
4047
  default:
4047
4048
  console.warn(`[action-sdk] invalid '${animation}', so we use 'transform: none' instead`);
4048
4049
  return "transform: none";
@@ -4181,6 +4182,10 @@ var BackgroundOverlay_default$1 = BackgroundOverlay$1;
4181
4182
 
4182
4183
  //#endregion
4183
4184
  //#region src/enhancedStopPropagation.ts
4185
+ /**
4186
+ * data属性とカスタムのイベントハンドラによるstopPropagation。
4187
+ * デフォルトのstopPropagationだと伝播先のpreventDefaultも無効化されてしまうため、それの対策。
4188
+ */
4184
4189
  function createDataAttrKey(eventName) {
4185
4190
  return `data-stop-propagation-${eventName}-${actionId}`;
4186
4191
  }
@@ -5112,10 +5117,7 @@ function instance$103($$self, $$props, $$invalidate) {
5112
5117
  let elasticStyle = ElasticityStyle[isPreview() ? "none" : elasticity];
5113
5118
  if (!useBreakPoint) modalStyles.add(elasticStyle);
5114
5119
  DEVICE_IDS.forEach((deviceId) => {
5115
- if (!isPreview() && useBreakPoint) {
5116
- const elasticityWithBp = breakPoint[deviceId]?.elasticity;
5117
- elasticStyle = ElasticityStyle[elasticityWithBp];
5118
- }
5120
+ if (!isPreview() && useBreakPoint) elasticStyle = ElasticityStyle[breakPoint[deviceId]?.elasticity];
5119
5121
  const elasticityVariables = stringifyStyleObj(formatObjectKey({
5120
5122
  obj: parseStyle(elasticStyle),
5121
5123
  prefix: "--modal-bp-",
@@ -6475,12 +6477,11 @@ function instance$93($$self, $$props, $$invalidate) {
6475
6477
  let domRef = null;
6476
6478
  function sendMovieEvent(event_name, values = {}) {
6477
6479
  if (!sendEvent) return;
6478
- const sentValues = {
6480
+ send_event(event_name, {
6479
6481
  campaign_id: $system.campaignId,
6480
6482
  shorten_id: $system.shortenId,
6481
6483
  ...values
6482
- };
6483
- send_event(event_name, sentValues);
6484
+ });
6484
6485
  }
6485
6486
  function sendPlaytime() {
6486
6487
  if (!startDate) return;
@@ -6729,12 +6730,11 @@ function instance$92($$self, $$props, $$invalidate) {
6729
6730
  let domRef = null;
6730
6731
  function sendMovieEvent(event_name, values = {}) {
6731
6732
  if (!sendEvent) return;
6732
- const sentValues = {
6733
+ send_event(event_name, {
6733
6734
  campaign_id: $system.campaignId,
6734
6735
  shorten_id: $system.shortenId,
6735
6736
  ...values
6736
- };
6737
- send_event(event_name, sentValues);
6737
+ });
6738
6738
  }
6739
6739
  function sendPlaytime() {
6740
6740
  if (!startDate) return;
@@ -8723,8 +8723,7 @@ function instance$83($$self, $$props, $$invalidate) {
8723
8723
  if (!moving) return;
8724
8724
  if (previousMove) {
8725
8725
  const dx = clientX - previousMove.clientX;
8726
- const dt = timeStamp - previousMove.timeStamp;
8727
- moveSpeed = dx / dt;
8726
+ moveSpeed = dx / (timeStamp - previousMove.timeStamp);
8728
8727
  const updatedSlidePosition = slidePosition + dx;
8729
8728
  window.requestAnimationFrame(() => {
8730
8729
  $$invalidate(28, slidePosition = updatedSlidePosition);
@@ -10648,12 +10647,10 @@ const toCssOverflow = (p) => {
10648
10647
  function createComponentRawCss(layerId, define) {
10649
10648
  const rootSelector = `[data-layer-id="${layerId}"]`;
10650
10649
  const gen = (selector, styles) => {
10651
- const childSelector = selector.startsWith("&") ? selector.slice(1) : ` ${selector}`;
10652
- const body = Object.entries(styles).map(([k, v]) => {
10650
+ return `${rootSelector}${selector.startsWith("&") ? selector.slice(1) : ` ${selector}`} {\n${Object.entries(styles).map(([k, v]) => {
10653
10651
  if (!v) return "";
10654
10652
  return `${k.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase())}: ${v};`;
10655
- }).filter((v) => v !== "").join("\n");
10656
- return `${rootSelector}${childSelector} {\n${body}\n}`;
10653
+ }).filter((v) => v !== "").join("\n")}\n}`;
10657
10654
  };
10658
10655
  return define(gen).join("\n");
10659
10656
  }
@@ -12902,8 +12899,7 @@ var Icon_default = Icon;
12902
12899
  //#region src/components-flex/styles.ts
12903
12900
  const getPropStyles = (callback$5) => {
12904
12901
  return (customBrandKit) => {
12905
- const brandKit = getBrandKit(customBrandKit);
12906
- return callback$5({ brandKit });
12902
+ return callback$5({ brandKit: getBrandKit(customBrandKit) });
12907
12903
  };
12908
12904
  };
12909
12905
 
@@ -17788,15 +17784,11 @@ function calcRemainingTime(limit) {
17788
17784
  return limit - (/* @__PURE__ */ new Date()).getTime();
17789
17785
  }
17790
17786
  function formatTimeDiff(ms) {
17791
- const diffDay = Math.floor(ms / 1e3 / 60 / 60 / 24);
17792
- const diffHour = Math.floor(ms / 1e3 / 60 / 60) % 24;
17793
- const diffMin = Math.floor(ms / 1e3 / 60) % 60;
17794
- const diffSec = Math.floor(ms / 1e3) % 60;
17795
17787
  return {
17796
- day: diffDay,
17797
- hour: diffHour,
17798
- min: diffMin,
17799
- sec: diffSec
17788
+ day: Math.floor(ms / 1e3 / 60 / 60 / 24),
17789
+ hour: Math.floor(ms / 1e3 / 60 / 60) % 24,
17790
+ min: Math.floor(ms / 1e3 / 60) % 60,
17791
+ sec: Math.floor(ms / 1e3) % 60
17800
17792
  };
17801
17793
  }
17802
17794
  function instance$16($$self, $$props, $$invalidate) {
@@ -17893,24 +17885,22 @@ const useText = (props, layerId) => {
17893
17885
  fontWeight: getFontWeight()
17894
17886
  };
17895
17887
  };
17896
- const escapedHTML = props.content.replace(/&/g, "&lt;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#x27;").replace(/\n/g, "<br />");
17897
- const style = objToStyle({
17898
- position: props?.position ?? "static",
17899
- textAlign: props.align,
17900
- width: props.width,
17901
- fontFamily: `"${fontFamily}"`,
17902
- color: getColor(),
17903
- ...getCssSize(),
17904
- ...toCssRadius(props),
17905
- ...toCssBackground(props),
17906
- ...toCssCommon(props),
17907
- ...toCssPosition(props),
17908
- ...toCssPadding(props),
17909
- ...toCssBorder(props)
17910
- });
17911
17888
  return {
17912
- escapedHTML,
17913
- style
17889
+ escapedHTML: props.content.replace(/&/g, "&lt;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#x27;").replace(/\n/g, "<br />"),
17890
+ style: objToStyle({
17891
+ position: props?.position ?? "static",
17892
+ textAlign: props.align,
17893
+ width: props.width,
17894
+ fontFamily: `"${fontFamily}"`,
17895
+ color: getColor(),
17896
+ ...getCssSize(),
17897
+ ...toCssRadius(props),
17898
+ ...toCssBackground(props),
17899
+ ...toCssCommon(props),
17900
+ ...toCssPosition(props),
17901
+ ...toCssPadding(props),
17902
+ ...toCssBorder(props)
17903
+ })
17914
17904
  };
17915
17905
  };
17916
17906