@combos-fun/plugin-renderer-text 0.0.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/README.md +3 -0
- package/dist/plugin-renderer-text.cjs.js +89 -0
- package/dist/plugin-renderer-text.cjs.js.map +1 -0
- package/dist/plugin-renderer-text.cjs.prod.js +1 -0
- package/dist/plugin-renderer-text.d.ts +36 -0
- package/dist/plugin-renderer-text.esm.js +86 -0
- package/dist/plugin-renderer-text.esm.js.map +1 -0
- package/index.js +7 -0
- package/package.json +29 -0
package/README.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib = require('tslib');
|
|
4
|
+
var engine = require('@combos-fun/engine');
|
|
5
|
+
var inspectorDecorator = require('@combos-fun/inspector-decorator');
|
|
6
|
+
var pluginRenderer = require('@combos-fun/plugin-renderer');
|
|
7
|
+
var rendererAdapter = require('@combos-fun/renderer-adapter');
|
|
8
|
+
|
|
9
|
+
let Text$1 = class Text extends engine.Component {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.text = '';
|
|
13
|
+
// @decorators.IDEProp 复杂编辑后续添加
|
|
14
|
+
this.style = {};
|
|
15
|
+
}
|
|
16
|
+
static { this.componentName = 'Text'; }
|
|
17
|
+
init(obj) {
|
|
18
|
+
this.style = { fontSize: 20 };
|
|
19
|
+
if (obj) {
|
|
20
|
+
this.text = obj.text;
|
|
21
|
+
Object.assign(this.style, obj.style);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
tslib.__decorate([
|
|
26
|
+
inspectorDecorator.type('string')
|
|
27
|
+
], Text$1.prototype, "text", void 0);
|
|
28
|
+
|
|
29
|
+
let Text = class Text extends pluginRenderer.Renderer {
|
|
30
|
+
constructor() {
|
|
31
|
+
super(...arguments);
|
|
32
|
+
this.name = 'Text';
|
|
33
|
+
this.texts = {};
|
|
34
|
+
}
|
|
35
|
+
static { this.systemName = 'Text'; }
|
|
36
|
+
init() {
|
|
37
|
+
this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
|
|
38
|
+
this.renderSystem.rendererManager.register(this);
|
|
39
|
+
}
|
|
40
|
+
async componentChanged(changed) {
|
|
41
|
+
if (changed.componentName !== 'Text')
|
|
42
|
+
return;
|
|
43
|
+
if (changed.type === engine.OBSERVER_TYPE.ADD) {
|
|
44
|
+
const component = changed.component;
|
|
45
|
+
const text = new rendererAdapter.Text(component.text, component.style);
|
|
46
|
+
this.containerManager.getContainer(changed.gameObject.id).addChildAt(text, 0);
|
|
47
|
+
this.texts[changed.gameObject.id] = {
|
|
48
|
+
text,
|
|
49
|
+
component: changed.component,
|
|
50
|
+
};
|
|
51
|
+
this.setSize(changed);
|
|
52
|
+
}
|
|
53
|
+
else if (changed.type === engine.OBSERVER_TYPE.REMOVE) {
|
|
54
|
+
this.containerManager.getContainer(changed.gameObject.id).removeChild(this.texts[changed.gameObject.id].text);
|
|
55
|
+
this.texts[changed.gameObject.id].text.destroy({ children: true });
|
|
56
|
+
delete this.texts[changed.gameObject.id];
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
this.change(changed);
|
|
60
|
+
this.setSize(changed);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
change(changed) {
|
|
64
|
+
const { text, component } = this.texts[changed.gameObject.id];
|
|
65
|
+
if (changed.prop.prop[0] === 'text') {
|
|
66
|
+
text.text = component.text;
|
|
67
|
+
}
|
|
68
|
+
else if (changed.prop.prop[0] === 'style') {
|
|
69
|
+
Object.assign(text.style, changed.component.style);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
setSize(changed) {
|
|
73
|
+
const { transform } = changed.gameObject;
|
|
74
|
+
if (!transform)
|
|
75
|
+
return;
|
|
76
|
+
transform.size.width = this.texts[changed.gameObject.id].text.width;
|
|
77
|
+
transform.size.height = this.texts[changed.gameObject.id].text.height;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
Text = tslib.__decorate([
|
|
81
|
+
engine.decorators.componentObserver({
|
|
82
|
+
Text: ['text', { prop: ['style'], deep: true }],
|
|
83
|
+
})
|
|
84
|
+
], Text);
|
|
85
|
+
var Text_default = Text;
|
|
86
|
+
|
|
87
|
+
exports.Text = Text$1;
|
|
88
|
+
exports.TextSystem = Text_default;
|
|
89
|
+
//# sourceMappingURL=plugin-renderer-text.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-renderer-text.cjs.js","sources":["../lib/component.ts","../lib/system.ts"],"sourcesContent":["import type { TextStyle } from 'pixi.js';\nimport { Component } from '@combos-fun/engine';\nimport { type } from '@combos-fun/inspector-decorator';\n\nexport interface TextParams {\n text: string;\n style?: Partial<TextStyle>;\n}\n\nexport default class Text extends Component<TextParams> {\n static componentName: string = 'Text';\n @type('string') text: string = '';\n // @decorators.IDEProp 复杂编辑后续添加\n style: TextParams['style'] = {};\n init(obj?: TextParams) {\n this.style = { fontSize: 20 };\n if (obj) {\n this.text = obj.text;\n Object.assign(this.style, obj.style);\n }\n }\n}\n","import { decorators, ComponentChanged, OBSERVER_TYPE } from '@combos-fun/engine';\n\nimport { RendererManager, ContainerManager, RendererSystem, Renderer } from '@combos-fun/plugin-renderer';\nimport { Text as TextEngine } from '@combos-fun/renderer-adapter';\n\nimport TextComponent from './component';\n@decorators.componentObserver({\n Text: ['text', { prop: ['style'], deep: true }],\n})\nexport default class Text extends Renderer {\n static systemName = 'Text';\n name: string = 'Text';\n texts: {\n [propName: number]: { text: TextEngine; component: TextComponent };\n } = {};\n renderSystem: RendererSystem;\n rendererManager: RendererManager;\n containerManager: ContainerManager;\n init() {\n this.renderSystem = this.game.getSystem(RendererSystem) as RendererSystem;\n this.renderSystem.rendererManager.register(this);\n }\n async componentChanged(changed: ComponentChanged) {\n if (changed.componentName !== 'Text') return;\n if (changed.type === OBSERVER_TYPE.ADD) {\n const component = changed.component as TextComponent;\n const text = new TextEngine(component.text, component.style);\n this.containerManager.getContainer(changed.gameObject.id).addChildAt(text, 0);\n this.texts[changed.gameObject.id] = {\n text,\n component: changed.component as TextComponent,\n };\n this.setSize(changed);\n } else if (changed.type === OBSERVER_TYPE.REMOVE) {\n this.containerManager.getContainer(changed.gameObject.id).removeChild(this.texts[changed.gameObject.id].text);\n this.texts[changed.gameObject.id].text.destroy({ children: true });\n delete this.texts[changed.gameObject.id];\n } else {\n this.change(changed);\n this.setSize(changed);\n }\n }\n change(changed: ComponentChanged) {\n const { text, component } = this.texts[changed.gameObject.id];\n if (changed.prop.prop[0] === 'text') {\n text.text = component.text;\n } else if (changed.prop.prop[0] === 'style') {\n Object.assign(text.style, (changed.component as TextComponent).style);\n }\n }\n setSize(changed: ComponentChanged) {\n const { transform } = changed.gameObject;\n if (!transform) return;\n transform.size.width = this.texts[changed.gameObject.id].text.width;\n transform.size.height = this.texts[changed.gameObject.id].text.height;\n }\n}\n"],"names":["Component","__decorate","type","Text","Renderer","RendererSystem","OBSERVER_TYPE","TextEngine","decorators"],"mappings":";;;;;;;;aASc,MAAO,IAAK,SAAQA,gBAAqB,CAAA;AAAvD,IAAA,WAAA,GAAA;;QAEkB,IAAA,CAAA,IAAI,GAAW,EAAE;;QAEjC,IAAA,CAAA,KAAK,GAAwB,EAAE;IAQjC;aAXS,IAAA,CAAA,aAAa,GAAW,MAAX,CAAkB;AAItC,IAAA,IAAI,CAAC,GAAgB,EAAA;QACnB,IAAI,CAAC,KAAK,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE;QAC7B,IAAI,GAAG,EAAE;AACP,YAAA,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI;YACpB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC;QACtC;IACF;;AATgBC,gBAAA,CAAA;IAAfC,uBAAI,CAAC,QAAQ;AAAoB,CAAA,EAAAC,MAAA,CAAA,SAAA,E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AC,MAAM;IACvE;;AA9CmB,IAAI,GAAAL,gBAAA,CAAA;IAHxBO,iBAAU,CAAC,iBAAiB,CAAC;AAC5B,QAAA,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;KAChD;AACoB,CAAA,EAAA,IAAI,CA+CxB;mBA/CoB,IAAI;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("tslib"),t=require("@combos-fun/engine"),s=require("@combos-fun/inspector-decorator"),i=require("@combos-fun/plugin-renderer"),r=require("@combos-fun/renderer-adapter");let n=class extends t.Component{constructor(){super(...arguments),this.text="",this.style={}}static{this.componentName="Text"}init(e){this.style={fontSize:20},e&&(this.text=e.text,Object.assign(this.style,e.style))}};e.__decorate([s.type("string")],n.prototype,"text",void 0);let o=class extends i.Renderer{constructor(){super(...arguments),this.name="Text",this.texts={}}static{this.systemName="Text"}init(){this.renderSystem=this.game.getSystem(i.RendererSystem),this.renderSystem.rendererManager.register(this)}async componentChanged(e){if("Text"===e.componentName)if(e.type===t.OBSERVER_TYPE.ADD){const t=e.component,s=new r.Text(t.text,t.style);this.containerManager.getContainer(e.gameObject.id).addChildAt(s,0),this.texts[e.gameObject.id]={text:s,component:e.component},this.setSize(e)}else e.type===t.OBSERVER_TYPE.REMOVE?(this.containerManager.getContainer(e.gameObject.id).removeChild(this.texts[e.gameObject.id].text),this.texts[e.gameObject.id].text.destroy({children:!0}),delete this.texts[e.gameObject.id]):(this.change(e),this.setSize(e))}change(e){const{text:t,component:s}=this.texts[e.gameObject.id];"text"===e.prop.prop[0]?t.text=s.text:"style"===e.prop.prop[0]&&Object.assign(t.style,e.component.style)}setSize(e){const{transform:t}=e.gameObject;t&&(t.size.width=this.texts[e.gameObject.id].text.width,t.size.height=this.texts[e.gameObject.id].text.height)}};o=e.__decorate([t.decorators.componentObserver({Text:["text",{prop:["style"],deep:!0}]})],o);var c=o;exports.Text=n,exports.TextSystem=c;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { TextStyle } from 'pixi.js';
|
|
2
|
+
import { Component, ComponentChanged } from '@combos-fun/engine';
|
|
3
|
+
import { Renderer, RendererSystem, RendererManager, ContainerManager } from '@combos-fun/plugin-renderer';
|
|
4
|
+
import { Text as Text$2 } from '@combos-fun/renderer-adapter';
|
|
5
|
+
|
|
6
|
+
interface TextParams {
|
|
7
|
+
text: string;
|
|
8
|
+
style?: Partial<TextStyle>;
|
|
9
|
+
}
|
|
10
|
+
declare class Text$1 extends Component<TextParams> {
|
|
11
|
+
static componentName: string;
|
|
12
|
+
text: string;
|
|
13
|
+
style: TextParams['style'];
|
|
14
|
+
init(obj?: TextParams): void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
declare class Text extends Renderer {
|
|
18
|
+
static systemName: string;
|
|
19
|
+
name: string;
|
|
20
|
+
texts: {
|
|
21
|
+
[propName: number]: {
|
|
22
|
+
text: Text$2;
|
|
23
|
+
component: Text$1;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
renderSystem: RendererSystem;
|
|
27
|
+
rendererManager: RendererManager;
|
|
28
|
+
containerManager: ContainerManager;
|
|
29
|
+
init(): void;
|
|
30
|
+
componentChanged(changed: ComponentChanged): Promise<void>;
|
|
31
|
+
change(changed: ComponentChanged): void;
|
|
32
|
+
setSize(changed: ComponentChanged): void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { Text$1 as Text, Text as TextSystem };
|
|
36
|
+
export type { TextParams };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { __decorate } from 'tslib';
|
|
2
|
+
import { Component, OBSERVER_TYPE, decorators } from '@combos-fun/engine';
|
|
3
|
+
import { type } from '@combos-fun/inspector-decorator';
|
|
4
|
+
import { Renderer, RendererSystem } from '@combos-fun/plugin-renderer';
|
|
5
|
+
import { Text as Text$2 } from '@combos-fun/renderer-adapter';
|
|
6
|
+
|
|
7
|
+
let Text$1 = class Text extends Component {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.text = '';
|
|
11
|
+
// @decorators.IDEProp 复杂编辑后续添加
|
|
12
|
+
this.style = {};
|
|
13
|
+
}
|
|
14
|
+
static { this.componentName = 'Text'; }
|
|
15
|
+
init(obj) {
|
|
16
|
+
this.style = { fontSize: 20 };
|
|
17
|
+
if (obj) {
|
|
18
|
+
this.text = obj.text;
|
|
19
|
+
Object.assign(this.style, obj.style);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
__decorate([
|
|
24
|
+
type('string')
|
|
25
|
+
], Text$1.prototype, "text", void 0);
|
|
26
|
+
|
|
27
|
+
let Text = class Text extends Renderer {
|
|
28
|
+
constructor() {
|
|
29
|
+
super(...arguments);
|
|
30
|
+
this.name = 'Text';
|
|
31
|
+
this.texts = {};
|
|
32
|
+
}
|
|
33
|
+
static { this.systemName = 'Text'; }
|
|
34
|
+
init() {
|
|
35
|
+
this.renderSystem = this.game.getSystem(RendererSystem);
|
|
36
|
+
this.renderSystem.rendererManager.register(this);
|
|
37
|
+
}
|
|
38
|
+
async componentChanged(changed) {
|
|
39
|
+
if (changed.componentName !== 'Text')
|
|
40
|
+
return;
|
|
41
|
+
if (changed.type === OBSERVER_TYPE.ADD) {
|
|
42
|
+
const component = changed.component;
|
|
43
|
+
const text = new Text$2(component.text, component.style);
|
|
44
|
+
this.containerManager.getContainer(changed.gameObject.id).addChildAt(text, 0);
|
|
45
|
+
this.texts[changed.gameObject.id] = {
|
|
46
|
+
text,
|
|
47
|
+
component: changed.component,
|
|
48
|
+
};
|
|
49
|
+
this.setSize(changed);
|
|
50
|
+
}
|
|
51
|
+
else if (changed.type === OBSERVER_TYPE.REMOVE) {
|
|
52
|
+
this.containerManager.getContainer(changed.gameObject.id).removeChild(this.texts[changed.gameObject.id].text);
|
|
53
|
+
this.texts[changed.gameObject.id].text.destroy({ children: true });
|
|
54
|
+
delete this.texts[changed.gameObject.id];
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
this.change(changed);
|
|
58
|
+
this.setSize(changed);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
change(changed) {
|
|
62
|
+
const { text, component } = this.texts[changed.gameObject.id];
|
|
63
|
+
if (changed.prop.prop[0] === 'text') {
|
|
64
|
+
text.text = component.text;
|
|
65
|
+
}
|
|
66
|
+
else if (changed.prop.prop[0] === 'style') {
|
|
67
|
+
Object.assign(text.style, changed.component.style);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
setSize(changed) {
|
|
71
|
+
const { transform } = changed.gameObject;
|
|
72
|
+
if (!transform)
|
|
73
|
+
return;
|
|
74
|
+
transform.size.width = this.texts[changed.gameObject.id].text.width;
|
|
75
|
+
transform.size.height = this.texts[changed.gameObject.id].text.height;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
Text = __decorate([
|
|
79
|
+
decorators.componentObserver({
|
|
80
|
+
Text: ['text', { prop: ['style'], deep: true }],
|
|
81
|
+
})
|
|
82
|
+
], Text);
|
|
83
|
+
var Text_default = Text;
|
|
84
|
+
|
|
85
|
+
export { Text$1 as Text, Text_default as TextSystem };
|
|
86
|
+
//# sourceMappingURL=plugin-renderer-text.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-renderer-text.esm.js","sources":["../lib/component.ts","../lib/system.ts"],"sourcesContent":["import type { TextStyle } from 'pixi.js';\nimport { Component } from '@combos-fun/engine';\nimport { type } from '@combos-fun/inspector-decorator';\n\nexport interface TextParams {\n text: string;\n style?: Partial<TextStyle>;\n}\n\nexport default class Text extends Component<TextParams> {\n static componentName: string = 'Text';\n @type('string') text: string = '';\n // @decorators.IDEProp 复杂编辑后续添加\n style: TextParams['style'] = {};\n init(obj?: TextParams) {\n this.style = { fontSize: 20 };\n if (obj) {\n this.text = obj.text;\n Object.assign(this.style, obj.style);\n }\n }\n}\n","import { decorators, ComponentChanged, OBSERVER_TYPE } from '@combos-fun/engine';\n\nimport { RendererManager, ContainerManager, RendererSystem, Renderer } from '@combos-fun/plugin-renderer';\nimport { Text as TextEngine } from '@combos-fun/renderer-adapter';\n\nimport TextComponent from './component';\n@decorators.componentObserver({\n Text: ['text', { prop: ['style'], deep: true }],\n})\nexport default class Text extends Renderer {\n static systemName = 'Text';\n name: string = 'Text';\n texts: {\n [propName: number]: { text: TextEngine; component: TextComponent };\n } = {};\n renderSystem: RendererSystem;\n rendererManager: RendererManager;\n containerManager: ContainerManager;\n init() {\n this.renderSystem = this.game.getSystem(RendererSystem) as RendererSystem;\n this.renderSystem.rendererManager.register(this);\n }\n async componentChanged(changed: ComponentChanged) {\n if (changed.componentName !== 'Text') return;\n if (changed.type === OBSERVER_TYPE.ADD) {\n const component = changed.component as TextComponent;\n const text = new TextEngine(component.text, component.style);\n this.containerManager.getContainer(changed.gameObject.id).addChildAt(text, 0);\n this.texts[changed.gameObject.id] = {\n text,\n component: changed.component as TextComponent,\n };\n this.setSize(changed);\n } else if (changed.type === OBSERVER_TYPE.REMOVE) {\n this.containerManager.getContainer(changed.gameObject.id).removeChild(this.texts[changed.gameObject.id].text);\n this.texts[changed.gameObject.id].text.destroy({ children: true });\n delete this.texts[changed.gameObject.id];\n } else {\n this.change(changed);\n this.setSize(changed);\n }\n }\n change(changed: ComponentChanged) {\n const { text, component } = this.texts[changed.gameObject.id];\n if (changed.prop.prop[0] === 'text') {\n text.text = component.text;\n } else if (changed.prop.prop[0] === 'style') {\n Object.assign(text.style, (changed.component as TextComponent).style);\n }\n }\n setSize(changed: ComponentChanged) {\n const { transform } = changed.gameObject;\n if (!transform) return;\n transform.size.width = this.texts[changed.gameObject.id].text.width;\n transform.size.height = this.texts[changed.gameObject.id].text.height;\n }\n}\n"],"names":["Text","TextEngine"],"mappings":";;;;;;aASc,MAAO,IAAK,SAAQ,SAAqB,CAAA;AAAvD,IAAA,WAAA,GAAA;;QAEkB,IA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AAI,CAAC,KAAK,EAAG,OAAO,CAAC,SAA2B,CAAC,KAAK,CAAC;QACvE;IACF;AACA,IAAA,OAAO,CAAC,OAAyB,EAAA;AAC/B,QAAA,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,UAAU;AACxC,QAAA,IAAI,CAAC,SAAS;YAAE;AAChB,QAAA,SAAS,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK;AACnE,QAAA,SAAS,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM;IACvE;;AA9CmB,IAAI,GAAA,UAAA,CAAA;IAHxB,UAAU,CAAC,iBAAiB,CAAC;AAC5B,QAAA,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;KAChD;AACoB,CAAA,EAAA,IAAI,CA+CxB;mBA/CoB,IAAI;;;;"}
|
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@combos-fun/plugin-renderer-text",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "@combos-fun/plugin-renderer-text",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"module": "dist/plugin-renderer-text.esm.js",
|
|
7
|
+
"bundle": "CombosFun.plugin.renderer.text",
|
|
8
|
+
"unpkg": "dist/CombosFun.plugin.renderer.text.min.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"index.js",
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"types": "dist/plugin-renderer-text.d.ts",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"combos-fun",
|
|
16
|
+
"game"
|
|
17
|
+
],
|
|
18
|
+
"author": "sun668 <q947692259@gmail.com>",
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"pixi.js": "^8.18.1",
|
|
21
|
+
"@combos-fun/plugin-renderer": "0.0.1",
|
|
22
|
+
"@combos-fun/renderer-adapter": "0.0.1",
|
|
23
|
+
"@combos-fun/engine": "0.0.1",
|
|
24
|
+
"@combos-fun/inspector-decorator": "0.0.1"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "node ../../scripts/build-package.mjs"
|
|
28
|
+
}
|
|
29
|
+
}
|