@cjhd/cj-event-emitter 1.0.1 → 1.1.2

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,13 @@
1
+ {
2
+ "schema": "cj-package-v1",
3
+ "name": "@cjhd/cj-event-emitter",
4
+ "version": "1.1.2",
5
+ "payloadManifest": "encrypted-payload/manifest.json",
6
+ "entry": "index.js",
7
+ "assetsDir": "assets",
8
+ "generatedFiles": [
9
+ "assets/EventEmitter.js",
10
+ "index.js"
11
+ ],
12
+ "dependencies": []
13
+ }
@@ -0,0 +1,6 @@
1
+ function __cjLicenseError() {
2
+ throw new Error("[CJHD License] Runtime package is not unlocked. Expected license file: extensions/pkg/node_modules/@cjhd/cj-cocos-license/bin/cj-runtime-license.json. Then run: node extensions/pkg/node_modules/@cjhd/cj-cocos-license/bin/cj-license.js --mode install --force");
3
+ }
4
+
5
+ export class EventEmitter { constructor() { __cjLicenseError(); } }
6
+ export function __cj_package_not_unlocked__() { __cjLicenseError(); }
@@ -0,0 +1,32 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import childProcess from 'node:child_process';
4
+ import { fileURLToPath } from 'node:url';
5
+
6
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
7
+ const packageRoot = path.resolve(__dirname, '..');
8
+ const cjhdRoot = path.dirname(packageRoot);
9
+ const pkgRoot = path.resolve(cjhdRoot, '../..');
10
+ const cli = path.join(cjhdRoot, 'cj-cocos-license', 'bin', 'cj-license.js');
11
+
12
+ if (!fs.existsSync(cli)) {
13
+ console.warn('[CJHD License] @cjhd/cj-cocos-license is not installed; keeping unauthorized stubs.');
14
+ process.exit(0);
15
+ }
16
+
17
+ const result = childProcess.spawnSync(process.execPath, [
18
+ cli,
19
+ '--mode',
20
+ 'install',
21
+ '--soft',
22
+ '--pkg-root',
23
+ pkgRoot
24
+ ], {
25
+ cwd: pkgRoot,
26
+ stdio: 'inherit',
27
+ shell: false
28
+ });
29
+
30
+ if (result.status !== 0) {
31
+ console.warn('[CJHD License] install unlock check did not complete; keeping unauthorized stubs.');
32
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "schema": "cj-encrypted-payload-v1",
3
+ "packageName": "@cjhd/cj-event-emitter",
4
+ "packageVersion": "1.1.2",
5
+ "algorithm": "AES-256-GCM",
6
+ "kdf": "HKDF-SHA256",
7
+ "sourceHash": "129d209fe3d626f9a33f9216f6b24379cbbabdb908e47ee39e52b83229db23f9",
8
+ "payloadHash": "ecd16fc90841f80044abe4015b6747ca885630de24ebd5f31fb3dd9949195b2f",
9
+ "files": [
10
+ {
11
+ "out": "assets/EventEmitter.js",
12
+ "bin": "files/assets__EventEmitter.js.bin",
13
+ "iv": "P5DYctQ0GGurRdvi",
14
+ "authTag": "VfHs22dc8x1hfIYmhyUPBA==",
15
+ "sha256": "9158b2e2f5ed0e5a7cec070510d483cbf0d7e9ec1e0c88ea216662f0710d5186"
16
+ },
17
+ {
18
+ "out": "index.js",
19
+ "bin": "files/index.js.bin",
20
+ "iv": "AebTV57yPFrNgIyJ",
21
+ "authTag": "NMZYANeFvh6MRuqScDm8hw==",
22
+ "sha256": "4742c8af69dcde9e83eeedd2dbcbe2fe5d51881cc201eeb3bc6b5c59750df402"
23
+ }
24
+ ],
25
+ "publicExports": [
26
+ "EventEmitter"
27
+ ],
28
+ "createdAt": "2026-05-20T02:39:03.265Z"
29
+ }
package/index.js ADDED
@@ -0,0 +1,6 @@
1
+ function __cjLicenseError() {
2
+ throw new Error("[CJHD License] Runtime package is not unlocked. Expected license file: extensions/pkg/node_modules/@cjhd/cj-cocos-license/bin/cj-runtime-license.json. Then run: node extensions/pkg/node_modules/@cjhd/cj-cocos-license/bin/cj-license.js --mode install --force");
3
+ }
4
+
5
+ export { EventEmitter } from './assets/EventEmitter.js';
6
+ export function __cj_package_not_unlocked__() { __cjLicenseError(); }
package/package.json CHANGED
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "name": "@cjhd/cj-event-emitter",
3
- "version": "1.0.1",
4
- "engine": ">=3.8.0",
3
+ "version": "1.1.2",
5
4
  "description": "全局事件触发器:零依赖、轻量级",
