miaoda-game-devkit 0.2.9 → 0.2.10
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 +21 -1
- package/dist/cli/lint.js +32 -1
- package/dist/game-clock-suUidZdT.d.mts +11 -0
- package/dist/game-clock-suUidZdT.d.ts +11 -0
- package/dist/{gameplay-audit-CCJo4Qhk.d.mts → gameplay-audit-BwAobjIX.d.mts} +1 -1
- package/dist/{gameplay-audit-CCJo4Qhk.d.ts → gameplay-audit-BwAobjIX.d.ts} +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/lint/vitest-config.contract.mjs +213 -8
- package/dist/phaser-facade.mjs +156 -0
- package/dist/react/index.d.mts +13 -0
- package/dist/react/index.d.ts +13 -0
- package/dist/react/index.js +57 -0
- package/dist/react/index.mjs +29 -0
- package/dist/react/testing.d.mts +21 -0
- package/dist/react/testing.d.ts +21 -0
- package/dist/react/testing.js +82 -0
- package/dist/react/testing.mjs +57 -0
- package/dist/react/vitest-config.d.mts +14 -0
- package/dist/react/vitest-config.d.ts +14 -0
- package/dist/react/vitest-config.js +57 -0
- package/dist/react/vitest-config.mjs +32 -0
- package/dist/react/vitest-setup.d.mts +2 -0
- package/dist/react/vitest-setup.d.ts +2 -0
- package/dist/react/vitest-setup.js +35 -0
- package/dist/react/vitest-setup.mjs +33 -0
- package/dist/vite.d.mts +22 -0
- package/dist/vite.d.ts +22 -0
- package/dist/vite.js +93 -0
- package/dist/vite.mjs +67 -0
- package/dist/vitest-config.d.mts +1 -1
- package/dist/vitest-config.d.ts +1 -1
- package/dist/vitest-config.js +46 -2
- package/dist/vitest-config.mjs +46 -2
- package/package.json +72 -2
package/dist/vitest-config.d.mts
CHANGED
package/dist/vitest-config.d.ts
CHANGED
package/dist/vitest-config.js
CHANGED
|
@@ -23,7 +23,7 @@ __export(vitest_config_exports, {
|
|
|
23
23
|
defineGameVitestConfig: () => defineGameVitestConfig
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(vitest_config_exports);
|
|
26
|
-
var
|
|
26
|
+
var import_node_path4 = require("path");
|
|
27
27
|
var import_config = require("vitest/config");
|
|
28
28
|
|
|
29
29
|
// src/gameplay-audit.ts
|
|
@@ -627,6 +627,49 @@ GAMEPLAY_AUDIT: ALL CONTRACTS PASSED (${tests.filter((test) => test.metadata).le
|
|
|
627
627
|
}
|
|
628
628
|
};
|
|
629
629
|
|
|
630
|
+
// src/vite.ts
|
|
631
|
+
var import_node_fs2 = require("fs");
|
|
632
|
+
var import_node_module = require("module");
|
|
633
|
+
var import_node_path3 = require("path");
|
|
634
|
+
var PHASER_MODULE_ID = "phaser";
|
|
635
|
+
function resolvePhaserFacade(projectRoot) {
|
|
636
|
+
const requireFromProject = (0, import_node_module.createRequire)((0, import_node_path3.join)(projectRoot, "package.json"));
|
|
637
|
+
const viteEntry = requireFromProject.resolve("miaoda-game-devkit/vite");
|
|
638
|
+
const facade = (0, import_node_path3.join)((0, import_node_path3.dirname)(viteEntry), "phaser-facade.mjs");
|
|
639
|
+
if (!(0, import_node_fs2.existsSync)(facade)) {
|
|
640
|
+
throw new Error(
|
|
641
|
+
`miaoda-game-devkit \u7F3A\u5C11 Phaser facade\uFF1A${facade}`
|
|
642
|
+
);
|
|
643
|
+
}
|
|
644
|
+
return facade;
|
|
645
|
+
}
|
|
646
|
+
function isInsideDirectory(filePath, directory) {
|
|
647
|
+
const normalizedFile = (0, import_node_path3.normalize)(filePath);
|
|
648
|
+
const normalizedDirectory = `${(0, import_node_path3.normalize)(directory)}${import_node_path3.sep}`;
|
|
649
|
+
return normalizedFile.startsWith(normalizedDirectory);
|
|
650
|
+
}
|
|
651
|
+
function phaserRexUIScenePlugin(projectRoot) {
|
|
652
|
+
let scenesRoot = projectRoot ? (0, import_node_path3.resolve)(projectRoot, "src/scenes") : void 0;
|
|
653
|
+
let phaserFacade = projectRoot ? resolvePhaserFacade(projectRoot) : void 0;
|
|
654
|
+
return {
|
|
655
|
+
name: "miaoda-phaser-rexui-scene",
|
|
656
|
+
enforce: "pre",
|
|
657
|
+
configResolved(config) {
|
|
658
|
+
const resolvedProjectRoot = projectRoot ?? config.root;
|
|
659
|
+
scenesRoot ??= (0, import_node_path3.resolve)(resolvedProjectRoot, "src/scenes");
|
|
660
|
+
phaserFacade ??= resolvePhaserFacade(resolvedProjectRoot);
|
|
661
|
+
},
|
|
662
|
+
/** 查询参数属于构建工具元数据,去除后才能稳定判断真实源码位置。 */
|
|
663
|
+
resolveId(source, importer) {
|
|
664
|
+
if (source !== PHASER_MODULE_ID || !importer || !scenesRoot) {
|
|
665
|
+
return null;
|
|
666
|
+
}
|
|
667
|
+
const cleanImporter = importer.split("?", 1)[0] ?? importer;
|
|
668
|
+
return isInsideDirectory(cleanImporter, scenesRoot) ? phaserFacade ?? null : null;
|
|
669
|
+
}
|
|
670
|
+
};
|
|
671
|
+
}
|
|
672
|
+
|
|
630
673
|
// src/vitest-config.ts
|
|
631
674
|
function defineGameVitestConfig(options) {
|
|
632
675
|
const auditIssues = validateGameplayAuditOptions(options.gameplayAudit, options.projectRoot);
|
|
@@ -637,10 +680,11 @@ function defineGameVitestConfig(options) {
|
|
|
637
680
|
);
|
|
638
681
|
}
|
|
639
682
|
return (0, import_config.defineConfig)({
|
|
683
|
+
plugins: [phaserRexUIScenePlugin(options.projectRoot)],
|
|
640
684
|
resolve: {
|
|
641
685
|
alias: {
|
|
642
686
|
...options.aliases,
|
|
643
|
-
"@": (0,
|
|
687
|
+
"@": (0, import_node_path4.resolve)(options.projectRoot, "src")
|
|
644
688
|
}
|
|
645
689
|
},
|
|
646
690
|
// devkit 作为 external ESM 加载时,应用测试也必须 externalize Phaser,
|
package/dist/vitest-config.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/vitest-config.ts
|
|
2
|
-
import { resolve } from "path";
|
|
2
|
+
import { resolve as resolve2 } from "path";
|
|
3
3
|
import { defineConfig } from "vitest/config";
|
|
4
4
|
|
|
5
5
|
// src/gameplay-audit.ts
|
|
@@ -603,6 +603,49 @@ GAMEPLAY_AUDIT: ALL CONTRACTS PASSED (${tests.filter((test) => test.metadata).le
|
|
|
603
603
|
}
|
|
604
604
|
};
|
|
605
605
|
|
|
606
|
+
// src/vite.ts
|
|
607
|
+
import { existsSync } from "fs";
|
|
608
|
+
import { createRequire } from "module";
|
|
609
|
+
import { dirname, join as join2, normalize, resolve, sep } from "path";
|
|
610
|
+
var PHASER_MODULE_ID = "phaser";
|
|
611
|
+
function resolvePhaserFacade(projectRoot) {
|
|
612
|
+
const requireFromProject = createRequire(join2(projectRoot, "package.json"));
|
|
613
|
+
const viteEntry = requireFromProject.resolve("miaoda-game-devkit/vite");
|
|
614
|
+
const facade = join2(dirname(viteEntry), "phaser-facade.mjs");
|
|
615
|
+
if (!existsSync(facade)) {
|
|
616
|
+
throw new Error(
|
|
617
|
+
`miaoda-game-devkit \u7F3A\u5C11 Phaser facade\uFF1A${facade}`
|
|
618
|
+
);
|
|
619
|
+
}
|
|
620
|
+
return facade;
|
|
621
|
+
}
|
|
622
|
+
function isInsideDirectory(filePath, directory) {
|
|
623
|
+
const normalizedFile = normalize(filePath);
|
|
624
|
+
const normalizedDirectory = `${normalize(directory)}${sep}`;
|
|
625
|
+
return normalizedFile.startsWith(normalizedDirectory);
|
|
626
|
+
}
|
|
627
|
+
function phaserRexUIScenePlugin(projectRoot) {
|
|
628
|
+
let scenesRoot = projectRoot ? resolve(projectRoot, "src/scenes") : void 0;
|
|
629
|
+
let phaserFacade = projectRoot ? resolvePhaserFacade(projectRoot) : void 0;
|
|
630
|
+
return {
|
|
631
|
+
name: "miaoda-phaser-rexui-scene",
|
|
632
|
+
enforce: "pre",
|
|
633
|
+
configResolved(config) {
|
|
634
|
+
const resolvedProjectRoot = projectRoot ?? config.root;
|
|
635
|
+
scenesRoot ??= resolve(resolvedProjectRoot, "src/scenes");
|
|
636
|
+
phaserFacade ??= resolvePhaserFacade(resolvedProjectRoot);
|
|
637
|
+
},
|
|
638
|
+
/** 查询参数属于构建工具元数据,去除后才能稳定判断真实源码位置。 */
|
|
639
|
+
resolveId(source, importer) {
|
|
640
|
+
if (source !== PHASER_MODULE_ID || !importer || !scenesRoot) {
|
|
641
|
+
return null;
|
|
642
|
+
}
|
|
643
|
+
const cleanImporter = importer.split("?", 1)[0] ?? importer;
|
|
644
|
+
return isInsideDirectory(cleanImporter, scenesRoot) ? phaserFacade ?? null : null;
|
|
645
|
+
}
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
|
|
606
649
|
// src/vitest-config.ts
|
|
607
650
|
function defineGameVitestConfig(options) {
|
|
608
651
|
const auditIssues = validateGameplayAuditOptions(options.gameplayAudit, options.projectRoot);
|
|
@@ -613,10 +656,11 @@ function defineGameVitestConfig(options) {
|
|
|
613
656
|
);
|
|
614
657
|
}
|
|
615
658
|
return defineConfig({
|
|
659
|
+
plugins: [phaserRexUIScenePlugin(options.projectRoot)],
|
|
616
660
|
resolve: {
|
|
617
661
|
alias: {
|
|
618
662
|
...options.aliases,
|
|
619
|
-
"@":
|
|
663
|
+
"@": resolve2(options.projectRoot, "src")
|
|
620
664
|
}
|
|
621
665
|
},
|
|
622
666
|
// devkit 作为 external ESM 加载时,应用测试也必须 externalize Phaser,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "miaoda-game-devkit",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.10",
|
|
4
4
|
"description": "Shared lint and deterministic Phaser HEADLESS testing tools for Miaoda games",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -30,7 +30,48 @@
|
|
|
30
30
|
"default": "./dist/vitest-config.js"
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
|
+
"./vite": {
|
|
34
|
+
"import": {
|
|
35
|
+
"types": "./dist/vite.d.mts",
|
|
36
|
+
"default": "./dist/vite.mjs"
|
|
37
|
+
},
|
|
38
|
+
"require": {
|
|
39
|
+
"types": "./dist/vite.d.ts",
|
|
40
|
+
"default": "./dist/vite.js"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
33
43
|
"./vitest-setup": "./dist/lint/setup.mjs",
|
|
44
|
+
"./react": {
|
|
45
|
+
"import": {
|
|
46
|
+
"types": "./dist/react/index.d.mts",
|
|
47
|
+
"default": "./dist/react/index.mjs"
|
|
48
|
+
},
|
|
49
|
+
"require": {
|
|
50
|
+
"types": "./dist/react/index.d.ts",
|
|
51
|
+
"default": "./dist/react/index.js"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"./react/testing": {
|
|
55
|
+
"import": {
|
|
56
|
+
"types": "./dist/react/testing.d.mts",
|
|
57
|
+
"default": "./dist/react/testing.mjs"
|
|
58
|
+
},
|
|
59
|
+
"require": {
|
|
60
|
+
"types": "./dist/react/testing.d.ts",
|
|
61
|
+
"default": "./dist/react/testing.js"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"./react/vitest-config": {
|
|
65
|
+
"import": {
|
|
66
|
+
"types": "./dist/react/vitest-config.d.mts",
|
|
67
|
+
"default": "./dist/react/vitest-config.mjs"
|
|
68
|
+
},
|
|
69
|
+
"require": {
|
|
70
|
+
"types": "./dist/react/vitest-config.d.ts",
|
|
71
|
+
"default": "./dist/react/vitest-config.js"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"./react/vitest-setup": "./dist/react/vitest-setup.mjs",
|
|
34
75
|
"./biome": "./biome-config.json",
|
|
35
76
|
"./tsconfig-base": "./tsconfig-base.json"
|
|
36
77
|
},
|
|
@@ -80,7 +121,36 @@
|
|
|
80
121
|
"vitest": "^4.1.10"
|
|
81
122
|
},
|
|
82
123
|
"peerDependencies": {
|
|
83
|
-
"
|
|
124
|
+
"@testing-library/jest-dom": ">=6 <8",
|
|
125
|
+
"@testing-library/react": ">=16 <17",
|
|
126
|
+
"phaser": ">=4.0.0 <5",
|
|
127
|
+
"phaser4-rex-plugins": ">=4.0.0 <5",
|
|
128
|
+
"react": ">=19 <20",
|
|
129
|
+
"react-dom": ">=19 <20",
|
|
130
|
+
"vite": ">=6 <9"
|
|
131
|
+
},
|
|
132
|
+
"peerDependenciesMeta": {
|
|
133
|
+
"@testing-library/jest-dom": {
|
|
134
|
+
"optional": true
|
|
135
|
+
},
|
|
136
|
+
"@testing-library/react": {
|
|
137
|
+
"optional": true
|
|
138
|
+
},
|
|
139
|
+
"phaser": {
|
|
140
|
+
"optional": true
|
|
141
|
+
},
|
|
142
|
+
"phaser4-rex-plugins": {
|
|
143
|
+
"optional": true
|
|
144
|
+
},
|
|
145
|
+
"react": {
|
|
146
|
+
"optional": true
|
|
147
|
+
},
|
|
148
|
+
"react-dom": {
|
|
149
|
+
"optional": true
|
|
150
|
+
},
|
|
151
|
+
"vite": {
|
|
152
|
+
"optional": true
|
|
153
|
+
}
|
|
84
154
|
},
|
|
85
155
|
"publishConfig": {
|
|
86
156
|
"registry": "https://registry.npmjs.org/",
|