spoclip-kit 1.0.17 → 1.0.18

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.cjs CHANGED
@@ -25,6 +25,7 @@ __export(src_exports, {
25
25
  module.exports = __toCommonJS(src_exports);
26
26
 
27
27
  // src/libs/cost.ts
28
+ var CLIP_COST_PER_SECOND = 1 / 60;
28
29
  function getVideoDownloadCost({
29
30
  duration,
30
31
  quality,
@@ -32,18 +33,31 @@ function getVideoDownloadCost({
32
33
  remainingFreeDownloads = 0
33
34
  }) {
34
35
  if (quality === "4K") {
35
- return { cost: 20, isPlusFree: false };
36
+ return getRawVideoDownloadCost();
36
37
  }
38
+ return getClipVideoDownloadCost({
39
+ duration,
40
+ ticketCode,
41
+ remainingFreeDownloads
42
+ });
43
+ }
44
+ function getClipVideoDownloadCost({
45
+ duration,
46
+ ticketCode = "FREE",
47
+ remainingFreeDownloads = 0
48
+ }) {
37
49
  const durationInSeconds = duration / 1e3;
38
50
  const isUnder61 = durationInSeconds < 61;
39
51
  const isPlus = ticketCode === "PLUS";
40
52
  if (isPlus && remainingFreeDownloads > 0 && isUnder61) {
41
53
  return { cost: 0, isPlusFree: true };
42
54
  }
43
- const costPerSecond = 1 / 60;
44
- const cost = Math.round(durationInSeconds * costPerSecond * 10) / 10;
55
+ const cost = Math.round(durationInSeconds * CLIP_COST_PER_SECOND * 10) / 10;
45
56
  return { cost, isPlusFree: false };
46
57
  }
58
+ function getRawVideoDownloadCost() {
59
+ return { cost: 20, isPlusFree: false };
60
+ }
47
61
  // Annotate the CommonJS export names for ESM import in node:
48
62
  0 && (module.exports = {
49
63
  getVideoDownloadCost
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/libs/cost.ts"],"sourcesContent":["// Main entry point for spoclip-kit\nexport * from './libs';\nexport * from './types';\n","import type { TicketCode } from '@/types/membership';\n\n/**\n * 비디오 다운로드 비용을 계산합니다.\n *\n * @description\n * - 전체 시간 4K 다운로드 시 티켓 상관없이 20톨\n * - 1분 미만인 경우, remainingFreeDownloads > 0 이면 무료\n * - 1분 미만인 경우, remainingFreeDownloads <= 0 이면 1톨부터 시작\n * - 55초부터는 1.92xx 이므로 반올림 시 1.9톨\n * - 59초부터는 1.98xx 이므로 반올림 시 2톨\n * - 60초부터는 2.00xx 이므로 반올림 시 2톨\n * - 62초부터는 2.03xx 이므로 반올림 시 2톨\n * - 63초부터는 2.05xx 이므로 반올림 시 2.1톨\n *\n */\n\ntype GetVideoDownloadCostParams = {\n duration: number;\n quality: '2K' | '4K';\n ticketCode?: TicketCode;\n remainingFreeDownloads?: number;\n\n /** @deprecated 이 파라미터는 더이상 사용되지 않습니다. */\n isFullTime?: boolean;\n};\nexport function getVideoDownloadCost({\n duration,\n quality,\n ticketCode = 'FREE',\n remainingFreeDownloads = 0,\n}: GetVideoDownloadCostParams) {\n if (quality === '4K') {\n return { cost: 20, isPlusFree: false };\n }\n\n const durationInSeconds = duration / 1000;\n const isUnder61 = durationInSeconds < 61;\n const isPlus = ticketCode === 'PLUS';\n\n if (isPlus && remainingFreeDownloads > 0 && isUnder61) {\n return { cost: 0, isPlusFree: true };\n }\n\n const costPerSecond = 1 / 60;\n const cost = Math.round(durationInSeconds * costPerSecond * 10) / 10;\n return { cost, isPlusFree: false };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC0BO,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,yBAAyB;AAC3B,GAA+B;AAC7B,MAAI,YAAY,MAAM;AACpB,WAAO,EAAE,MAAM,IAAI,YAAY,MAAM;AAAA,EACvC;AAEA,QAAM,oBAAoB,WAAW;AACrC,QAAM,YAAY,oBAAoB;AACtC,QAAM,SAAS,eAAe;AAE9B,MAAI,UAAU,yBAAyB,KAAK,WAAW;AACrD,WAAO,EAAE,MAAM,GAAG,YAAY,KAAK;AAAA,EACrC;AAEA,QAAM,gBAAgB,IAAI;AAC1B,QAAM,OAAO,KAAK,MAAM,oBAAoB,gBAAgB,EAAE,IAAI;AAClE,SAAO,EAAE,MAAM,YAAY,MAAM;AACnC;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/libs/cost.ts"],"sourcesContent":["// Main entry point for spoclip-kit\nexport * from './libs';\nexport * from './types';\n","import type { TicketCode } from '@/types/membership';\n\nconst CLIP_COST_PER_SECOND = 1 / 60;\n\n/**\n * 비디오 다운로드 비용을 계산합니다.\n *\n * @description\n * - 전체 시간 4K 다운로드 시 티켓 상관없이 20톨\n * - 1분 미만인 경우, remainingFreeDownloads > 0 이면 무료\n * - 1분 미만인 경우, remainingFreeDownloads <= 0 이면 1톨부터 시작\n * - 55초부터는 1.92xx 이므로 반올림 시 1.9톨\n * - 59초부터는 1.98xx 이므로 반올림 시 2톨\n * - 60초부터는 2.00xx 이므로 반올림 시 2톨\n * - 62초부터는 2.03xx 이므로 반올림 시 2톨\n * - 63초부터는 2.05xx 이므로 반올림 시 2.1톨\n *\n */\n\ntype GetVideoDownloadCostParams = {\n duration: number;\n quality: '2K' | '4K';\n ticketCode?: TicketCode;\n remainingFreeDownloads?: number;\n\n /** @deprecated 이 파라미터는 더이상 사용되지 않습니다. */\n isFullTime?: boolean;\n};\n\nexport function getVideoDownloadCost({\n duration,\n quality,\n ticketCode = 'FREE',\n remainingFreeDownloads = 0,\n}: GetVideoDownloadCostParams) {\n if (quality === '4K') {\n return getRawVideoDownloadCost();\n }\n\n return getClipVideoDownloadCost({\n duration,\n ticketCode,\n remainingFreeDownloads,\n });\n}\n\ntype GetClipVideoDownloadCostParams = {\n duration: number;\n ticketCode?: TicketCode;\n remainingFreeDownloads?: number;\n};\n\nexport function getClipVideoDownloadCost({\n duration,\n ticketCode = 'FREE',\n remainingFreeDownloads = 0,\n}: GetClipVideoDownloadCostParams) {\n const durationInSeconds = duration / 1000;\n const isUnder61 = durationInSeconds < 61;\n const isPlus = ticketCode === 'PLUS';\n\n if (isPlus && remainingFreeDownloads > 0 && isUnder61) {\n return { cost: 0, isPlusFree: true };\n }\n\n const cost = Math.round(durationInSeconds * CLIP_COST_PER_SECOND * 10) / 10;\n return { cost, isPlusFree: false };\n}\n\nexport function getRawVideoDownloadCost() {\n return { cost: 20, isPlusFree: false };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,IAAM,uBAAuB,IAAI;AA2B1B,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,yBAAyB;AAC3B,GAA+B;AAC7B,MAAI,YAAY,MAAM;AACpB,WAAO,wBAAwB;AAAA,EACjC;AAEA,SAAO,yBAAyB;AAAA,IAC9B;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;AAQO,SAAS,yBAAyB;AAAA,EACvC;AAAA,EACA,aAAa;AAAA,EACb,yBAAyB;AAC3B,GAAmC;AACjC,QAAM,oBAAoB,WAAW;AACrC,QAAM,YAAY,oBAAoB;AACtC,QAAM,SAAS,eAAe;AAE9B,MAAI,UAAU,yBAAyB,KAAK,WAAW;AACrD,WAAO,EAAE,MAAM,GAAG,YAAY,KAAK;AAAA,EACrC;AAEA,QAAM,OAAO,KAAK,MAAM,oBAAoB,uBAAuB,EAAE,IAAI;AACzE,SAAO,EAAE,MAAM,YAAY,MAAM;AACnC;AAEO,SAAS,0BAA0B;AACxC,SAAO,EAAE,MAAM,IAAI,YAAY,MAAM;AACvC;","names":[]}
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  // src/libs/cost.ts
2
+ var CLIP_COST_PER_SECOND = 1 / 60;
2
3
  function getVideoDownloadCost({
3
4
  duration,
4
5
  quality,
@@ -6,18 +7,31 @@ function getVideoDownloadCost({
6
7
  remainingFreeDownloads = 0
7
8
  }) {
8
9
  if (quality === "4K") {
9
- return { cost: 20, isPlusFree: false };
10
+ return getRawVideoDownloadCost();
10
11
  }
12
+ return getClipVideoDownloadCost({
13
+ duration,
14
+ ticketCode,
15
+ remainingFreeDownloads
16
+ });
17
+ }
18
+ function getClipVideoDownloadCost({
19
+ duration,
20
+ ticketCode = "FREE",
21
+ remainingFreeDownloads = 0
22
+ }) {
11
23
  const durationInSeconds = duration / 1e3;
12
24
  const isUnder61 = durationInSeconds < 61;
13
25
  const isPlus = ticketCode === "PLUS";
14
26
  if (isPlus && remainingFreeDownloads > 0 && isUnder61) {
15
27
  return { cost: 0, isPlusFree: true };
16
28
  }
17
- const costPerSecond = 1 / 60;
18
- const cost = Math.round(durationInSeconds * costPerSecond * 10) / 10;
29
+ const cost = Math.round(durationInSeconds * CLIP_COST_PER_SECOND * 10) / 10;
19
30
  return { cost, isPlusFree: false };
20
31
  }
32
+ function getRawVideoDownloadCost() {
33
+ return { cost: 20, isPlusFree: false };
34
+ }
21
35
  export {
22
36
  getVideoDownloadCost
23
37
  };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/libs/cost.ts"],"sourcesContent":["import type { TicketCode } from '@/types/membership';\n\n/**\n * 비디오 다운로드 비용을 계산합니다.\n *\n * @description\n * - 전체 시간 4K 다운로드 시 티켓 상관없이 20톨\n * - 1분 미만인 경우, remainingFreeDownloads > 0 이면 무료\n * - 1분 미만인 경우, remainingFreeDownloads <= 0 이면 1톨부터 시작\n * - 55초부터는 1.92xx 이므로 반올림 시 1.9톨\n * - 59초부터는 1.98xx 이므로 반올림 시 2톨\n * - 60초부터는 2.00xx 이므로 반올림 시 2톨\n * - 62초부터는 2.03xx 이므로 반올림 시 2톨\n * - 63초부터는 2.05xx 이므로 반올림 시 2.1톨\n *\n */\n\ntype GetVideoDownloadCostParams = {\n duration: number;\n quality: '2K' | '4K';\n ticketCode?: TicketCode;\n remainingFreeDownloads?: number;\n\n /** @deprecated 이 파라미터는 더이상 사용되지 않습니다. */\n isFullTime?: boolean;\n};\nexport function getVideoDownloadCost({\n duration,\n quality,\n ticketCode = 'FREE',\n remainingFreeDownloads = 0,\n}: GetVideoDownloadCostParams) {\n if (quality === '4K') {\n return { cost: 20, isPlusFree: false };\n }\n\n const durationInSeconds = duration / 1000;\n const isUnder61 = durationInSeconds < 61;\n const isPlus = ticketCode === 'PLUS';\n\n if (isPlus && remainingFreeDownloads > 0 && isUnder61) {\n return { cost: 0, isPlusFree: true };\n }\n\n const costPerSecond = 1 / 60;\n const cost = Math.round(durationInSeconds * costPerSecond * 10) / 10;\n return { cost, isPlusFree: false };\n}\n"],"mappings":";AA0BO,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,yBAAyB;AAC3B,GAA+B;AAC7B,MAAI,YAAY,MAAM;AACpB,WAAO,EAAE,MAAM,IAAI,YAAY,MAAM;AAAA,EACvC;AAEA,QAAM,oBAAoB,WAAW;AACrC,QAAM,YAAY,oBAAoB;AACtC,QAAM,SAAS,eAAe;AAE9B,MAAI,UAAU,yBAAyB,KAAK,WAAW;AACrD,WAAO,EAAE,MAAM,GAAG,YAAY,KAAK;AAAA,EACrC;AAEA,QAAM,gBAAgB,IAAI;AAC1B,QAAM,OAAO,KAAK,MAAM,oBAAoB,gBAAgB,EAAE,IAAI;AAClE,SAAO,EAAE,MAAM,YAAY,MAAM;AACnC;","names":[]}
1
+ {"version":3,"sources":["../src/libs/cost.ts"],"sourcesContent":["import type { TicketCode } from '@/types/membership';\n\nconst CLIP_COST_PER_SECOND = 1 / 60;\n\n/**\n * 비디오 다운로드 비용을 계산합니다.\n *\n * @description\n * - 전체 시간 4K 다운로드 시 티켓 상관없이 20톨\n * - 1분 미만인 경우, remainingFreeDownloads > 0 이면 무료\n * - 1분 미만인 경우, remainingFreeDownloads <= 0 이면 1톨부터 시작\n * - 55초부터는 1.92xx 이므로 반올림 시 1.9톨\n * - 59초부터는 1.98xx 이므로 반올림 시 2톨\n * - 60초부터는 2.00xx 이므로 반올림 시 2톨\n * - 62초부터는 2.03xx 이므로 반올림 시 2톨\n * - 63초부터는 2.05xx 이므로 반올림 시 2.1톨\n *\n */\n\ntype GetVideoDownloadCostParams = {\n duration: number;\n quality: '2K' | '4K';\n ticketCode?: TicketCode;\n remainingFreeDownloads?: number;\n\n /** @deprecated 이 파라미터는 더이상 사용되지 않습니다. */\n isFullTime?: boolean;\n};\n\nexport function getVideoDownloadCost({\n duration,\n quality,\n ticketCode = 'FREE',\n remainingFreeDownloads = 0,\n}: GetVideoDownloadCostParams) {\n if (quality === '4K') {\n return getRawVideoDownloadCost();\n }\n\n return getClipVideoDownloadCost({\n duration,\n ticketCode,\n remainingFreeDownloads,\n });\n}\n\ntype GetClipVideoDownloadCostParams = {\n duration: number;\n ticketCode?: TicketCode;\n remainingFreeDownloads?: number;\n};\n\nexport function getClipVideoDownloadCost({\n duration,\n ticketCode = 'FREE',\n remainingFreeDownloads = 0,\n}: GetClipVideoDownloadCostParams) {\n const durationInSeconds = duration / 1000;\n const isUnder61 = durationInSeconds < 61;\n const isPlus = ticketCode === 'PLUS';\n\n if (isPlus && remainingFreeDownloads > 0 && isUnder61) {\n return { cost: 0, isPlusFree: true };\n }\n\n const cost = Math.round(durationInSeconds * CLIP_COST_PER_SECOND * 10) / 10;\n return { cost, isPlusFree: false };\n}\n\nexport function getRawVideoDownloadCost() {\n return { cost: 20, isPlusFree: false };\n}\n"],"mappings":";AAEA,IAAM,uBAAuB,IAAI;AA2B1B,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,yBAAyB;AAC3B,GAA+B;AAC7B,MAAI,YAAY,MAAM;AACpB,WAAO,wBAAwB;AAAA,EACjC;AAEA,SAAO,yBAAyB;AAAA,IAC9B;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;AAQO,SAAS,yBAAyB;AAAA,EACvC;AAAA,EACA,aAAa;AAAA,EACb,yBAAyB;AAC3B,GAAmC;AACjC,QAAM,oBAAoB,WAAW;AACrC,QAAM,YAAY,oBAAoB;AACtC,QAAM,SAAS,eAAe;AAE9B,MAAI,UAAU,yBAAyB,KAAK,WAAW;AACrD,WAAO,EAAE,MAAM,GAAG,YAAY,KAAK;AAAA,EACrC;AAEA,QAAM,OAAO,KAAK,MAAM,oBAAoB,uBAAuB,EAAE,IAAI;AACzE,SAAO,EAAE,MAAM,YAAY,MAAM;AACnC;AAEO,SAAS,0BAA0B;AACxC,SAAO,EAAE,MAAM,IAAI,YAAY,MAAM;AACvC;","names":[]}
package/dist/libs.cjs CHANGED
@@ -25,6 +25,7 @@ __export(libs_exports, {
25
25
  module.exports = __toCommonJS(libs_exports);
26
26
 
27
27
  // src/libs/cost.ts
28
+ var CLIP_COST_PER_SECOND = 1 / 60;
28
29
  function getVideoDownloadCost({
29
30
  duration,
30
31
  quality,
@@ -32,18 +33,31 @@ function getVideoDownloadCost({
32
33
  remainingFreeDownloads = 0
33
34
  }) {
34
35
  if (quality === "4K") {
35
- return { cost: 20, isPlusFree: false };
36
+ return getRawVideoDownloadCost();
36
37
  }
38
+ return getClipVideoDownloadCost({
39
+ duration,
40
+ ticketCode,
41
+ remainingFreeDownloads
42
+ });
43
+ }
44
+ function getClipVideoDownloadCost({
45
+ duration,
46
+ ticketCode = "FREE",
47
+ remainingFreeDownloads = 0
48
+ }) {
37
49
  const durationInSeconds = duration / 1e3;
38
50
  const isUnder61 = durationInSeconds < 61;
39
51
  const isPlus = ticketCode === "PLUS";
40
52
  if (isPlus && remainingFreeDownloads > 0 && isUnder61) {
41
53
  return { cost: 0, isPlusFree: true };
42
54
  }
43
- const costPerSecond = 1 / 60;
44
- const cost = Math.round(durationInSeconds * costPerSecond * 10) / 10;
55
+ const cost = Math.round(durationInSeconds * CLIP_COST_PER_SECOND * 10) / 10;
45
56
  return { cost, isPlusFree: false };
46
57
  }
58
+ function getRawVideoDownloadCost() {
59
+ return { cost: 20, isPlusFree: false };
60
+ }
47
61
  // Annotate the CommonJS export names for ESM import in node:
48
62
  0 && (module.exports = {
49
63
  getVideoDownloadCost
package/dist/libs.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/libs/index.ts","../src/libs/cost.ts"],"sourcesContent":["export { getVideoDownloadCost } from './cost';\n","import type { TicketCode } from '@/types/membership';\n\n/**\n * 비디오 다운로드 비용을 계산합니다.\n *\n * @description\n * - 전체 시간 4K 다운로드 시 티켓 상관없이 20톨\n * - 1분 미만인 경우, remainingFreeDownloads > 0 이면 무료\n * - 1분 미만인 경우, remainingFreeDownloads <= 0 이면 1톨부터 시작\n * - 55초부터는 1.92xx 이므로 반올림 시 1.9톨\n * - 59초부터는 1.98xx 이므로 반올림 시 2톨\n * - 60초부터는 2.00xx 이므로 반올림 시 2톨\n * - 62초부터는 2.03xx 이므로 반올림 시 2톨\n * - 63초부터는 2.05xx 이므로 반올림 시 2.1톨\n *\n */\n\ntype GetVideoDownloadCostParams = {\n duration: number;\n quality: '2K' | '4K';\n ticketCode?: TicketCode;\n remainingFreeDownloads?: number;\n\n /** @deprecated 이 파라미터는 더이상 사용되지 않습니다. */\n isFullTime?: boolean;\n};\nexport function getVideoDownloadCost({\n duration,\n quality,\n ticketCode = 'FREE',\n remainingFreeDownloads = 0,\n}: GetVideoDownloadCostParams) {\n if (quality === '4K') {\n return { cost: 20, isPlusFree: false };\n }\n\n const durationInSeconds = duration / 1000;\n const isUnder61 = durationInSeconds < 61;\n const isPlus = ticketCode === 'PLUS';\n\n if (isPlus && remainingFreeDownloads > 0 && isUnder61) {\n return { cost: 0, isPlusFree: true };\n }\n\n const costPerSecond = 1 / 60;\n const cost = Math.round(durationInSeconds * costPerSecond * 10) / 10;\n return { cost, isPlusFree: false };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC0BO,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,yBAAyB;AAC3B,GAA+B;AAC7B,MAAI,YAAY,MAAM;AACpB,WAAO,EAAE,MAAM,IAAI,YAAY,MAAM;AAAA,EACvC;AAEA,QAAM,oBAAoB,WAAW;AACrC,QAAM,YAAY,oBAAoB;AACtC,QAAM,SAAS,eAAe;AAE9B,MAAI,UAAU,yBAAyB,KAAK,WAAW;AACrD,WAAO,EAAE,MAAM,GAAG,YAAY,KAAK;AAAA,EACrC;AAEA,QAAM,gBAAgB,IAAI;AAC1B,QAAM,OAAO,KAAK,MAAM,oBAAoB,gBAAgB,EAAE,IAAI;AAClE,SAAO,EAAE,MAAM,YAAY,MAAM;AACnC;","names":[]}
1
+ {"version":3,"sources":["../src/libs/index.ts","../src/libs/cost.ts"],"sourcesContent":["export { getVideoDownloadCost } from './cost';\n","import type { TicketCode } from '@/types/membership';\n\nconst CLIP_COST_PER_SECOND = 1 / 60;\n\n/**\n * 비디오 다운로드 비용을 계산합니다.\n *\n * @description\n * - 전체 시간 4K 다운로드 시 티켓 상관없이 20톨\n * - 1분 미만인 경우, remainingFreeDownloads > 0 이면 무료\n * - 1분 미만인 경우, remainingFreeDownloads <= 0 이면 1톨부터 시작\n * - 55초부터는 1.92xx 이므로 반올림 시 1.9톨\n * - 59초부터는 1.98xx 이므로 반올림 시 2톨\n * - 60초부터는 2.00xx 이므로 반올림 시 2톨\n * - 62초부터는 2.03xx 이므로 반올림 시 2톨\n * - 63초부터는 2.05xx 이므로 반올림 시 2.1톨\n *\n */\n\ntype GetVideoDownloadCostParams = {\n duration: number;\n quality: '2K' | '4K';\n ticketCode?: TicketCode;\n remainingFreeDownloads?: number;\n\n /** @deprecated 이 파라미터는 더이상 사용되지 않습니다. */\n isFullTime?: boolean;\n};\n\nexport function getVideoDownloadCost({\n duration,\n quality,\n ticketCode = 'FREE',\n remainingFreeDownloads = 0,\n}: GetVideoDownloadCostParams) {\n if (quality === '4K') {\n return getRawVideoDownloadCost();\n }\n\n return getClipVideoDownloadCost({\n duration,\n ticketCode,\n remainingFreeDownloads,\n });\n}\n\ntype GetClipVideoDownloadCostParams = {\n duration: number;\n ticketCode?: TicketCode;\n remainingFreeDownloads?: number;\n};\n\nexport function getClipVideoDownloadCost({\n duration,\n ticketCode = 'FREE',\n remainingFreeDownloads = 0,\n}: GetClipVideoDownloadCostParams) {\n const durationInSeconds = duration / 1000;\n const isUnder61 = durationInSeconds < 61;\n const isPlus = ticketCode === 'PLUS';\n\n if (isPlus && remainingFreeDownloads > 0 && isUnder61) {\n return { cost: 0, isPlusFree: true };\n }\n\n const cost = Math.round(durationInSeconds * CLIP_COST_PER_SECOND * 10) / 10;\n return { cost, isPlusFree: false };\n}\n\nexport function getRawVideoDownloadCost() {\n return { cost: 20, isPlusFree: false };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,IAAM,uBAAuB,IAAI;AA2B1B,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,yBAAyB;AAC3B,GAA+B;AAC7B,MAAI,YAAY,MAAM;AACpB,WAAO,wBAAwB;AAAA,EACjC;AAEA,SAAO,yBAAyB;AAAA,IAC9B;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;AAQO,SAAS,yBAAyB;AAAA,EACvC;AAAA,EACA,aAAa;AAAA,EACb,yBAAyB;AAC3B,GAAmC;AACjC,QAAM,oBAAoB,WAAW;AACrC,QAAM,YAAY,oBAAoB;AACtC,QAAM,SAAS,eAAe;AAE9B,MAAI,UAAU,yBAAyB,KAAK,WAAW;AACrD,WAAO,EAAE,MAAM,GAAG,YAAY,KAAK;AAAA,EACrC;AAEA,QAAM,OAAO,KAAK,MAAM,oBAAoB,uBAAuB,EAAE,IAAI;AACzE,SAAO,EAAE,MAAM,YAAY,MAAM;AACnC;AAEO,SAAS,0BAA0B;AACxC,SAAO,EAAE,MAAM,IAAI,YAAY,MAAM;AACvC;","names":[]}
package/dist/libs.js CHANGED
@@ -1,4 +1,5 @@
1
1
  // src/libs/cost.ts
2
+ var CLIP_COST_PER_SECOND = 1 / 60;
2
3
  function getVideoDownloadCost({
3
4
  duration,
4
5
  quality,
@@ -6,18 +7,31 @@ function getVideoDownloadCost({
6
7
  remainingFreeDownloads = 0
7
8
  }) {
8
9
  if (quality === "4K") {
9
- return { cost: 20, isPlusFree: false };
10
+ return getRawVideoDownloadCost();
10
11
  }
12
+ return getClipVideoDownloadCost({
13
+ duration,
14
+ ticketCode,
15
+ remainingFreeDownloads
16
+ });
17
+ }
18
+ function getClipVideoDownloadCost({
19
+ duration,
20
+ ticketCode = "FREE",
21
+ remainingFreeDownloads = 0
22
+ }) {
11
23
  const durationInSeconds = duration / 1e3;
12
24
  const isUnder61 = durationInSeconds < 61;
13
25
  const isPlus = ticketCode === "PLUS";
14
26
  if (isPlus && remainingFreeDownloads > 0 && isUnder61) {
15
27
  return { cost: 0, isPlusFree: true };
16
28
  }
17
- const costPerSecond = 1 / 60;
18
- const cost = Math.round(durationInSeconds * costPerSecond * 10) / 10;
29
+ const cost = Math.round(durationInSeconds * CLIP_COST_PER_SECOND * 10) / 10;
19
30
  return { cost, isPlusFree: false };
20
31
  }
32
+ function getRawVideoDownloadCost() {
33
+ return { cost: 20, isPlusFree: false };
34
+ }
21
35
  export {
22
36
  getVideoDownloadCost
23
37
  };
package/dist/libs.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/libs/cost.ts"],"sourcesContent":["import type { TicketCode } from '@/types/membership';\n\n/**\n * 비디오 다운로드 비용을 계산합니다.\n *\n * @description\n * - 전체 시간 4K 다운로드 시 티켓 상관없이 20톨\n * - 1분 미만인 경우, remainingFreeDownloads > 0 이면 무료\n * - 1분 미만인 경우, remainingFreeDownloads <= 0 이면 1톨부터 시작\n * - 55초부터는 1.92xx 이므로 반올림 시 1.9톨\n * - 59초부터는 1.98xx 이므로 반올림 시 2톨\n * - 60초부터는 2.00xx 이므로 반올림 시 2톨\n * - 62초부터는 2.03xx 이므로 반올림 시 2톨\n * - 63초부터는 2.05xx 이므로 반올림 시 2.1톨\n *\n */\n\ntype GetVideoDownloadCostParams = {\n duration: number;\n quality: '2K' | '4K';\n ticketCode?: TicketCode;\n remainingFreeDownloads?: number;\n\n /** @deprecated 이 파라미터는 더이상 사용되지 않습니다. */\n isFullTime?: boolean;\n};\nexport function getVideoDownloadCost({\n duration,\n quality,\n ticketCode = 'FREE',\n remainingFreeDownloads = 0,\n}: GetVideoDownloadCostParams) {\n if (quality === '4K') {\n return { cost: 20, isPlusFree: false };\n }\n\n const durationInSeconds = duration / 1000;\n const isUnder61 = durationInSeconds < 61;\n const isPlus = ticketCode === 'PLUS';\n\n if (isPlus && remainingFreeDownloads > 0 && isUnder61) {\n return { cost: 0, isPlusFree: true };\n }\n\n const costPerSecond = 1 / 60;\n const cost = Math.round(durationInSeconds * costPerSecond * 10) / 10;\n return { cost, isPlusFree: false };\n}\n"],"mappings":";AA0BO,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,yBAAyB;AAC3B,GAA+B;AAC7B,MAAI,YAAY,MAAM;AACpB,WAAO,EAAE,MAAM,IAAI,YAAY,MAAM;AAAA,EACvC;AAEA,QAAM,oBAAoB,WAAW;AACrC,QAAM,YAAY,oBAAoB;AACtC,QAAM,SAAS,eAAe;AAE9B,MAAI,UAAU,yBAAyB,KAAK,WAAW;AACrD,WAAO,EAAE,MAAM,GAAG,YAAY,KAAK;AAAA,EACrC;AAEA,QAAM,gBAAgB,IAAI;AAC1B,QAAM,OAAO,KAAK,MAAM,oBAAoB,gBAAgB,EAAE,IAAI;AAClE,SAAO,EAAE,MAAM,YAAY,MAAM;AACnC;","names":[]}
1
+ {"version":3,"sources":["../src/libs/cost.ts"],"sourcesContent":["import type { TicketCode } from '@/types/membership';\n\nconst CLIP_COST_PER_SECOND = 1 / 60;\n\n/**\n * 비디오 다운로드 비용을 계산합니다.\n *\n * @description\n * - 전체 시간 4K 다운로드 시 티켓 상관없이 20톨\n * - 1분 미만인 경우, remainingFreeDownloads > 0 이면 무료\n * - 1분 미만인 경우, remainingFreeDownloads <= 0 이면 1톨부터 시작\n * - 55초부터는 1.92xx 이므로 반올림 시 1.9톨\n * - 59초부터는 1.98xx 이므로 반올림 시 2톨\n * - 60초부터는 2.00xx 이므로 반올림 시 2톨\n * - 62초부터는 2.03xx 이므로 반올림 시 2톨\n * - 63초부터는 2.05xx 이므로 반올림 시 2.1톨\n *\n */\n\ntype GetVideoDownloadCostParams = {\n duration: number;\n quality: '2K' | '4K';\n ticketCode?: TicketCode;\n remainingFreeDownloads?: number;\n\n /** @deprecated 이 파라미터는 더이상 사용되지 않습니다. */\n isFullTime?: boolean;\n};\n\nexport function getVideoDownloadCost({\n duration,\n quality,\n ticketCode = 'FREE',\n remainingFreeDownloads = 0,\n}: GetVideoDownloadCostParams) {\n if (quality === '4K') {\n return getRawVideoDownloadCost();\n }\n\n return getClipVideoDownloadCost({\n duration,\n ticketCode,\n remainingFreeDownloads,\n });\n}\n\ntype GetClipVideoDownloadCostParams = {\n duration: number;\n ticketCode?: TicketCode;\n remainingFreeDownloads?: number;\n};\n\nexport function getClipVideoDownloadCost({\n duration,\n ticketCode = 'FREE',\n remainingFreeDownloads = 0,\n}: GetClipVideoDownloadCostParams) {\n const durationInSeconds = duration / 1000;\n const isUnder61 = durationInSeconds < 61;\n const isPlus = ticketCode === 'PLUS';\n\n if (isPlus && remainingFreeDownloads > 0 && isUnder61) {\n return { cost: 0, isPlusFree: true };\n }\n\n const cost = Math.round(durationInSeconds * CLIP_COST_PER_SECOND * 10) / 10;\n return { cost, isPlusFree: false };\n}\n\nexport function getRawVideoDownloadCost() {\n return { cost: 20, isPlusFree: false };\n}\n"],"mappings":";AAEA,IAAM,uBAAuB,IAAI;AA2B1B,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,yBAAyB;AAC3B,GAA+B;AAC7B,MAAI,YAAY,MAAM;AACpB,WAAO,wBAAwB;AAAA,EACjC;AAEA,SAAO,yBAAyB;AAAA,IAC9B;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;AAQO,SAAS,yBAAyB;AAAA,EACvC;AAAA,EACA,aAAa;AAAA,EACb,yBAAyB;AAC3B,GAAmC;AACjC,QAAM,oBAAoB,WAAW;AACrC,QAAM,YAAY,oBAAoB;AACtC,QAAM,SAAS,eAAe;AAE9B,MAAI,UAAU,yBAAyB,KAAK,WAAW;AACrD,WAAO,EAAE,MAAM,GAAG,YAAY,KAAK;AAAA,EACrC;AAEA,QAAM,OAAO,KAAK,MAAM,oBAAoB,uBAAuB,EAAE,IAAI;AACzE,SAAO,EAAE,MAAM,YAAY,MAAM;AACnC;AAEO,SAAS,0BAA0B;AACxC,SAAO,EAAE,MAAM,IAAI,YAAY,MAAM;AACvC;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spoclip-kit",
3
- "version": "1.0.17",
3
+ "version": "1.0.18",
4
4
  "type": "module",
5
5
  "description": "TypeScript utility library for internal use",
6
6
  "files": [