Live2D / CubismCocosCreatorComponents

Other
4 stars 6 forks source link

Some building errors but more like a naming oversight #14

Open Yunxi-awa opened 4 months ago

Yunxi-awa commented 4 months ago

Here is the error output.

H:\CocosProject\PlantsVsZombies\extensions\live2d_cubismsdk_cocoscreator>npm install

added 3 packages, and audited 4 packages in 4s
found 0 vulnerabilities

H:\CocosProject\PlantsVsZombies\extensions\live2d_cubismsdk_cocoscreator>npm run build
> live2d_cubismsdk_cocoscreator@5.0.0-beta.1 build
> tsc -b

static/assets/Framework/ComponentExtensionMethods.ts:13:33 - error TS2724: '"cc".__private' has no exported member named '_types_globals__Constructor'. Did you mean '__types_globals__Constructor'?

13     classConstructor: __private._types_globals__Constructor<T>
                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~
static/assets/Framework/ComponentExtensionMethods.ts:25:38 - error TS2769: No overload matches this call.
  Overload 1 of 2, '(...items: ConcatArray<T>[]): T[]', gave the following error.
    Argument of type 'Component[]' is not assignable to parameter of type 'ConcatArray<T>'.
      The types returned by 'slice(...)' are incompatible between these types.
        Type 'Component[]' is not assignable to type 'T[]'.
          Type 'Component' is not assignable to type 'T'.
            'Component' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Component'.
  Overload 2 of 2, '(...items: (T | ConcatArray<T>)[]): T[]', gave the following error.
    Argument of type 'Component[]' is not assignable to parameter of type 'T | ConcatArray<T>'.
      Type 'Component[]' is not assignable to type 'ConcatArray<T>'.

25       components = components.concat(range);
                                        ~~~~~
static/assets/Framework/ComponentExtensionMethods.ts:39:33 - error TS2724: '"cc".__private' has no exported member named '_types_globals__Constructor'. Did you mean '__types_globals__Constructor'?
39     classConstructor: __private._types_globals__Constructor<T>
                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~
static/assets/Framework/Pose/CubismPoseController.ts:78:34 - error TS2339: Property 'groupIndex' does not exist on type 'Component'.
78       const groupIndex = tags[i].groupIndex;
                                    ~~~~~~~~~~
static/assets/Framework/Pose/CubismPoseController.ts:79:33 - error TS2339: Property 'partIndex' does not exist on type 'Component'.
79       const partIndex = tags[i].partIndex;
                                   ~~~~~~~~~
static/assets/Framework/Pose/CubismPoseController.ts:97:30 - error TS2739: Type 'Component' is missing the following properties from type 'CubismPosePart': groupIndex, partIndex, link
97       data = data.copyWith({ posePart: tags[i], part: tags[i].getComponent(CubismPart) });
                                ~~~~~~~~
static/assets/Framework/Pose/CubismPoseController.ts:114:19 - error TS2339: Property 'link' does not exist on type 'Component'.
114       if (tags[i].link == null || tags[i].link.length == 0) {
                      ~~~~
static/assets/Framework/Pose/CubismPoseController.ts:114:43 - error TS2339: Property 'link' does not exist on type 'Component'.
114       if (tags[i].link == null || tags[i].link.length == 0) {
                                              ~~~~
static/assets/Framework/Pose/CubismPoseController.ts:118:62 - error TS2339: Property 'link' does not exist on type 'Component'.
118       const linkParts = new Array<CubismPart | null>(tags[i].link.length);
                                                                 ~~~~
static/assets/Framework/Pose/CubismPoseController.ts:119:35 - error TS2339: Property 'link' does not exist on type 'Component'.
119       for (let j = 0; j < tags[i].link.length; j++) {
                                      ~~~~
static/assets/Framework/Pose/CubismPoseController.ts:120:30 - error TS2339: Property 'link' does not exist on type 'Component'.
120         let linkId = tags[i].link[j];
                                 ~~~~
Found 11 errors.

H:\CocosProject\PlantsVsZombies\extensions\live2d_cubismsdk_cocoscreator>npm run build
> live2d_cubismsdk_cocoscreator@5.0.0-beta.1 build
> tsc -b
static/assets/Framework/ComponentExtensionMethods.ts:39:33 - error TS2724: '"cc".__private' has no exported member named '_types_globals__Constructor'. Did you mean '__types_globals__Constructor'?
39     classConstructor: __private._types_globals__Constructor<T>
                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 1 error.

H:\CocosProject\PlantsVsZombies\extensions\live2d_cubismsdk_cocoscreator>npm run build
> live2d_cubismsdk_cocoscreator@5.0.0-beta.1 build
> tsc -b

H:\CocosProject\PlantsVsZombies\extensions\live2d_cubismsdk_cocoscreator>

I completely followed the instructions in the README file to import the SDK, but the build did not go smoothly.

I found that it was because there were two missing underscores in the static/sets/Framework/ComponentExtensionMethods.ts file.

Line 13: classConstructor: __private._types_globals__Constructor<T>
                                     ^
Line 39: classConstructor: __private._types_globals__Constructor<T>
                                     ^

After adding the underline, the build no longer had any problems. I think there must have been an oversight in the naming, because "__private._types_globals_Constructor" should be the correct version🤔

nanshaws commented 3 weeks ago

me too

nanshaws commented 3 weeks ago

The following error occurs when you add an extension directly with cocos

The plug-in main process failed to load. Error: Cannot find module 'D:\cocosWorkspaces\HelloWorld\extensions\live2d_cubismsdk_cocoscreator\dist\main.js' Require stack: