scorm-player 1.1.0 → 1.2.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/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(folderPath: string, files: Record<string, string | Buffer>): Promise<void>;
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(folderPath: string, files: Record<string, string | Buffer>): Promise<void>;
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,39 @@ 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_uuid = require("uuid");
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
+ return `${baseName}-${(0, import_uuid.v4)()}`;
86
+ }
82
87
  async uploadFile(path, content) {
83
88
  const fullPath = `${this.rootFolder}/${path}`;
84
89
  await this.client.storage.from(this.rootFolder).upload(path, content, { upsert: true });
85
90
  return fullPath;
86
91
  }
87
- async uploadFolder(folderPath, files) {
92
+ // Принимаем files и optional baseName для папки
93
+ async uploadFolder(files, baseFolderName = "course") {
94
+ const uniqueFolder = this.generateUniqueFolder(baseFolderName);
88
95
  for (const [filePath, content] of Object.entries(files)) {
89
- const fullPath = `${folderPath}/${filePath}`;
96
+ const fullPath = `${uniqueFolder}/${filePath}`;
90
97
  await this.uploadFile(fullPath, content);
91
98
  }
99
+ return uniqueFolder;
92
100
  }
101
+ // Получаем публичный URL полного пути к файлу
93
102
  getFileUrl(path) {
94
103
  return this.client.storage.from(this.rootFolder).getPublicUrl(path).data.publicUrl;
95
104
  }
105
+ // Удобная функция для получения URL к launch файлу
106
+ getLaunchUrl(folderName, launchPath) {
107
+ const fullPath = `${folderName}/${launchPath}`;
108
+ return this.getFileUrl(fullPath);
109
+ }
96
110
  };
97
111
 
98
112
  // src/frontend/ScormPlayer.tsx
package/dist/index.mjs CHANGED
@@ -35,25 +35,39 @@ function parseManifest(manifestXml) {
35
35
 
36
36
  // src/backend/storageAdapters/supabaseAdapter.ts
37
37
  import { createClient } from "@supabase/supabase-js";
38
+ import { v4 as uuidv4 } from "uuid";
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
+ return `${baseName}-${uuidv4()}`;
47
+ }
43
48
  async uploadFile(path, content) {
44
49
  const fullPath = `${this.rootFolder}/${path}`;
45
50
  await this.client.storage.from(this.rootFolder).upload(path, content, { upsert: true });
46
51
  return fullPath;
47
52
  }
48
- async uploadFolder(folderPath, files) {
53
+ // Принимаем files и optional baseName для папки
54
+ async uploadFolder(files, baseFolderName = "course") {
55
+ const uniqueFolder = this.generateUniqueFolder(baseFolderName);
49
56
  for (const [filePath, content] of Object.entries(files)) {
50
- const fullPath = `${folderPath}/${filePath}`;
57
+ const fullPath = `${uniqueFolder}/${filePath}`;
51
58
  await this.uploadFile(fullPath, content);
52
59
  }
60
+ return uniqueFolder;
53
61
  }
62
+ // Получаем публичный URL полного пути к файлу
54
63
  getFileUrl(path) {
55
64
  return this.client.storage.from(this.rootFolder).getPublicUrl(path).data.publicUrl;
56
65
  }
66
+ // Удобная функция для получения URL к launch файлу
67
+ getLaunchUrl(folderName, launchPath) {
68
+ const fullPath = `${folderName}/${launchPath}`;
69
+ return this.getFileUrl(fullPath);
70
+ }
57
71
  };
58
72
 
59
73
  // src/frontend/ScormPlayer.tsx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scorm-player",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
4
4
  "description": "SCORM 2004 player, unpacker and manifest parser for Node.js / Next.js with storage adapters and React iframe renderer.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -28,6 +28,7 @@
28
28
  "dependencies": {
29
29
  "@supabase/supabase-js": "^2.9.0",
30
30
  "jszip": "^3.10.1",
31
+ "uuid": "^13.0.0",
31
32
  "xmldom": "^0.6.0"
32
33
  },
33
34
  "peerDependencies": {
@@ -37,6 +38,7 @@
37
38
  "devDependencies": {
38
39
  "@types/react": "^18.3.27",
39
40
  "@types/react-dom": "^18.3.7",
41
+ "@types/uuid": "^10.0.0",
40
42
  "@types/xmldom": "^0.1.34",
41
43
  "tsup": "^7.3.0",
42
44
  "typescript": "^5.4.5"