@academy-sdk/sdk 0.1.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.
@@ -0,0 +1,80 @@
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/utils/index.ts
21
+ var utils_exports = {};
22
+ __export(utils_exports, {
23
+ calculateProgress: () => calculateProgress,
24
+ formatDate: () => formatDate,
25
+ formatDuration: () => formatDuration,
26
+ formatPrice: () => formatPrice,
27
+ formatRelativeTime: () => formatRelativeTime,
28
+ truncateText: () => truncateText
29
+ });
30
+ module.exports = __toCommonJS(utils_exports);
31
+
32
+ // src/utils/formatters.ts
33
+ function formatDuration(seconds) {
34
+ if (!seconds || seconds < 0) return "0:00";
35
+ const hours = Math.floor(seconds / 3600);
36
+ const minutes = Math.floor(seconds % 3600 / 60);
37
+ const secs = Math.floor(seconds % 60);
38
+ if (hours > 0) {
39
+ return `${hours}:${minutes.toString().padStart(2, "0")}:${secs.toString().padStart(2, "0")}`;
40
+ }
41
+ return `${minutes}:${secs.toString().padStart(2, "0")}`;
42
+ }
43
+ function formatPrice(amount, currency = "USD") {
44
+ return new Intl.NumberFormat("en-US", {
45
+ style: "currency",
46
+ currency,
47
+ minimumFractionDigits: 0,
48
+ maximumFractionDigits: 2
49
+ }).format(amount);
50
+ }
51
+ function formatDate(dateString, options) {
52
+ const date = new Date(dateString);
53
+ return date.toLocaleDateString("en-US", options != null ? options : {
54
+ year: "numeric",
55
+ month: "short",
56
+ day: "numeric"
57
+ });
58
+ }
59
+ function formatRelativeTime(dateString) {
60
+ const date = new Date(dateString);
61
+ const now = /* @__PURE__ */ new Date();
62
+ const diffMs = now.getTime() - date.getTime();
63
+ const diffSecs = Math.floor(diffMs / 1e3);
64
+ const diffMins = Math.floor(diffSecs / 60);
65
+ const diffHours = Math.floor(diffMins / 60);
66
+ const diffDays = Math.floor(diffHours / 24);
67
+ if (diffSecs < 60) return "just now";
68
+ if (diffMins < 60) return `${diffMins}m ago`;
69
+ if (diffHours < 24) return `${diffHours}h ago`;
70
+ if (diffDays < 7) return `${diffDays}d ago`;
71
+ return formatDate(dateString);
72
+ }
73
+ function calculateProgress(completed, total) {
74
+ if (total === 0) return 0;
75
+ return Math.round(completed / total * 100);
76
+ }
77
+ function truncateText(text, maxLength) {
78
+ if (text.length <= maxLength) return text;
79
+ return text.slice(0, maxLength).trimEnd() + "...";
80
+ }
@@ -0,0 +1,57 @@
1
+ // src/utils/formatters.ts
2
+ function formatDuration(seconds) {
3
+ if (!seconds || seconds < 0) return "0:00";
4
+ const hours = Math.floor(seconds / 3600);
5
+ const minutes = Math.floor(seconds % 3600 / 60);
6
+ const secs = Math.floor(seconds % 60);
7
+ if (hours > 0) {
8
+ return `${hours}:${minutes.toString().padStart(2, "0")}:${secs.toString().padStart(2, "0")}`;
9
+ }
10
+ return `${minutes}:${secs.toString().padStart(2, "0")}`;
11
+ }
12
+ function formatPrice(amount, currency = "USD") {
13
+ return new Intl.NumberFormat("en-US", {
14
+ style: "currency",
15
+ currency,
16
+ minimumFractionDigits: 0,
17
+ maximumFractionDigits: 2
18
+ }).format(amount);
19
+ }
20
+ function formatDate(dateString, options) {
21
+ const date = new Date(dateString);
22
+ return date.toLocaleDateString("en-US", options != null ? options : {
23
+ year: "numeric",
24
+ month: "short",
25
+ day: "numeric"
26
+ });
27
+ }
28
+ function formatRelativeTime(dateString) {
29
+ const date = new Date(dateString);
30
+ const now = /* @__PURE__ */ new Date();
31
+ const diffMs = now.getTime() - date.getTime();
32
+ const diffSecs = Math.floor(diffMs / 1e3);
33
+ const diffMins = Math.floor(diffSecs / 60);
34
+ const diffHours = Math.floor(diffMins / 60);
35
+ const diffDays = Math.floor(diffHours / 24);
36
+ if (diffSecs < 60) return "just now";
37
+ if (diffMins < 60) return `${diffMins}m ago`;
38
+ if (diffHours < 24) return `${diffHours}h ago`;
39
+ if (diffDays < 7) return `${diffDays}d ago`;
40
+ return formatDate(dateString);
41
+ }
42
+ function calculateProgress(completed, total) {
43
+ if (total === 0) return 0;
44
+ return Math.round(completed / total * 100);
45
+ }
46
+ function truncateText(text, maxLength) {
47
+ if (text.length <= maxLength) return text;
48
+ return text.slice(0, maxLength).trimEnd() + "...";
49
+ }
50
+ export {
51
+ calculateProgress,
52
+ formatDate,
53
+ formatDuration,
54
+ formatPrice,
55
+ formatRelativeTime,
56
+ truncateText
57
+ };
package/package.json ADDED
@@ -0,0 +1,91 @@
1
+ {
2
+ "name": "@academy-sdk/sdk",
3
+ "version": "0.1.0",
4
+ "description": "SDK for building custom learner templates for the Academy platform",
5
+ "main": "./dist/index.cjs",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "import": "./dist/index.js",
18
+ "require": "./dist/index.cjs"
19
+ },
20
+ "./types": {
21
+ "types": "./dist/types/index.d.ts",
22
+ "import": "./dist/types/index.js",
23
+ "require": "./dist/types/index.cjs"
24
+ },
25
+ "./hooks": {
26
+ "types": "./dist/hooks/index.d.ts",
27
+ "import": "./dist/hooks/index.js",
28
+ "require": "./dist/hooks/index.cjs"
29
+ },
30
+ "./contracts": {
31
+ "types": "./dist/contracts/index.d.ts",
32
+ "import": "./dist/contracts/index.js",
33
+ "require": "./dist/contracts/index.cjs"
34
+ },
35
+ "./utils": {
36
+ "types": "./dist/utils/index.d.ts",
37
+ "import": "./dist/utils/index.js",
38
+ "require": "./dist/utils/index.cjs"
39
+ },
40
+ "./components": {
41
+ "types": "./dist/components/index.d.ts",
42
+ "import": "./dist/components/index.js",
43
+ "require": "./dist/components/index.cjs"
44
+ },
45
+ "./components/atoms": {
46
+ "types": "./dist/components/atoms/index.d.ts",
47
+ "import": "./dist/components/atoms/index.js",
48
+ "require": "./dist/components/atoms/index.cjs"
49
+ },
50
+ "./components/molecules": {
51
+ "types": "./dist/components/molecules/index.d.ts",
52
+ "import": "./dist/components/molecules/index.js",
53
+ "require": "./dist/components/molecules/index.cjs"
54
+ },
55
+ "./components/organisms": {
56
+ "types": "./dist/components/organisms/index.d.ts",
57
+ "import": "./dist/components/organisms/index.js",
58
+ "require": "./dist/components/organisms/index.cjs"
59
+ },
60
+ "./components/pages": {
61
+ "types": "./dist/components/pages/index.d.ts",
62
+ "import": "./dist/components/pages/index.js",
63
+ "require": "./dist/components/pages/index.cjs"
64
+ }
65
+ },
66
+ "scripts": {
67
+ "build": "node build.mjs",
68
+ "prepublishOnly": "npm run build",
69
+ "preview": "node preview.mjs"
70
+ },
71
+ "peerDependencies": {
72
+ "react": ">=18.0.0",
73
+ "react-dom": ">=18.0.0",
74
+ "clsx": ">=2.0.0",
75
+ "tailwind-merge": ">=2.0.0",
76
+ "class-variance-authority": ">=0.7.0",
77
+ "lucide-react": ">=0.300.0"
78
+ },
79
+ "devDependencies": {
80
+ "esbuild": "0.25.5",
81
+ "typescript": "5.9.3",
82
+ "react": "19.2.0",
83
+ "react-dom": "19.2.0",
84
+ "@types/react": "19.2.7",
85
+ "@types/react-dom": "19.2.3",
86
+ "clsx": "2.1.1",
87
+ "tailwind-merge": "3.4.0",
88
+ "class-variance-authority": "0.7.1",
89
+ "lucide-react": "0.555.0"
90
+ }
91
+ }