@reela/credits 3.0.0 → 3.1.1

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.
@@ -1,9 +1,36 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ calculateAssetCredits: () => calculateAssetCredits,
24
+ calculateAvatarCredits: () => calculateAvatarCredits,
25
+ calculateTaskCredits: () => calculateTaskCredits,
26
+ estimateTaskCredits: () => estimateTaskCredits
27
+ });
28
+ module.exports = __toCommonJS(index_exports);
29
+
1
30
  // src/constants/shot-type.ts
2
31
  var shotType = {
3
- aiv: "AIV",
4
- aivr: "AIVReference",
5
- aii: "AII",
6
- aiir: "AIIReference"
32
+ video: "video",
33
+ image: "image"
7
34
  };
8
35
 
9
36
  // src/constants/tier.ts
@@ -15,26 +42,6 @@ var tier = {
15
42
  ultra: "ultra"
16
43
  };
17
44
 
18
- // src/constants/mode.ts
19
- var mode = {
20
- studio: "studio",
21
- reference: "reference",
22
- remix: "remix",
23
- presenter: "presenter"
24
- };
25
-
26
- // src/constants/visual.ts
27
- var visual = {
28
- aiv: "AIV",
29
- oiv: "OIV",
30
- aivr: "AIV_REFERENCE",
31
- aia: "AIA",
32
- aiar: "AIA_REFERENCE",
33
- ovs: "OVS",
34
- ova: "OVA_VISUAL",
35
- webv: "WEBV"
36
- };
37
-
38
45
  // src/get-key.ts
