@ollang-dev/sdk 0.3.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.
- package/bin/tms.js +47 -0
- package/dist/browser/index.d.ts +143 -0
- package/dist/browser/index.js +2336 -0
- package/dist/browser/ollang-browser.min.js +1 -0
- package/dist/browser/script-loader.d.ts +1 -0
- package/dist/browser/script-loader.js +53 -0
- package/dist/client.d.ts +13 -0
- package/dist/client.js +60 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +74 -0
- package/dist/resources/cms.d.ts +29 -0
- package/dist/resources/cms.js +34 -0
- package/dist/resources/customInstructions.d.ts +11 -0
- package/dist/resources/customInstructions.js +24 -0
- package/dist/resources/orders.d.ts +13 -0
- package/dist/resources/orders.js +65 -0
- package/dist/resources/projects.d.ts +8 -0
- package/dist/resources/projects.js +29 -0
- package/dist/resources/revisions.d.ts +9 -0
- package/dist/resources/revisions.js +18 -0
- package/dist/resources/scans.d.ts +38 -0
- package/dist/resources/scans.js +52 -0
- package/dist/resources/uploads.d.ts +8 -0
- package/dist/resources/uploads.js +25 -0
- package/dist/tms/config.d.ts +16 -0
- package/dist/tms/config.js +172 -0
- package/dist/tms/detector/audio-detector.d.ts +27 -0
- package/dist/tms/detector/audio-detector.js +168 -0
- package/dist/tms/detector/auto-detect.d.ts +1 -0
- package/dist/tms/detector/auto-detect.js +152 -0
- package/dist/tms/detector/cms-detector.d.ts +17 -0
- package/dist/tms/detector/cms-detector.js +94 -0
- package/dist/tms/detector/content-type-detector.d.ts +79 -0
- package/dist/tms/detector/content-type-detector.js +2 -0
- package/dist/tms/detector/hardcoded-detector.d.ts +11 -0
- package/dist/tms/detector/hardcoded-detector.js +154 -0
- package/dist/tms/detector/i18n-detector.d.ts +16 -0
- package/dist/tms/detector/i18n-detector.js +311 -0
- package/dist/tms/detector/image-detector.d.ts +11 -0
- package/dist/tms/detector/image-detector.js +170 -0
- package/dist/tms/detector/text-detector.d.ts +9 -0
- package/dist/tms/detector/text-detector.js +35 -0
- package/dist/tms/detector/video-detector.d.ts +12 -0
- package/dist/tms/detector/video-detector.js +188 -0
- package/dist/tms/index.d.ts +12 -0
- package/dist/tms/index.js +38 -0
- package/dist/tms/multi-content-tms.d.ts +42 -0
- package/dist/tms/multi-content-tms.js +230 -0
- package/dist/tms/server/index.d.ts +1 -0
- package/dist/tms/server/index.js +1473 -0
- package/dist/tms/server/strapi-pusher.d.ts +31 -0
- package/dist/tms/server/strapi-pusher.js +296 -0
- package/dist/tms/server/strapi-schema.d.ts +47 -0
- package/dist/tms/server/strapi-schema.js +93 -0
- package/dist/tms/tms.d.ts +48 -0
- package/dist/tms/tms.js +875 -0
- package/dist/tms/types.d.ts +189 -0
- package/dist/tms/types.js +2 -0
- package/dist/tms/ui-dist/assets/index-5U1Hw3uo.css +1 -0
- package/dist/tms/ui-dist/assets/index-HvrqZV5Z.js +149 -0
- package/dist/tms/ui-dist/index.html +14 -0
- package/dist/types/index.d.ts +174 -0
- package/dist/types/index.js +2 -0
- package/package.json +98 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ContentDetector, ImageContent, DetectionConfig } from './content-type-detector.js';
|
|
2
|
+
export declare class ImageDetector implements ContentDetector<ImageContent> {
|
|
3
|
+
supports(filePath: string): boolean;
|
|
4
|
+
detect(projectRoot: string, config: DetectionConfig): Promise<ImageContent[]>;
|
|
5
|
+
private scanDirectory;
|
|
6
|
+
private analyzeImage;
|
|
7
|
+
private shouldExclude;
|
|
8
|
+
private scanForImageUrls;
|
|
9
|
+
private extractImageUrls;
|
|
10
|
+
private getFormatFromUrl;
|
|
11
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ImageDetector = void 0;
|
|
37
|
+
const fs = __importStar(require("fs/promises"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const IMAGE_EXTENSIONS = ['.png', '.jpg', '.jpeg', '.gif', '.webp', '.bmp'];
|
|
40
|
+
const IMAGE_URL_PATTERNS = [
|
|
41
|
+
/https?:\/\/[^\s"']+\.png/gi,
|
|
42
|
+
/https?:\/\/[^\s"']+\.jpg/gi,
|
|
43
|
+
/https?:\/\/[^\s"']+\.jpeg/gi,
|
|
44
|
+
/https?:\/\/[^\s"']+\.gif/gi,
|
|
45
|
+
/https?:\/\/[^\s"']+\.webp/gi,
|
|
46
|
+
/https?:\/\/[^\s"']*amazonaws\.com[^\s"']*\.(png|jpg|jpeg|gif|webp)/gi,
|
|
47
|
+
/https?:\/\/[^\s"']*cloudfront\.net[^\s"']*\.(png|jpg|jpeg|gif|webp)/gi,
|
|
48
|
+
];
|
|
49
|
+
class ImageDetector {
|
|
50
|
+
supports(filePath) {
|
|
51
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
52
|
+
return IMAGE_EXTENSIONS.includes(ext);
|
|
53
|
+
}
|
|
54
|
+
async detect(projectRoot, config) {
|
|
55
|
+
const images = [];
|
|
56
|
+
for (const includePath of config.includePaths) {
|
|
57
|
+
const fullPath = path.join(projectRoot, includePath);
|
|
58
|
+
const physicalImages = await this.scanDirectory(fullPath, config.excludePaths);
|
|
59
|
+
images.push(...physicalImages);
|
|
60
|
+
const urlImages = await this.scanForImageUrls(fullPath, config.excludePaths);
|
|
61
|
+
images.push(...urlImages);
|
|
62
|
+
}
|
|
63
|
+
return images;
|
|
64
|
+
}
|
|
65
|
+
async scanDirectory(dirPath, excludePaths) {
|
|
66
|
+
const images = [];
|
|
67
|
+
const items = await fs.readdir(dirPath, { withFileTypes: true });
|
|
68
|
+
for (const item of items) {
|
|
69
|
+
const fullPath = path.join(dirPath, item.name);
|
|
70
|
+
if (this.shouldExclude(fullPath, excludePaths)) {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (item.isDirectory()) {
|
|
74
|
+
const subImages = await this.scanDirectory(fullPath, excludePaths);
|
|
75
|
+
images.push(...subImages);
|
|
76
|
+
}
|
|
77
|
+
else if (item.isFile() && this.supports(item.name)) {
|
|
78
|
+
const imageContent = await this.analyzeImage(fullPath);
|
|
79
|
+
images.push(imageContent);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return images;
|
|
83
|
+
}
|
|
84
|
+
async analyzeImage(filePath) {
|
|
85
|
+
const stat = await fs.stat(filePath);
|
|
86
|
+
const filename = path.basename(filePath);
|
|
87
|
+
return {
|
|
88
|
+
id: `image-${filePath}`,
|
|
89
|
+
type: 'image',
|
|
90
|
+
path: filePath,
|
|
91
|
+
filename,
|
|
92
|
+
metadata: {
|
|
93
|
+
hasText: true,
|
|
94
|
+
format: path.extname(filePath).substring(1),
|
|
95
|
+
size: stat.size,
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
shouldExclude(filePath, excludePaths) {
|
|
100
|
+
return excludePaths.some((exclude) => filePath.includes(exclude));
|
|
101
|
+
}
|
|
102
|
+
async scanForImageUrls(dirPath, excludePaths) {
|
|
103
|
+
const images = [];
|
|
104
|
+
const codeExtensions = ['.ts', '.tsx', '.js', '.jsx', '.vue', '.html'];
|
|
105
|
+
const items = await fs.readdir(dirPath, { withFileTypes: true });
|
|
106
|
+
for (const item of items) {
|
|
107
|
+
const fullPath = path.join(dirPath, item.name);
|
|
108
|
+
if (this.shouldExclude(fullPath, excludePaths)) {
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (item.isDirectory()) {
|
|
112
|
+
const subImages = await this.scanForImageUrls(fullPath, excludePaths);
|
|
113
|
+
images.push(...subImages);
|
|
114
|
+
}
|
|
115
|
+
else if (item.isFile()) {
|
|
116
|
+
const ext = path.extname(item.name).toLowerCase();
|
|
117
|
+
if (codeExtensions.includes(ext)) {
|
|
118
|
+
const foundUrls = await this.extractImageUrls(fullPath);
|
|
119
|
+
images.push(...foundUrls);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return images;
|
|
124
|
+
}
|
|
125
|
+
async extractImageUrls(filePath) {
|
|
126
|
+
const images = [];
|
|
127
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
128
|
+
const foundUrls = new Set();
|
|
129
|
+
const lines = content.split('\n');
|
|
130
|
+
for (const pattern of IMAGE_URL_PATTERNS) {
|
|
131
|
+
const matches = content.matchAll(pattern);
|
|
132
|
+
for (const match of matches) {
|
|
133
|
+
foundUrls.add(match[0]);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
for (const url of foundUrls) {
|
|
137
|
+
const format = this.getFormatFromUrl(url);
|
|
138
|
+
let lineNumber = 0;
|
|
139
|
+
let columnNumber = 0;
|
|
140
|
+
for (let i = 0; i < lines.length; i++) {
|
|
141
|
+
const index = lines[i].indexOf(url);
|
|
142
|
+
if (index !== -1) {
|
|
143
|
+
lineNumber = i + 1;
|
|
144
|
+
columnNumber = index;
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
images.push({
|
|
149
|
+
id: `image-url-${url}`,
|
|
150
|
+
type: 'image',
|
|
151
|
+
path: filePath,
|
|
152
|
+
url,
|
|
153
|
+
line: lineNumber,
|
|
154
|
+
column: columnNumber,
|
|
155
|
+
metadata: {
|
|
156
|
+
hasText: true,
|
|
157
|
+
format,
|
|
158
|
+
isUrl: true,
|
|
159
|
+
sourceFile: filePath,
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
return images;
|
|
164
|
+
}
|
|
165
|
+
getFormatFromUrl(url) {
|
|
166
|
+
const match = url.match(/\.(png|jpg|jpeg|gif|webp)(\?|$)/i);
|
|
167
|
+
return match ? match[1].toLowerCase() : 'png';
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
exports.ImageDetector = ImageDetector;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TextItem, ScanConfig, I18nSetupInfo } from '../types.js';
|
|
2
|
+
export declare class TextDetector {
|
|
3
|
+
private i18nDetector;
|
|
4
|
+
private hardcodedDetector;
|
|
5
|
+
constructor();
|
|
6
|
+
scan(config: ScanConfig): Promise<TextItem[]>;
|
|
7
|
+
scanFiles(paths: string[]): Promise<TextItem[]>;
|
|
8
|
+
detectI18nSetup(projectRoot: string): Promise<I18nSetupInfo | null>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TextDetector = void 0;
|
|
4
|
+
const i18n_detector_js_1 = require("./i18n-detector.js");
|
|
5
|
+
const hardcoded_detector_js_1 = require("./hardcoded-detector.js");
|
|
6
|
+
class TextDetector {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.i18nDetector = new i18n_detector_js_1.I18nDetector();
|
|
9
|
+
this.hardcodedDetector = new hardcoded_detector_js_1.HardcodedDetector();
|
|
10
|
+
}
|
|
11
|
+
async scan(config) {
|
|
12
|
+
const texts = [];
|
|
13
|
+
if (config.detectI18n) {
|
|
14
|
+
const i18nTexts = await this.i18nDetector.detect(config);
|
|
15
|
+
texts.push(...i18nTexts);
|
|
16
|
+
}
|
|
17
|
+
if (config.detectHardcoded) {
|
|
18
|
+
const hardcodedTexts = await this.hardcodedDetector.detect(config);
|
|
19
|
+
texts.push(...hardcodedTexts);
|
|
20
|
+
}
|
|
21
|
+
return texts;
|
|
22
|
+
}
|
|
23
|
+
async scanFiles(paths) {
|
|
24
|
+
const texts = [];
|
|
25
|
+
for (const path of paths) {
|
|
26
|
+
const fileTexts = await this.i18nDetector.detectFile(path);
|
|
27
|
+
texts.push(...fileTexts);
|
|
28
|
+
}
|
|
29
|
+
return texts;
|
|
30
|
+
}
|
|
31
|
+
async detectI18nSetup(projectRoot) {
|
|
32
|
+
return this.i18nDetector.detectSetup(projectRoot);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.TextDetector = TextDetector;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ContentDetector, VideoContent, DetectionConfig } from './content-type-detector.js';
|
|
2
|
+
export declare class VideoDetector implements ContentDetector<VideoContent> {
|
|
3
|
+
supports(filePath: string): boolean;
|
|
4
|
+
detect(projectRoot: string, config: DetectionConfig): Promise<VideoContent[]>;
|
|
5
|
+
private scanDirectory;
|
|
6
|
+
private analyzeVideo;
|
|
7
|
+
private findSubtitleFile;
|
|
8
|
+
private shouldExclude;
|
|
9
|
+
private scanForVideoUrls;
|
|
10
|
+
private extractVideoUrls;
|
|
11
|
+
private getFormatFromUrl;
|
|
12
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.VideoDetector = void 0;
|
|
37
|
+
const fs = __importStar(require("fs/promises"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const VIDEO_EXTENSIONS = ['.mp4', '.mov', '.avi', '.mkv', '.webm', '.flv', '.wmv'];
|
|
40
|
+
const SUBTITLE_EXTENSIONS = ['.srt', '.vtt', '.ass', '.ssa'];
|
|
41
|
+
const VIDEO_URL_PATTERNS = [
|
|
42
|
+
/https?:\/\/[^\s"']+\.mp4/gi,
|
|
43
|
+
/https?:\/\/[^\s"']+\.mov/gi,
|
|
44
|
+
/https?:\/\/[^\s"']+\.webm/gi,
|
|
45
|
+
/https?:\/\/[^\s"']+\.avi/gi,
|
|
46
|
+
/https?:\/\/[^\s"']+\.mkv/gi,
|
|
47
|
+
/https?:\/\/[^\s"']*amazonaws\.com[^\s"']*\.(mp4|mov|webm|avi)/gi,
|
|
48
|
+
/https?:\/\/[^\s"']*cloudfront\.net[^\s"']*\.(mp4|mov|webm|avi)/gi,
|
|
49
|
+
];
|
|
50
|
+
class VideoDetector {
|
|
51
|
+
supports(filePath) {
|
|
52
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
53
|
+
return VIDEO_EXTENSIONS.includes(ext);
|
|
54
|
+
}
|
|
55
|
+
async detect(projectRoot, config) {
|
|
56
|
+
const videos = [];
|
|
57
|
+
for (const includePath of config.includePaths) {
|
|
58
|
+
const fullPath = path.join(projectRoot, includePath);
|
|
59
|
+
const physicalVideos = await this.scanDirectory(fullPath, config.excludePaths);
|
|
60
|
+
videos.push(...physicalVideos);
|
|
61
|
+
const urlVideos = await this.scanForVideoUrls(fullPath, config.excludePaths);
|
|
62
|
+
videos.push(...urlVideos);
|
|
63
|
+
}
|
|
64
|
+
return videos;
|
|
65
|
+
}
|
|
66
|
+
async scanDirectory(dirPath, excludePaths) {
|
|
67
|
+
const videos = [];
|
|
68
|
+
const items = await fs.readdir(dirPath, { withFileTypes: true });
|
|
69
|
+
for (const item of items) {
|
|
70
|
+
const fullPath = path.join(dirPath, item.name);
|
|
71
|
+
if (this.shouldExclude(fullPath, excludePaths)) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (item.isDirectory()) {
|
|
75
|
+
const subVideos = await this.scanDirectory(fullPath, excludePaths);
|
|
76
|
+
videos.push(...subVideos);
|
|
77
|
+
}
|
|
78
|
+
else if (item.isFile() && this.supports(item.name)) {
|
|
79
|
+
const videoContent = await this.analyzeVideo(fullPath);
|
|
80
|
+
videos.push(videoContent);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return videos;
|
|
84
|
+
}
|
|
85
|
+
async analyzeVideo(filePath) {
|
|
86
|
+
const stat = await fs.stat(filePath);
|
|
87
|
+
const dir = path.dirname(filePath);
|
|
88
|
+
const basename = path.basename(filePath, path.extname(filePath));
|
|
89
|
+
const filename = path.basename(filePath);
|
|
90
|
+
const subtitlePath = await this.findSubtitleFile(dir, basename);
|
|
91
|
+
return {
|
|
92
|
+
id: `video-${filePath}`,
|
|
93
|
+
type: 'video',
|
|
94
|
+
path: filePath,
|
|
95
|
+
filename,
|
|
96
|
+
metadata: {
|
|
97
|
+
duration: 0,
|
|
98
|
+
format: path.extname(filePath).substring(1),
|
|
99
|
+
hasSubtitles: !!subtitlePath,
|
|
100
|
+
subtitlePath,
|
|
101
|
+
size: stat.size,
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
async findSubtitleFile(dir, basename) {
|
|
106
|
+
for (const ext of SUBTITLE_EXTENSIONS) {
|
|
107
|
+
const subtitlePath = path.join(dir, `${basename}${ext}`);
|
|
108
|
+
try {
|
|
109
|
+
await fs.access(subtitlePath);
|
|
110
|
+
return subtitlePath;
|
|
111
|
+
}
|
|
112
|
+
catch { }
|
|
113
|
+
}
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
shouldExclude(filePath, excludePaths) {
|
|
117
|
+
return excludePaths.some((exclude) => filePath.includes(exclude));
|
|
118
|
+
}
|
|
119
|
+
async scanForVideoUrls(dirPath, excludePaths) {
|
|
120
|
+
const videos = [];
|
|
121
|
+
const codeExtensions = ['.ts', '.tsx', '.js', '.jsx', '.vue', '.html'];
|
|
122
|
+
const items = await fs.readdir(dirPath, { withFileTypes: true });
|
|
123
|
+
for (const item of items) {
|
|
124
|
+
const fullPath = path.join(dirPath, item.name);
|
|
125
|
+
if (this.shouldExclude(fullPath, excludePaths)) {
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if (item.isDirectory()) {
|
|
129
|
+
const subVideos = await this.scanForVideoUrls(fullPath, excludePaths);
|
|
130
|
+
videos.push(...subVideos);
|
|
131
|
+
}
|
|
132
|
+
else if (item.isFile()) {
|
|
133
|
+
const ext = path.extname(item.name).toLowerCase();
|
|
134
|
+
if (codeExtensions.includes(ext)) {
|
|
135
|
+
const foundUrls = await this.extractVideoUrls(fullPath);
|
|
136
|
+
videos.push(...foundUrls);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return videos;
|
|
141
|
+
}
|
|
142
|
+
async extractVideoUrls(filePath) {
|
|
143
|
+
const videos = [];
|
|
144
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
145
|
+
const foundUrls = new Set();
|
|
146
|
+
const lines = content.split('\n');
|
|
147
|
+
for (const pattern of VIDEO_URL_PATTERNS) {
|
|
148
|
+
const matches = content.matchAll(pattern);
|
|
149
|
+
for (const match of matches) {
|
|
150
|
+
foundUrls.add(match[0]);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
for (const url of foundUrls) {
|
|
154
|
+
const format = this.getFormatFromUrl(url);
|
|
155
|
+
let lineNumber = 0;
|
|
156
|
+
let columnNumber = 0;
|
|
157
|
+
for (let i = 0; i < lines.length; i++) {
|
|
158
|
+
const index = lines[i].indexOf(url);
|
|
159
|
+
if (index !== -1) {
|
|
160
|
+
lineNumber = i + 1;
|
|
161
|
+
columnNumber = index;
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
videos.push({
|
|
166
|
+
id: `video-url-${url}`,
|
|
167
|
+
type: 'video',
|
|
168
|
+
path: filePath,
|
|
169
|
+
url,
|
|
170
|
+
line: lineNumber,
|
|
171
|
+
column: columnNumber,
|
|
172
|
+
metadata: {
|
|
173
|
+
duration: 0,
|
|
174
|
+
format,
|
|
175
|
+
hasSubtitles: false,
|
|
176
|
+
isUrl: true,
|
|
177
|
+
sourceFile: filePath,
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
return videos;
|
|
182
|
+
}
|
|
183
|
+
getFormatFromUrl(url) {
|
|
184
|
+
const match = url.match(/\.(mp4|mov|webm|avi|mkv)(\?|$)/i);
|
|
185
|
+
return match ? match[1].toLowerCase() : 'mp4';
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
exports.VideoDetector = VideoDetector;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Translation Management System - Public API
|
|
3
|
+
*/
|
|
4
|
+
export { TranslationManagementSystem } from './tms.js';
|
|
5
|
+
export { MultiContentTMS } from './multi-content-tms.js';
|
|
6
|
+
export { ConfigManager, createConfig, DEFAULT_TMS_CONFIG } from './config.js';
|
|
7
|
+
export { TextDetector } from './detector/text-detector.js';
|
|
8
|
+
export { VideoDetector } from './detector/video-detector.js';
|
|
9
|
+
export { ImageDetector } from './detector/image-detector.js';
|
|
10
|
+
export { CMSDetector } from './detector/cms-detector.js';
|
|
11
|
+
export * from './types.js';
|
|
12
|
+
export * from './detector/content-type-detector.js';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Translation Management System - Public API
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.CMSDetector = exports.ImageDetector = exports.VideoDetector = exports.TextDetector = exports.DEFAULT_TMS_CONFIG = exports.createConfig = exports.ConfigManager = exports.MultiContentTMS = exports.TranslationManagementSystem = void 0;
|
|
21
|
+
var tms_js_1 = require("./tms.js");
|
|
22
|
+
Object.defineProperty(exports, "TranslationManagementSystem", { enumerable: true, get: function () { return tms_js_1.TranslationManagementSystem; } });
|
|
23
|
+
var multi_content_tms_js_1 = require("./multi-content-tms.js");
|
|
24
|
+
Object.defineProperty(exports, "MultiContentTMS", { enumerable: true, get: function () { return multi_content_tms_js_1.MultiContentTMS; } });
|
|
25
|
+
var config_js_1 = require("./config.js");
|
|
26
|
+
Object.defineProperty(exports, "ConfigManager", { enumerable: true, get: function () { return config_js_1.ConfigManager; } });
|
|
27
|
+
Object.defineProperty(exports, "createConfig", { enumerable: true, get: function () { return config_js_1.createConfig; } });
|
|
28
|
+
Object.defineProperty(exports, "DEFAULT_TMS_CONFIG", { enumerable: true, get: function () { return config_js_1.DEFAULT_TMS_CONFIG; } });
|
|
29
|
+
var text_detector_js_1 = require("./detector/text-detector.js");
|
|
30
|
+
Object.defineProperty(exports, "TextDetector", { enumerable: true, get: function () { return text_detector_js_1.TextDetector; } });
|
|
31
|
+
var video_detector_js_1 = require("./detector/video-detector.js");
|
|
32
|
+
Object.defineProperty(exports, "VideoDetector", { enumerable: true, get: function () { return video_detector_js_1.VideoDetector; } });
|
|
33
|
+
var image_detector_js_1 = require("./detector/image-detector.js");
|
|
34
|
+
Object.defineProperty(exports, "ImageDetector", { enumerable: true, get: function () { return image_detector_js_1.ImageDetector; } });
|
|
35
|
+
var cms_detector_js_1 = require("./detector/cms-detector.js");
|
|
36
|
+
Object.defineProperty(exports, "CMSDetector", { enumerable: true, get: function () { return cms_detector_js_1.CMSDetector; } });
|
|
37
|
+
__exportStar(require("./types.js"), exports);
|
|
38
|
+
__exportStar(require("./detector/content-type-detector.js"), exports);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Ollang } from '../index.js';
|
|
2
|
+
import { AnyContentItem, ContentType, VideoContent, ImageContent, I18nContent } from './detector/content-type-detector.js';
|
|
3
|
+
import { TMSConfig } from './types.js';
|
|
4
|
+
import { OrderType } from '../types/index.js';
|
|
5
|
+
export interface MultiContentScanResult {
|
|
6
|
+
i18n: I18nContent[];
|
|
7
|
+
videos: VideoContent[];
|
|
8
|
+
images: ImageContent[];
|
|
9
|
+
total: number;
|
|
10
|
+
}
|
|
11
|
+
export interface TranslationRequest {
|
|
12
|
+
contentType: ContentType;
|
|
13
|
+
items: AnyContentItem[];
|
|
14
|
+
targetLanguage: string;
|
|
15
|
+
level?: number;
|
|
16
|
+
}
|
|
17
|
+
export interface TranslationResult {
|
|
18
|
+
orderId: string;
|
|
19
|
+
orderType: OrderType;
|
|
20
|
+
status: string;
|
|
21
|
+
contentType: ContentType;
|
|
22
|
+
itemCount: number;
|
|
23
|
+
}
|
|
24
|
+
export declare class MultiContentTMS {
|
|
25
|
+
private config;
|
|
26
|
+
private configManager;
|
|
27
|
+
private ollangClient;
|
|
28
|
+
private textDetector;
|
|
29
|
+
private videoDetector;
|
|
30
|
+
private imageDetector;
|
|
31
|
+
constructor(customConfig?: Partial<TMSConfig>);
|
|
32
|
+
scanAll(): Promise<MultiContentScanResult>;
|
|
33
|
+
private scanI18n;
|
|
34
|
+
translate(request: TranslationRequest): Promise<TranslationResult>;
|
|
35
|
+
private translateVideos;
|
|
36
|
+
private translateImages;
|
|
37
|
+
private translateI18n;
|
|
38
|
+
getOrderStatus(orderId: string): Promise<import("../index.js").Order>;
|
|
39
|
+
waitForCompletion(orderId: string, maxWaitSeconds?: number): Promise<any>;
|
|
40
|
+
getSDK(): Ollang;
|
|
41
|
+
getConfig(): TMSConfig;
|
|
42
|
+
}
|