Skip to content

Commit 8c30d95

Browse files
committed
refactor(structure): reorganize source files into categorized directories
1 parent 585e4f4 commit 8c30d95

31 files changed

+91
-79
lines changed

examples/advanced-scheduling/demo.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { pipeline } from "@codehz/pipeline";
2-
import { component } from "../../src/entity";
3-
import type { Query } from "../../src/query";
4-
import { World } from "../../src/world";
2+
import { World, component, type Query } from "../../src";
53

64
// 定义组件类型
75
type Position = { x: number; y: number };

examples/simple/demo.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { pipeline } from "@codehz/pipeline";
2-
import { component, relation } from "../../src/entity";
3-
import type { Query } from "../../src/query";
4-
import { World } from "../../src/world";
2+
import { component, relation, World, type Query } from "../../src";
53

64
// 定义组件类型
75
type Position = { x: number; y: number };

scripts/release.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,12 @@ pkg.version = version;
4040

4141
// 运行构建
4242
console.log("🔨 Running build process...");
43-
const entries = ["/index", "/testing"];
43+
const entries = [
44+
{ name: "/index", path: "/index.ts" },
45+
{ name: "/testing", path: "/testing/index.ts" },
46+
];
4447
await build({
45-
entry: entries.map((e) => `src${e}.ts`),
48+
entry: Object.fromEntries(entries.map((e) => [e.name, `src${e.path}`])),
4649
outDir: "dist",
4750
dts: true,
4851
sourcemap: true,
@@ -52,10 +55,10 @@ await build({
5255
// 生成 exports
5356
const exports: Record<string, any> = Object.fromEntries(
5457
entries.map((e) => [
55-
`.${e === "/index" ? "" : e}`,
58+
`.${e.name === "/index" ? "" : e.name}`,
5659
{
57-
types: `.${e}.d.mts`,
58-
import: `.${e}.mjs`,
60+
types: `.${e.name}.d.mts`,
61+
import: `.${e.name}.mjs`,
5962
},
6063
]),
6164
);

src/__tests__/archetype.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, expect, it } from "bun:test";
2-
import { Archetype } from "../archetype";
3-
import { component, createEntityId, relation, type EntityId } from "../entity";
2+
import { Archetype } from "../core/archetype";
3+
import { component, createEntityId, relation, type EntityId } from "../core/entity";
44

55
describe("Archetype", () => {
66
type Position = { x: number; y: number };

src/__tests__/changeset.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, expect, it } from "bun:test";
2-
import { ComponentChangeset } from "../changeset";
3-
import { component } from "../entity";
2+
import { ComponentChangeset } from "../commands/changeset";
3+
import { component } from "../core/entity";
44

55
describe("ComponentChangeset", () => {
66
const PositionId = component<{ x: number; y: number }>();

src/__tests__/command-buffer.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, expect, it } from "bun:test";
2-
import { CommandBuffer, type Command } from "../command-buffer";
3-
import type { EntityId } from "../entity";
2+
import { CommandBuffer, type Command } from "../commands/command-buffer";
3+
import type { EntityId } from "../core/entity";
44

55
describe("CommandBuffer", () => {
66
it("should buffer commands and execute them", () => {

src/__tests__/dont-fragment-query-notification.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, expect, it } from "bun:test";
2-
import { component, relation } from "../entity";
3-
import { World } from "../world";
2+
import { component, relation } from "../core/entity";
3+
import { World } from "../core/world";
44

55
describe("DontFragment Query Notification Issue", () => {
66
it("should notify queries when new archetypes with dontFragment relations are created", () => {

src/__tests__/dont-fragment.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, expect, it } from "bun:test";
2-
import { component, relation, type EntityId } from "../entity";
3-
import { World } from "../world";
2+
import { component, relation, type EntityId } from "../core/entity";
3+
import { World } from "../core/world";
44

55
describe("DontFragment Relations", () => {
66
it("should prevent archetype fragmentation for dontFragment relations", () => {

src/__tests__/entity.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it } from "bun:test";
2-
import type { ComponentId, EntityId } from "../entity";
2+
import type { ComponentId, EntityId } from "../core/entity";
33
import {
44
component,
55
COMPONENT_ID_MAX,
@@ -24,7 +24,7 @@ import {
2424
isRelationId,
2525
isWildcardRelationId,
2626
relation,
27-
} from "../entity";
27+
} from "../core/entity";
2828

2929
describe("Entity ID System", () => {
3030
describe("Component IDs", () => {

src/__tests__/get-optional.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, expect, it } from "bun:test";
2-
import { component, relation } from "../entity";
3-
import { World } from "../world";
2+
import { component, relation } from "../core/entity";
3+
import { World } from "../core/world";
44

55
describe("World.getOptional", () => {
66
it("should return { value: T } when component exists", () => {

0 commit comments

Comments
 (0)