39
46
  function getKey(pipeline) {
40
47
  const { tier: tier2 = "default", type = "default", cameraPosition = 1, visual: visual2 = [] } = pipeline;
@@ -44,65 +51,87 @@ function getKey(pipeline) {
44
51
  }
45
52
 
46
53
  // src/asset-credits.ts
54
+ var IMAGE_CREDITS = 3;
47
55
  var creditsMap = {
48
- [getKey({ type: shotType.aii, tier: tier.photo })]: 3,
49
- [getKey({ type: shotType.aiv, tier: tier.lite })]: 25,
50
- [getKey({ type: shotType.aiv, tier: tier.pro })]: 25,
51
- [getKey({ type: shotType.aiv, tier: tier.max })]: 250,
52
- [getKey({ type: shotType.aiv, tier: tier.ultra })]: 250,
53
- [getKey({ type: shotType.aiir, tier: tier.photo })]: 5,
54
- [getKey({ type: shotType.aivr, tier: tier.lite })]: 25,
55
- [getKey({ type: shotType.aivr, tier: tier.pro })]: 45,
56
- [getKey({ type: shotType.aivr, tier: tier.max })]: 250,
57
- [getKey({ type: shotType.aivr, tier: tier.ultra })]: 250
58
- };
59
- var getShotType = (pipeline) => {
60
- if (pipeline.type) {
61
- switch (pipeline.type) {
62
- case mode.reference:
63
- if (pipeline.tier === "photo") {
64
- return shotType.aiir;
65
- }
66
- return shotType.aivr;
67
- case mode.studio:
68
- case mode.remix:
69
- case mode.presenter:
70
- if (pipeline.tier === "photo") {
71
- return shotType.aii;
72
- }
73
- return shotType.aiv;
74
- default:
75
- break;
76
- }
56
+ [getKey({ type: shotType.video, tier: tier.lite })]: {
57
+ 1: 2,
58
+ 2: 4,
59
+ 3: 6,
60
+ 4: 8,
61
+ 5: 10,
62
+ 6: 12,
63
+ 7: 14,
64
+ 8: 16
65
+ },
66
+ [getKey({ type: shotType.video, tier: tier.pro })]: {
67
+ 1: 10,
68
+ 2: 13,
69
+ 3: 13,
70
+ 4: 16,
71
+ 5: 16,
72
+ 6: 19,
73
+ 7: 19,
74
+ 8: 22
75
+ },
76
+ [getKey({ type: shotType.video, tier: tier.max })]: {
77
+ 1: 20,
78
+ 2: 25,
79
+ 3: 32,
80
+ 4: 38,
81
+ 5: 44,
82
+ 6: 50,
83
+ 7: 57,
84
+ 8: 63
85
+ },
86
+ [getKey({ type: shotType.video, tier: tier.ultra })]: {
87
+ 1: 20,
88
+ 2: 25,
89
+ 3: 32,
90
+ 4: 38,
91
+ 5: 44,
92
+ 6: 50,
93
+ 7: 57,
94
+ 8: 63
77
95
  }
78
- if (pipeline.visual && pipeline.visual.length > 0) {
79
- if (pipeline.visual.includes(visual.aiv) || pipeline.visual.includes(visual.oiv)) {
80
- if (pipeline.tier === "photo") {
81
- return shotType.aii;
82
- }
83
- return shotType.aiv;
84
- }
85
- if (pipeline.visual.includes(visual.aivr) || pipeline.visual.includes(visual.aiar)) {
86
- if (pipeline.tier === "photo") {
87
- return shotType.aiir;
88
- }
89
- return shotType.aivr;
90
- }
91
- }
92
- throw new Error(`Invalid pipeline, get pipeline ${JSON.stringify(pipeline)}`);
93
96
  };
94
- function calculateAssetCredits(pipeline) {
95
- if (typeof pipeline !== "object" || pipeline === null || Array.isArray(pipeline)) {
97
+ function calculateAssetCredits(params) {
98
+ if (typeof params !== "object" || params === null || Array.isArray(params)) {
96
99
  throw new Error("Pipeline must be an object");
97
100
  }
98
- const shotType2 = getShotType(pipeline);
99
- const credits = creditsMap[getKey({ type: shotType2, tier: pipeline.tier })];
101
+ const duraion = Math.min(Math.ceil(params.duraion || 0), 8);
102
+ let credits;
103
+ switch (params.type) {
104
+ case shotType.image:
105
+ credits = IMAGE_CREDITS;
106
+ break;
107
+ case shotType.video:
108
+ const m = creditsMap[getKey({ type: params.type, tier: params.tier })];
109
+ if (!m) {
110
+ break;
111
+ }
112
+ credits = m[duraion];
113
+ break;
114
+ default:
115
+ break;
116
+ }
100
117
  if (typeof credits === "undefined") {
101
- throw new Error(`Invalid pipeline, get pipeline ${JSON.stringify(pipeline)}`);
118
+ throw new Error(`Invalid pipeline, get pipeline ${JSON.stringify(params)}`);
102
119
  }
103
120
  return credits;
104
121
  }
105
122
 
123
+ // src/constants/visual.ts
124
+ var visual = {
125
+ aiv: "AIV",
126
+ oiv: "OIV",
127
+ aivr: "AIV_REFERENCE",
128
+ aia: "AIA",
129
+ aiar: "AIA_REFERENCE",
130
+ ovs: "OVS",
131
+ ova: "OVA_VISUAL",
132
+ webv: "WEBV"
133
+ };
134
+
106
135
  // src/task-credits.ts
107
136
  var unitCredits = {
108
137
  // AIV/OIV
@@ -113,13 +142,13 @@ var unitCredits = {
113
142
  [getKey({ visual: [visual.aiv], tier: tier.ultra })]: 100,
114
143
  // AIV_REFERENCE
115
144
  [getKey({ visual: [visual.aivr], tier: tier.photo })]: 5,
116
- [getKey({ visual: [visual.aivr], tier: tier.lite })]: 25,
117
- [getKey({ visual: [visual.aivr], tier: tier.pro })]: 25,
118
- [getKey({ visual: [visual.aivr], tier: tier.max })]: 100,
119
- [getKey({ visual: [visual.aivr], tier: tier.ultra })]: 100,
145
+ [getKey({ visual: [visual.aivr], tier: tier.lite })]: 15,
146
+ [getKey({ visual: [visual.aivr], tier: tier.pro })]: 20,
147
+ [getKey({ visual: [visual.aivr], tier: tier.max })]: 40,
148
+ [getKey({ visual: [visual.aivr], tier: tier.ultra })]: 40,
120
149
  // AIA/AIA_REFERENCE
121
- [getKey({ visual: [visual.aia], tier: tier.lite })]: 5,
122
- [getKey({ visual: [visual.aia], tier: tier.pro })]: 5,
150
+ [getKey({ visual: [visual.aia], tier: tier.lite })]: 15,
151
+ [getKey({ visual: [visual.aia], tier: tier.pro })]: 20,
123
152
  [getKey({ visual: [visual.aia], tier: tier.max })]: 40,
124
153
  [getKey({ visual: [visual.aia], tier: tier.ultra })]: 40,
125
154
  // OVS/OVA
@@ -196,11 +225,12 @@ function getShotCredits(visualType, tier2, duration, cameraPosition = 1) {
196
225
 
197
226
  // src/avatar-credits.ts
198
227
  function calculateAvatarCredits() {
199
- return 400;
228
+ return 200;
200
229
  }
201
- export {
230
+ // Annotate the CommonJS export names for ESM import in node:
231
+ 0 && (module.exports = {
202
232
  calculateAssetCredits,
203
233
  calculateAvatarCredits,
204
234
  calculateTaskCredits,
205
235
  estimateTaskCredits
206
- };
236
+ });
@@ -1,11 +1,8 @@
1
- interface Pipeline {
1
+ declare function calculateAssetCredits(params: {
2
+ type: string;
2
3
  tier: string;
3
- type?: string;
4
- cameraPosition?: number;
5
- visual: string[];
6
- }
7
-
8
- declare function calculateAssetCredits(pipeline: Pipeline): number;
4
+ duraion?: number;
5
+ }): number;
9
6
 
10
7
  interface CalculateTaskCreditsParams {
11
8
  durationOfShots: Array<{
package/index.d.ts CHANGED
@@ -1,11 +1,8 @@
1
- interface Pipeline {
1
+ declare function calculateAssetCredits(params: {
2
+ type: string;
2
3
  tier: string;
3
- type?: string;
4
- cameraPosition?: number;
5
- visual: string[];
6
- }
7
-
8
- declare function calculateAssetCredits(pipeline: Pipeline): number;
4
+ duraion?: number;
5
+ }): number;
9
6
 
10
7
  interface CalculateTaskCreditsParams {
11
8
  durationOfShots: Array<{
package/index.js CHANGED
@@ -1,38 +1,7 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- calculateAssetCredits: () => calculateAssetCredits,
24
- calculateAvatarCredits: () => calculateAvatarCredits,
25
- calculateTaskCredits: () => calculateTaskCredits,
26
- estimateTaskCredits: () => estimateTaskCredits
27
- });
28
- module.exports = __toCommonJS(index_exports);
29
-
30
1
  // src/constants/shot-type.ts
31
2
  var shotType = {
32
- aiv: "AIV",
33
- aivr: "AIVReference",
34
- aii: "AII",
35
- aiir: "AIIReference"
3
+ video: "video",
4
+ image: "image"
36
5
  };
37
6
 
38
7
  // src/constants/tier.ts
@@ -44,26 +13,6 @@ var tier = {
44
13
  ultra: "ultra"
45
14
  };
46
15
 
47
- // src/constants/mode.ts
48
- var mode = {
49
- studio: "studio",
50
- reference: "reference",
51
- remix: "remix",
52
- presenter: "presenter"
53
- };
54
-
55
- // src/constants/visual.ts
56
- var visual = {
57
- aiv: "AIV",
58
- oiv: "OIV",
59
- aivr: "AIV_REFERENCE",
60
- aia: "AIA",
61
- aiar: "AIA_REFERENCE",
62
- ovs: "OVS",
63
- ova: "OVA_VISUAL",
64
- webv: "WEBV"
65
- };
66
-
67
16
  // src/get-key.ts
68
17
  function getKey(pipeline) {
69
18
  const { tier: tier2 = "default", type = "default", cameraPosition = 1, visual: visual2 = [] } = pipeline;
@@ -73,65 +22,87 @@ function getKey(pipeline) {
73
22
  }
74
23
 
75
24
  // src/asset-credits.ts
25
+ var IMAGE_CREDITS = 3;
76
26
  var creditsMap = {
77
- [getKey({ type: shotType.aii, tier: tier.photo })]: 3,
78
- [getKey({ type: shotType.aiv, tier: tier.lite })]: 25,
79
- [getKey({ type: shotType.aiv, tier: tier.pro })]: 25,
80
- [getKey({ type: shotType.aiv, tier: tier.max })]: 250,
81
- [getKey({ type: shotType.aiv, tier: tier.ultra })]: 250,
82
- [getKey({ type: shotType.aiir, tier: tier.photo })]: 5,
83
- [getKey({ type: shotType.aivr, tier: tier.lite })]: 25,
84
- [getKey({ type: shotType.aivr, tier: tier.pro })]: 45,
85
- [getKey({ type: shotType.aivr, tier: tier.max })]: 250,
86
- [getKey({ type: shotType.aivr, tier: tier.ultra })]: 250
87
- };
88
- var getShotType = (pipeline) => {
89
- if (pipeline.type) {
90
- switch (pipeline.type) {
91
- case mode.reference:
92
- if (pipeline.tier === "photo") {
93
- return shotType.aiir;
94
- }
95
- return shotType.aivr;
96
- case mode.studio:
97
- case mode.remix:
98
- case mode.presenter:
99
- if (pipeline.tier === "photo") {
100
- return shotType.aii;
101
- }
102
- return shotType.aiv;
103
- default:
104
- break;
105
- }
27
+ [getKey({ type: shotType.video, tier: tier.lite })]: {
28
+ 1: 2,
29
+ 2: 4,
30
+ 3: 6,
31
+ 4: 8,
32
+ 5: 10,
33
+ 6: 12,
34
+ 7: 14,
35
+ 8: 16
36
+ },
37
+ [getKey({ type: shotType.video, tier: tier.pro })]: {
38
+ 1: 10,
39
+ 2: 13,
40
+ 3: 13,
41
+ 4: 16,
42
+ 5: 16,
43
+ 6: 19,
44
+ 7: 19,
45
+ 8: 22
46
+ },
47
+ [getKey({ type: shotType.video, tier: tier.max })]: {
48
+ 1: 20,
49
+ 2: 25,
50
+ 3: 32,
51
+ 4: 38,
52
+ 5: 44,
53
+ 6: 50,
54
+ 7: 57,
55
+ 8: 63
56
+ },
57
+ [getKey({ type: shotType.video, tier: tier.ultra })]: {
58
+ 1: 20,
59
+ 2: 25,
60
+ 3: 32,
61
+ 4: 38,
62
+ 5: 44,
63
+ 6: 50,
64
+ 7: 57,
65
+ 8: 63
106
66
  }
107
- if (pipeline.visual && pipeline.visual.length > 0) {
108
- if (pipeline.visual.includes(visual.aiv) || pipeline.visual.includes(visual.oiv)) {
109
- if (pipeline.tier === "photo") {
110
- return shotType.aii;
111
- }
112
- return shotType.aiv;
113
- }
114
- if (pipeline.visual.includes(visual.aivr) || pipeline.visual.includes(visual.aiar)) {
115
- if (pipeline.tier === "photo") {
116
- return shotType.aiir;
117
- }
118
- return shotType.aivr;
119
- }
120
- }
121
- throw new Error(`Invalid pipeline, get pipeline ${JSON.stringify(pipeline)}`);
122
67
  };
123
- function calculateAssetCredits(pipeline) {
124
- if (typeof pipeline !== "object" || pipeline === null || Array.isArray(pipeline)) {
68
+ function calculateAssetCredits(params) {
69
+ if (typeof params !== "object" || params === null || Array.isArray(params)) {
125
70
  throw new Error("Pipeline must be an object");
126
71
  }
127
- const shotType2 = getShotType(pipeline);
128
- const credits = creditsMap[getKey({ type: shotType2, tier: pipeline.tier })];
72
+ const duraion = Math.min(Math.ceil(params.duraion || 0), 8);
73
+ let credits;
74
+ switch (params.type) {
75
+ case shotType.image:
76
+ credits = IMAGE_CREDITS;
77
+ break;
78
+ case shotType.video:
79
+ const m = creditsMap[getKey({ type: params.type, tier: params.tier })];
80
+ if (!m) {
81
+ break;
82
+ }
83
+ credits = m[duraion];
84
+ break;
85
+ default:
86
+ break;
87
+ }
129
88
  if (typeof credits === "undefined") {
130
- throw new Error(`Invalid pipeline, get pipeline ${JSON.stringify(pipeline)}`);
89
+ throw new Error(`Invalid pipeline, get pipeline ${JSON.stringify(params)}`);
131
90
  }
132
91
  return credits;
133
92
  }
134
93
 
94
+ // src/constants/visual.ts
95
+ var visual = {
96
+ aiv: "AIV",
97
+ oiv: "OIV",
98
+ aivr: "AIV_REFERENCE",
99
+ aia: "AIA",
100
+ aiar: "AIA_REFERENCE",
101
+ ovs: "OVS",
102
+ ova: "OVA_VISUAL",
103
+ webv: "WEBV"
104
+ };
105
+
135
106
  // src/task-credits.ts
136
107
  var unitCredits = {
137
108
  // AIV/OIV
@@ -142,13 +113,13 @@ var unitCredits = {
142
113
  [getKey({ visual: [visual.aiv], tier: tier.ultra })]: 100,
143
114
  // AIV_REFERENCE
144
115
  [getKey({ visual: [visual.aivr], tier: tier.photo })]: 5,
145
- [getKey({ visual: [visual.aivr], tier: tier.lite })]: 25,
146
- [getKey({ visual: [visual.aivr], tier: tier.pro })]: 25,
147
- [getKey({ visual: [visual.aivr], tier: tier.max })]: 100,
148
- [getKey({ visual: [visual.aivr], tier: tier.ultra })]: 100,
116
+ [getKey({ visual: [visual.aivr], tier: tier.lite })]: 15,
117
+ [getKey({ visual: [visual.aivr], tier: tier.pro })]: 20,
118
+ [getKey({ visual: [visual.aivr], tier: tier.max })]: 40,
119
+ [getKey({ visual: [visual.aivr], tier: tier.ultra })]: 40,
149
120
  // AIA/AIA_REFERENCE
150
- [getKey({ visual: [visual.aia], tier: tier.lite })]: 5,
151
- [getKey({ visual: [visual.aia], tier: tier.pro })]: 5,
121
+ [getKey({ visual: [visual.aia], tier: tier.lite })]: 15,
122
+ [getKey({ visual: [visual.aia], tier: tier.pro })]: 20,
152
123
  [getKey({ visual: [visual.aia], tier: tier.max })]: 40,
153
124
  [getKey({ visual: [visual.aia], tier: tier.ultra })]: 40,
154
125
  // OVS/OVA
@@ -225,12 +196,11 @@ function getShotCredits(visualType, tier2, duration, cameraPosition = 1) {
225
196
 
226
197
  // src/avatar-credits.ts
227
198
  function calculateAvatarCredits() {
228
- return 400;
199
+ return 200;
229
200
  }
230
- // Annotate the CommonJS export names for ESM import in node:
231
- 0 && (module.exports = {
201
+ export {
232
202
  calculateAssetCredits,
233
203
  calculateAvatarCredits,
234
204
  calculateTaskCredits,
235
205
  estimateTaskCredits
236
- });
206
+ };
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@reela/credits",
3
- "version": "3.0.0",
3
+ "version": "3.1.1",
4
4
  "main": "index.js",
5
5
  "types": "./index.d.ts",
6
6
  "exports": {
7
7
  ".": {
8
- "import": "./index.mjs",
9
- "require": "./index.js",
8
+ "import": "./index.js",
9
+ "require": "./index.cjs",
10
10
  "types": "./index.d.ts"
11
11
  }
12
12
  },