@lessonkit/xapi 0.3.0 → 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/dist/index.cjs CHANGED
@@ -24,7 +24,8 @@ __export(index_exports, {
24
24
  createXAPIClient: () => createXAPIClient
25
25
  });
26
26
  module.exports = __toCommonJS(index_exports);
27
- var import_core = require("@lessonkit/core");
27
+
28
+ // src/queue.ts
28
29
  function createInMemoryXAPIQueue() {
29
30
  const buffer = [];
30
31
  return {
@@ -45,6 +46,26 @@ function createInMemoryXAPIQueue() {
45
46
  }
46
47
  };
47
48
  }
49
+
50
+ // src/client.ts
51
+ var import_core = require("@lessonkit/core");
52
+
53
+ // src/id.ts
54
+ function cryptoRandomId() {
55
+ const g = globalThis;
56
+ if (g.crypto?.randomUUID) return g.crypto.randomUUID();
57
+ return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 11)}`;
58
+ }
59
+
60
+ // src/duration.ts
61
+ function formatDurationMs(ms) {
62
+ const safe = Math.max(0, ms);
63
+ const seconds = safe / 1e3;
64
+ const fixed = Number.isInteger(seconds) ? String(seconds) : seconds.toFixed(3).replace(/0+$/, "").replace(/\.$/, "");
65
+ return `PT${fixed}S`;
66
+ }
67
+
68
+ // src/client.ts
48
69
  var XAPIVerbs = {
49
70
  started: "http://adlnet.gov/expapi/verbs/initialized",
50
71
  completed: "http://adlnet.gov/expapi/verbs/completed"
@@ -110,17 +131,6 @@ function statementFor(objectId, verb, extra) {
110
131
  context: extra?.context
111
132
  };
112
133
  }
113
- function cryptoRandomId() {
114
- const g = globalThis;
115
- if (g.crypto?.randomUUID) return g.crypto.randomUUID();
116
- return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 11)}`;
117
- }
118
- function formatDurationMs(ms) {
119
- const safe = Math.max(0, ms);
120
- const seconds = safe / 1e3;
121
- const fixed = Number.isInteger(seconds) ? String(seconds) : seconds.toFixed(3).replace(/0+$/, "").replace(/\.$/, "");
122
- return `PT${fixed}S`;
123
- }
124
134
  // Annotate the CommonJS export names for ESM import in node:
125
135
  0 && (module.exports = {
126
136
  createInMemoryXAPIQueue,
package/dist/index.d.cts CHANGED
@@ -17,7 +17,6 @@ type XAPIQueue = {
17
17
  flush: (transport: XAPITransport) => Promise<void>;
18
18
  size: () => number;
19
19
  };
20
- declare function createInMemoryXAPIQueue(): XAPIQueue;
21
20
  type XAPIClient = {
22
21
  send: (statement: XAPIStatement) => void;
23
22
  flush: () => Promise<void>;
@@ -34,6 +33,9 @@ type XAPIClient = {
34
33
  }) => void;
35
34
  completeCourse: () => void;
36
35
  };
36
+
37
+ declare function createInMemoryXAPIQueue(): XAPIQueue;
38
+
37
39
  declare function createXAPIClient(opts?: {
38
40
  transport?: XAPITransport;
39
41
  baseId?: string;
package/dist/index.d.ts CHANGED
@@ -17,7 +17,6 @@ type XAPIQueue = {
17
17
  flush: (transport: XAPITransport) => Promise<void>;
18
18
  size: () => number;
19
19
  };
20
- declare function createInMemoryXAPIQueue(): XAPIQueue;
21
20
  type XAPIClient = {
22
21
  send: (statement: XAPIStatement) => void;
23
22
  flush: () => Promise<void>;
@@ -34,6 +33,9 @@ type XAPIClient = {
34
33
  }) => void;
35
34
  completeCourse: () => void;
36
35
  };
36
+
37
+ declare function createInMemoryXAPIQueue(): XAPIQueue;
38
+
37
39
  declare function createXAPIClient(opts?: {
38
40
  transport?: XAPITransport;
39
41
  baseId?: string;
package/dist/index.js CHANGED
@@ -1,5 +1,4 @@
1
- // src/index.ts
2
- import { nowIso } from "@lessonkit/core";
1
+ // src/queue.ts
3
2
  function createInMemoryXAPIQueue() {
4
3
  const buffer = [];
5
4
  return {
@@ -20,6 +19,26 @@ function createInMemoryXAPIQueue() {
20
19
  }
21
20
  };
22
21
  }
22
+
23
+ // src/client.ts
24
+ import { nowIso } from "@lessonkit/core";
25
+
26
+ // src/id.ts
27
+ function cryptoRandomId() {
28
+ const g = globalThis;
29
+ if (g.crypto?.randomUUID) return g.crypto.randomUUID();
30
+ return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 11)}`;
31
+ }
32
+
33
+ // src/duration.ts
34
+ function formatDurationMs(ms) {
35
+ const safe = Math.max(0, ms);
36
+ const seconds = safe / 1e3;
37
+ const fixed = Number.isInteger(seconds) ? String(seconds) : seconds.toFixed(3).replace(/0+$/, "").replace(/\.$/, "");
38
+ return `PT${fixed}S`;
39
+ }
40
+
41
+ // src/client.ts
23
42
  var XAPIVerbs = {
24
43
  started: "http://adlnet.gov/expapi/verbs/initialized",
25
44
  completed: "http://adlnet.gov/expapi/verbs/completed"
@@ -85,17 +104,6 @@ function statementFor(objectId, verb, extra) {
85
104
  context: extra?.context
86
105
  };
87
106
  }
88
- function cryptoRandomId() {
89
- const g = globalThis;
90
- if (g.crypto?.randomUUID) return g.crypto.randomUUID();
91
- return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 11)}`;
92
- }
93
- function formatDurationMs(ms) {
94
- const safe = Math.max(0, ms);
95
- const seconds = safe / 1e3;
96
- const fixed = Number.isInteger(seconds) ? String(seconds) : seconds.toFixed(3).replace(/0+$/, "").replace(/\.$/, "");
97
- return `PT${fixed}S`;
98
- }
99
107
  export {
100
108
  createInMemoryXAPIQueue,
101
109
  createXAPIClient
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lessonkit/xapi",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "private": false,
5
5
  "description": "xAPI statement generation primitives for LessonKit.",
6
6
  "license": "Apache-2.0",
@@ -45,7 +45,7 @@
45
45
  "lint": "echo \"(no lint configured yet)\""
46
46
  },
47
47
  "dependencies": {
48
- "@lessonkit/core": "0.3.0"
48
+ "@lessonkit/core": "0.3.1"
49
49
  },
50
50
  "devDependencies": {
51
51
  "tsup": "^8.5.0",