scorm-player 1.1.0 → 1.2.0
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.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +17 -2
- package/dist/index.mjs +17 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -12,9 +12,11 @@ declare class SupabaseAdapter {
|
|
|
12
12
|
client: SupabaseClient;
|
|
13
13
|
rootFolder: string;
|
|
14
14
|
constructor(supabaseUrl: string, supabaseKey: string, rootFolder?: string);
|
|
15
|
+
generateUniqueFolder(baseName: string): string;
|
|
15
16
|
uploadFile(path: string, content: string | Buffer): Promise<string>;
|
|
16
|
-
uploadFolder(
|
|
17
|
+
uploadFolder(files: Record<string, string | Buffer>, baseFolderName?: string): Promise<string>;
|
|
17
18
|
getFileUrl(path: string): string;
|
|
19
|
+
getLaunchUrl(folderName: string, launchPath: string): string;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
interface SCORMState {
|
package/dist/index.d.ts
CHANGED
|
@@ -12,9 +12,11 @@ declare class SupabaseAdapter {
|
|
|
12
12
|
client: SupabaseClient;
|
|
13
13
|
rootFolder: string;
|
|
14
14
|
constructor(supabaseUrl: string, supabaseKey: string, rootFolder?: string);
|
|
15
|
+
generateUniqueFolder(baseName: string): string;
|
|
15
16
|
uploadFile(path: string, content: string | Buffer): Promise<string>;
|
|
16
|
-
uploadFolder(
|
|
17
|
+
uploadFolder(files: Record<string, string | Buffer>, baseFolderName?: string): Promise<string>;
|
|
17
18
|
getFileUrl(path: string): string;
|
|
19
|
+
getLaunchUrl(folderName: string, launchPath: string): string;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
interface SCORMState {
|
package/dist/index.js
CHANGED
|
@@ -74,25 +74,40 @@ function parseManifest(manifestXml) {
|
|
|
74
74
|
|
|
75
75
|
// src/backend/storageAdapters/supabaseAdapter.ts
|
|
76
76
|
var import_supabase_js = require("@supabase/supabase-js");
|
|
77
|
+
var import_crypto = require("crypto");
|
|
77
78
|
var SupabaseAdapter = class {
|
|
78
79
|
constructor(supabaseUrl, supabaseKey, rootFolder = "scorm-courses") {
|
|
79
80
|
this.client = (0, import_supabase_js.createClient)(supabaseUrl, supabaseKey);
|
|
80
81
|
this.rootFolder = rootFolder;
|
|
81
82
|
}
|
|
83
|
+
// Генерация уникального имени папки
|
|
84
|
+
generateUniqueFolder(baseName) {
|
|
85
|
+
const id = (0, import_crypto.randomUUID)();
|
|
86
|
+
return `${baseName}-${id}`;
|
|
87
|
+
}
|
|
82
88
|
async uploadFile(path, content) {
|
|
83
89
|
const fullPath = `${this.rootFolder}/${path}`;
|
|
84
90
|
await this.client.storage.from(this.rootFolder).upload(path, content, { upsert: true });
|
|
85
91
|
return fullPath;
|
|
86
92
|
}
|
|
87
|
-
|
|
93
|
+
// Принимаем files и optional baseName для папки
|
|
94
|
+
async uploadFolder(files, baseFolderName = "course") {
|
|
95
|
+
const uniqueFolder = this.generateUniqueFolder(baseFolderName);
|
|
88
96
|
for (const [filePath, content] of Object.entries(files)) {
|
|
89
|
-
const fullPath = `${
|
|
97
|
+
const fullPath = `${uniqueFolder}/${filePath}`;
|
|
90
98
|
await this.uploadFile(fullPath, content);
|
|
91
99
|
}
|
|
100
|
+
return uniqueFolder;
|
|
92
101
|
}
|
|
102
|
+
// Получаем публичный URL полного пути к файлу
|
|
93
103
|
getFileUrl(path) {
|
|
94
104
|
return this.client.storage.from(this.rootFolder).getPublicUrl(path).data.publicUrl;
|
|
95
105
|
}
|
|
106
|
+
// Удобная функция для получения URL к launch файлу
|
|
107
|
+
getLaunchUrl(folderName, launchPath) {
|
|
108
|
+
const fullPath = `${folderName}/${launchPath}`;
|
|
109
|
+
return this.getFileUrl(fullPath);
|
|
110
|
+
}
|
|
96
111
|
};
|
|
97
112
|
|
|
98
113
|
// src/frontend/ScormPlayer.tsx
|
package/dist/index.mjs
CHANGED
|
@@ -35,25 +35,40 @@ function parseManifest(manifestXml) {
|
|
|
35
35
|
|
|
36
36
|
// src/backend/storageAdapters/supabaseAdapter.ts
|
|
37
37
|
import { createClient } from "@supabase/supabase-js";
|
|
38
|
+
import { randomUUID } from "crypto";
|
|
38
39
|
var SupabaseAdapter = class {
|
|
39
40
|
constructor(supabaseUrl, supabaseKey, rootFolder = "scorm-courses") {
|
|
40
41
|
this.client = createClient(supabaseUrl, supabaseKey);
|
|
41
42
|
this.rootFolder = rootFolder;
|
|
42
43
|
}
|
|
44
|
+
// Генерация уникального имени папки
|
|
45
|
+
generateUniqueFolder(baseName) {
|
|
46
|
+
const id = randomUUID();
|
|
47
|
+
return `${baseName}-${id}`;
|
|
48
|
+
}
|
|
43
49
|
async uploadFile(path, content) {
|
|
44
50
|
const fullPath = `${this.rootFolder}/${path}`;
|
|
45
51
|
await this.client.storage.from(this.rootFolder).upload(path, content, { upsert: true });
|
|
46
52
|
return fullPath;
|
|
47
53
|
}
|
|
48
|
-
|
|
54
|
+
// Принимаем files и optional baseName для папки
|
|
55
|
+
async uploadFolder(files, baseFolderName = "course") {
|
|
56
|
+
const uniqueFolder = this.generateUniqueFolder(baseFolderName);
|
|
49
57
|
for (const [filePath, content] of Object.entries(files)) {
|
|
50
|
-
const fullPath = `${
|
|
58
|
+
const fullPath = `${uniqueFolder}/${filePath}`;
|
|
51
59
|
await this.uploadFile(fullPath, content);
|
|
52
60
|
}
|
|
61
|
+
return uniqueFolder;
|
|
53
62
|
}
|
|
63
|
+
// Получаем публичный URL полного пути к файлу
|
|
54
64
|
getFileUrl(path) {
|
|
55
65
|
return this.client.storage.from(this.rootFolder).getPublicUrl(path).data.publicUrl;
|
|
56
66
|
}
|
|
67
|
+
// Удобная функция для получения URL к launch файлу
|
|
68
|
+
getLaunchUrl(folderName, launchPath) {
|
|
69
|
+
const fullPath = `${folderName}/${launchPath}`;
|
|
70
|
+
return this.getFileUrl(fullPath);
|
|
71
|
+
}
|
|
57
72
|
};
|
|
58
73
|
|
|
59
74
|
// src/frontend/ScormPlayer.tsx
|
package/package.json
CHANGED