@skillprint/cocos-sdk 0.0.1 → 1.0.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/README.md ADDED
@@ -0,0 +1,126 @@
1
+ # Skillprint Cocos Creator SDK
2
+
3
+ TypeScript SDK for integrating Skillprint into Cocos Creator 3.8.x games. This SDK enables real-time session tracking, automated screenshot canvas captures for mood/skill analysis, and dynamic parameter adjustments (adaptive difficulty, relaxation pacing, grit challenges) based on player analytics.
4
+
5
+ For details on the published npm package, visit [npm package @skillprint/cocos-sdk](https://www.npmjs.com/package/@skillprint/cocos-sdk).
6
+
7
+ ---
8
+
9
+ ## 🚀 Installation
10
+
11
+ Install the package in your Cocos Creator project root:
12
+
13
+ ```bash
14
+ npm install @skillprint/cocos-sdk
15
+ ```
16
+
17
+ ---
18
+
19
+ ## 🛠️ Cocos Creator Setup
20
+
21
+ Cocos Creator's editor registers serializable component classes and inspector fields from files located inside the `assets/` directory. To use the SDK's editor-facing configuration and manager components:
22
+
23
+ ### 1. Create Local Wrappers
24
+
25
+ Create a directory in your project under `assets/scripts/SkillprintSDK/` and add the following wrapper scripts. They inherit from the npm package components, allowing them to register in the Cocos Creator Asset database and inspector.
26
+
27
+ #### 📄 `assets/scripts/SkillprintSDK/SkillprintConfigComponent.ts`
28
+ ```typescript
29
+ import { _decorator } from 'cc';
30
+ import { SkillprintConfigComponent as SDKConfig } from '@skillprint/cocos-sdk';
31
+ const { ccclass } = _decorator;
32
+
33
+ @ccclass('SkillprintConfigComponent')
34
+ export class SkillprintConfigComponent extends SDKConfig {}
35
+ ```
36
+
37
+ #### 📄 `assets/scripts/SkillprintSDK/SkillprintManager.ts`
38
+ ```typescript
39
+ import { _decorator } from 'cc';
40
+ import { SkillprintManager as SDKManager } from '@skillprint/cocos-sdk';
41
+ const { ccclass } = _decorator;
42
+
43
+ @ccclass('SkillprintManager')
44
+ export class SkillprintManager extends SDKManager {}
45
+ ```
46
+
47
+ ### 2. Configure in Scene Editor
48
+ 1. Create a Node in your Cocos Creator hierarchy (e.g. named `SkillprintManager`).
49
+ 2. Attach both the local `SkillprintManager` and `SkillprintConfigComponent` to it.
50
+ 3. In the **Inspector** panel for `SkillprintConfigComponent`:
51
+ - Set your **Game Name (Slug)** (e.g., `fruit-boom`).
52
+ - Select your target environment (`Staging` or `Production`).
53
+ - Input your **Staging/Production Partner API Keys** and **Base URLs**.
54
+ - Configure screenshot frequencies (default: `2s` capture, `5s` post intervals) and downscaling width (default: `960px`).
55
+
56
+ ---
57
+
58
+ ## 💻 Integration & Usage
59
+
60
+ Use a controller script (e.g. attached to your main scene node) to initialize the SDK and react to parameter updates.
61
+
62
+ ### Code Example: `SkillprintTestController.ts`
63
+ ```typescript
64
+ import { _decorator, Component } from 'cc';
65
+ import { SkillprintConfig, ApiEnvironment, ParameterType } from '@skillprint/cocos-sdk';
66
+ import { SkillprintManager } from './SkillprintSDK/SkillprintManager';
67
+
68
+ const { ccclass } = _decorator;
69
+
70
+ @ccclass('SkillprintTestController')
71
+ export class SkillprintTestController extends Component {
72
+
73
+ start() {
74
+ // 1. Get the local Manager component instance
75
+ let manager = this.getComponent(SkillprintManager);
76
+ if (!manager) {
77
+ manager = this.node.addComponent(SkillprintManager);
78
+ }
79
+
80
+ // 2. Register modifiers for parameters your game should adapt
81
+ SkillprintManager.instance.registerParameterModifier<number>('playerSpeed', (newSpeed) => {
82
+ console.log(`[Game Logic] Adjusting speed -> ${newSpeed}`);
83
+ // Apply speed to your player object here
84
+ });
85
+
86
+ SkillprintManager.instance.registerParameterModifier<boolean>('showTutorialHints', (show) => {
87
+ console.log(`[Game Logic] Toggle hints -> ${show}`);
88
+ // Apply hint display settings
89
+ });
90
+
91
+ // 3. Start the game session
92
+ // (It will read URL overrides if launched in browser preview: ?mood=focus&playerId=test-user)
93
+ SkillprintManager.instance.startGameSessionFromUrl('focus', 'player-id-123');
94
+ }
95
+
96
+ onDestroy() {
97
+ // Ensure session terminates correctly when scene changes or controller destroys
98
+ if (SkillprintManager.instance) {
99
+ SkillprintManager.instance.stopGameSession();
100
+ }
101
+ }
102
+ }
103
+ ```
104
+
105
+ ### Reference in UI scripts (like `HomeUI.ts`)
106
+ To reference your configuration from other scripts:
107
+ ```typescript
108
+ import { _decorator, Component } from 'cc';
109
+ import { SkillprintConfigComponent } from './SkillprintSDK/SkillprintConfigComponent';
110
+ import { SkillprintManager } from './SkillprintSDK/SkillprintManager';
111
+
112
+ const { ccclass, property } = _decorator;
113
+
114
+ @ccclass('HomeUI')
115
+ export class HomeUI extends Component {
116
+ @property(SkillprintConfigComponent)
117
+ public skillprintConfig: SkillprintConfigComponent = null!;
118
+
119
+ start() {
120
+ const manager = this.node.addComponent(SkillprintManager);
121
+ if (this.skillprintConfig) {
122
+ manager.init(this.skillprintConfig.getConfig());
123
+ }
124
+ }
125
+ }
126
+ ```
@@ -1,4 +1,4 @@
1
- import { ParameterInfo, ParameterUpdateResult } from './SkillprintTypes';
1
+ import { ParameterInfo, ParameterUpdateResult } from './SkillprintTypes.js';
2
2
  export declare class SkillprintAPIClient {
3
3
  private baseUrl;
4
4
  private partnerApiKey;
@@ -1,5 +1,5 @@
1
1
  import { Component } from 'cc';
2
- import { ApiEnvironment, SkillprintConfig } from './SkillprintTypes';
2
+ import { ApiEnvironment, SkillprintConfig } from './SkillprintTypes.js';
3
3
  export declare class SkillprintConfigComponent extends Component {
4
4
  gameName: string;
5
5
  targetEnvironment: ApiEnvironment;
@@ -5,7 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { _decorator, Component, Enum } from 'cc';
8
- import { ApiEnvironment } from './SkillprintTypes';
8
+ import { ApiEnvironment } from './SkillprintTypes.js';
9
9
  const { ccclass, property } = _decorator;
10
10
  Enum(ApiEnvironment);
11
11
  let SkillprintConfigComponent = class SkillprintConfigComponent extends Component {
@@ -1,5 +1,5 @@
1
1
  import { Component } from 'cc';
2
- import { SkillprintConfig } from './SkillprintTypes';
2
+ import { SkillprintConfig } from './SkillprintTypes.js';
3
3
  export declare class SkillprintManager extends Component {
4
4
  private static _instance;
5
5
  static get instance(): SkillprintManager;
@@ -6,9 +6,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  };
7
7
  var SkillprintManager_1;
8
8
  import { _decorator, Component, director, Camera, sys, Enum } from 'cc';
9
- import { ParameterType, ApiEnvironment } from './SkillprintTypes';
10
- import { SkillprintAPIClient } from './SkillprintAPIClient';
11
- import { ScreenshotUtility } from './ScreenshotUtility';
9
+ import { ParameterType, ApiEnvironment } from './SkillprintTypes.js';
10
+ import { SkillprintAPIClient } from './SkillprintAPIClient.js';
11
+ import { ScreenshotUtility } from './ScreenshotUtility.js';
12
12
  const { ccclass, property } = _decorator;
13
13
  Enum(ApiEnvironment);
14
14
  let SkillprintManager = SkillprintManager_1 = class SkillprintManager extends Component {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export * from './SkillprintTypes';
2
- export * from './SkillprintAPIClient';
3
- export * from './ScreenshotUtility';
4
- export * from './SkillprintManager';
5
- export * from './SkillprintConfigComponent';
1
+ export * from './SkillprintTypes.js';
2
+ export * from './SkillprintAPIClient.js';
3
+ export * from './ScreenshotUtility.js';
4
+ export * from './SkillprintManager.js';
5
+ export * from './SkillprintConfigComponent.js';
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- export * from './SkillprintTypes';
2
- export * from './SkillprintAPIClient';
3
- export * from './ScreenshotUtility';
4
- export * from './SkillprintManager';
5
- export * from './SkillprintConfigComponent';
1
+ export * from './SkillprintTypes.js';
2
+ export * from './SkillprintAPIClient.js';
3
+ export * from './ScreenshotUtility.js';
4
+ export * from './SkillprintManager.js';
5
+ export * from './SkillprintConfigComponent.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skillprint/cocos-sdk",
3
- "version": "0.0.1",
3
+ "version": "1.0.0",
4
4
  "type": "module",
5
5
  "description": "Skillprint SDK for Cocos Creator 3.x",
6
6
  "main": "dist/index.js",
@@ -9,7 +9,8 @@
9
9
  "access": "public"
10
10
  },
11
11
  "scripts": {
12
- "build": "tsc"
12
+ "build": "tsc",
13
+ "release": "./publish.sh"
13
14
  },
14
15
  "peerDependencies": {
15
16
  "cc": "*"
package/publish.sh ADDED
@@ -0,0 +1,70 @@
1
+ #!/bin/bash
2
+ # Exit immediately if a command exits with a non-zero status
3
+ set -e
4
+
5
+ echo "=== 🚀 Starting build and release process ==="
6
+
7
+ # Get current branch
8
+ CURRENT_BRANCH=$(git branch --show-current)
9
+ if [ -z "$CURRENT_BRANCH" ]; then
10
+ echo "❌ Could not determine current git branch. Aborting."
11
+ exit 1
12
+ fi
13
+
14
+ # 1. Build the project to verify it compiles before making any changes
15
+ echo "Building the SDK..."
16
+ npm run build
17
+
18
+ # 2. Check if git working directory is clean
19
+ if [ -n "$(git status --porcelain)" ]; then
20
+ echo "⚠️ Working directory is not clean. Please commit or stash your changes before releasing."
21
+ exit 1
22
+ fi
23
+
24
+ # 3. Determine version bump type (from argument or prompt)
25
+ BUMP_TYPE=$1
26
+
27
+ if [ -z "$BUMP_TYPE" ]; then
28
+ echo "Select version bump type:"
29
+ echo "1) patch (e.g. bump last digit)"
30
+ echo "2) minor (e.g. bump middle digit)"
31
+ echo "3) major (e.g. bump first digit)"
32
+ read -p "Enter choice [1-3] (default: patch): " choice
33
+
34
+ case "$choice" in
35
+ 2) BUMP_TYPE="minor" ;;
36
+ 3) BUMP_TYPE="major" ;;
37
+ *) BUMP_TYPE="patch" ;;
38
+ esac
39
+ fi
40
+
41
+ # Validate bump type
42
+ if [ "$BUMP_TYPE" != "patch" ] && [ "$BUMP_TYPE" != "minor" ] && [ "$BUMP_TYPE" != "major" ]; then
43
+ echo "❌ Invalid bump type '$BUMP_TYPE'. Must be 'patch', 'minor', or 'major'."
44
+ exit 1
45
+ fi
46
+
47
+ echo "Incrementing $BUMP_TYPE version..."
48
+ NEW_VERSION=$(npm version "$BUMP_TYPE")
49
+ echo "New version: $NEW_VERSION"
50
+
51
+ # 4. Push git commit and tags to remote origin
52
+ echo "Pushing changes and tags to GitHub ($CURRENT_BRANCH)..."
53
+ git push origin "$CURRENT_BRANCH"
54
+ git push origin "$NEW_VERSION"
55
+
56
+ # 5. Publish to npm
57
+ echo "Publishing to npm..."
58
+ # This will run interactively and prompt for 2FA OTP if required by the account settings
59
+ npm publish
60
+
61
+ # 6. Create GitHub release
62
+ echo "Creating GitHub release..."
63
+ if which gh > /dev/null 2>&1; then
64
+ gh release create "$NEW_VERSION" --title "$NEW_VERSION" --notes "Release $NEW_VERSION of @skillprint/cocos-sdk"
65
+ echo "GitHub release created successfully."
66
+ else
67
+ echo "⚠️ GitHub CLI (gh) not found or not authenticated. Skipping release creation."
68
+ fi
69
+
70
+ echo "=== 🎉 Release $NEW_VERSION successfully published! ==="
@@ -1,4 +1,4 @@
1
- import { ParameterInfo, ParameterUpdateResult, PollResultsResponse } from './SkillprintTypes';
1
+ import { ParameterInfo, ParameterUpdateResult, PollResultsResponse } from './SkillprintTypes.js';
2
2
 
3
3
  export class SkillprintAPIClient {
4
4
  private baseUrl: string;
@@ -1,5 +1,5 @@
1
1
  import { _decorator, Component, Enum } from 'cc';
2
- import { ApiEnvironment, SkillprintConfig } from './SkillprintTypes';
2
+ import { ApiEnvironment, SkillprintConfig } from './SkillprintTypes.js';
3
3
 
4
4
  const { ccclass, property } = _decorator;
5
5
 
@@ -1,7 +1,7 @@
1
1
  import { _decorator, Component, director, Camera, sys, Enum } from 'cc';
2
- import { SkillprintConfig, ParameterDefinition, ParameterType, ParameterInfo, ParameterUpdateResult, Mood, ApiEnvironment } from './SkillprintTypes';
3
- import { SkillprintAPIClient } from './SkillprintAPIClient';
4
- import { ScreenshotUtility } from './ScreenshotUtility';
2
+ import { SkillprintConfig, ParameterDefinition, ParameterType, ParameterInfo, ParameterUpdateResult, Mood, ApiEnvironment } from './SkillprintTypes.js';
3
+ import { SkillprintAPIClient } from './SkillprintAPIClient.js';
4
+ import { ScreenshotUtility } from './ScreenshotUtility.js';
5
5
 
6
6
  const { ccclass, property } = _decorator;
7
7
 
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
- export * from './SkillprintTypes';
2
- export * from './SkillprintAPIClient';
3
- export * from './ScreenshotUtility';
4
- export * from './SkillprintManager';
5
- export * from './SkillprintConfigComponent';
1
+ export * from './SkillprintTypes.js';
2
+ export * from './SkillprintAPIClient.js';
3
+ export * from './ScreenshotUtility.js';
4
+ export * from './SkillprintManager.js';
5
+ export * from './SkillprintConfigComponent.js';
Binary file