6
- "main": "./dist/cocos/index.js",
5
+ "main": "./index.js",
6
+ "scripts": {
7
+ "postinstall": "node ./bin/package-postinstall.js"
8
+ },
7
9
  "repository": {
8
10
  "type": "git",
9
11
  "url": "https://gitee.com/cocos2d-zp/cococs-creator-frame-3d"
@@ -13,28 +15,43 @@
13
15
  "registry": "https://registry.npmjs.org"
14
16
  },
15
17
  "author": "超M <402879660@qq.com>",
16
- "license": "MIT",
17
- "module": "./dist/cocos/index.js",
18
- "browser": "./dist/cocos/index.js",
18
+ "license": "SEE LICENSE IN README.md",
19
+ "type": "module",
20
+ "browser": "./index.js",
19
21
  "types": "./index.d.ts",
20
22
  "exports": {
21
23
  ".": {
22
24
  "types": "./index.d.ts",
23
- "import": "./dist/cocos/index.js",
24
- "browser": "./dist/cocos/index.js",
25
- "default": "./dist/cocos/index.js"
25
+ "browser": "./index.js",
26
+ "import": "./index.js",
27
+ "default": "./index.js"
26
28
  },
27
29
  "./assets/*": {
28
- "import": "./dist/cocos/assets/*",
29
- "browser": "./dist/cocos/assets/*",
30
- "default": "./dist/cocos/assets/*"
31
- }
30
+ "types": "./assets/*.d.ts",
31
+ "browser": "./assets/*.js",
32
+ "import": "./assets/*.js",
33
+ "default": "./assets/*.js"
34
+ },
35
+ "./package.json": "./package.json"
32
36
  },
33
37
  "files": [
34
- "dist/",
35
- "**/*.d.ts",
36
38
  "package.json",
37
39
  "README.md",
38
- "license/"
39
- ]
40
+ "index.d.ts",
41
+ "index.js",
42
+ "assets/**/*.d.ts",
43
+ "assets/**/*.js",
44
+ "encrypted-payload/**",
45
+ "bin/**",
46
+ ".cj-package.json"
47
+ ],
48
+ "dependencies": {},
49
+ "peerDependencies": {
50
+ "@cjhd/cj-cocos-license": "^1.0.0"
51
+ },
52
+ "peerDependenciesMeta": {
53
+ "@cjhd/cj-cocos-license": {
54
+ "optional": true
55
+ }
56
+ }
40
57
  }
@@ -1,2 +0,0 @@
1
- /* CJ_RUNTIME_PROTECTED_JS */
2
- "use strict";function isValidListener(e){return"function"==typeof e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.EventEmitter=void 0;class EventEmitter{constructor(){this._map=new Map}on(e,t,i){if(!isValidListener(t))return void console.warn("[EventEmitter] ignore invalid on listener:",e,t);let n=this._map.get(e);n||(n=new Set,this._map.set(e,n)),n.add({fn:t,ctx:i})}once(e,t,i){if(!isValidListener(t))return void console.warn("[EventEmitter] ignore invalid once listener:",e,t);let n=this._map.get(e);n||(n=new Set,this._map.set(e,n)),n.add({fn:t,ctx:i,once:!0})}off(e,t,i){const n=this._map.get(e);if(n)if(null!=t){for(const e of Array.from(n))e&&e.fn===t&&(void 0!==i&&i!==e.ctx||n.delete(e));0===n.size&&this._map.delete(e)}else this._map.delete(e)}targetOff(e){if(null!=e)for(const[t,i]of Array.from(this._map.entries())){for(const t of Array.from(i))t&&t.ctx===e&&i.delete(t);0===i.size&&this._map.delete(t)}}offAll(e){void 0===e?this._map.clear():this._map.delete(e)}emit(e,...t){const i=this._map.get(e);if(!i)return;const n=Array.from(i);for(const r of n)if(r&&isValidListener(r.fn))try{r.fn.apply(r.ctx,t)}finally{r.once&&i.delete(r)}else i.delete(r),console.warn("[EventEmitter] remove invalid listener while emitting:",e,r);0===i.size&&this._map.delete(e)}}exports.EventEmitter=EventEmitter;
@@ -1,2 +0,0 @@
1
- /* CJ_RUNTIME_PROTECTED_JS */
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.EventEmitter=void 0;var EventEmitter_1=require("./assets/EventEmitter");Object.defineProperty(exports,"EventEmitter",{enumerable:!0,get:function(){return EventEmitter_1.EventEmitter}});