Skip to content

Commit

Permalink
expose some internals, fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
lajbel committed Apr 14, 2024
1 parent 40fa318 commit d40b27a
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 67 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
node_modules

dist
test
test
docs.json
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# 1.0.0 (unreleased)
# 1.0.0 (unreleased)
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ kiboom is a Kaboom.js plugin that mainly provides a set of new "factory"
functions, made for create new easily modifiable objects.

## Installation

```
npm install kiboom
```

## Usage

```js
import kaboom from "kaboom";
import { kiboom } from "kiboom";
Expand All @@ -18,4 +20,4 @@ kaboom({
// New methods
makeSprite();
makeText();
```
```
4 changes: 3 additions & 1 deletion dprint.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
},
"excludes": [
"**/node_modules",
"**/*-lock.json"
"**/*-lock.yaml",
"**/docs",
"**/dist"
],
"plugins": [
"https://plugins.dprint.dev/typescript-0.90.0.wasm",
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"scripts": {
"build": "dts-bundle-generator -o dist/first.d.ts src/types.ts && node scripts/buildAll.js",
"doc": "typedoc",
"test": "esbuild --bundle test/main.ts --outfile=test/game.js --servedir=test --sourcemap"
"doc:json": "typedoc --json docs.json",
"test": "esbuild --bundle test/main.ts --outfile=test/game.js --servedir=test --sourcemap",
"fmt": "dprint fmt"
},
"exports": {
".": {
Expand Down Expand Up @@ -42,12 +44,12 @@
"author": "",
"license": "ISC",
"dependencies": {
"dprint": "^0.45.0",
"kaboom": "^3000.1.17"
},
"devDependencies": {
"@types/json-schema": "^7.0.15",
"@types/node": "^20.12.5",
"dprint": "^0.45.1",
"dts-bundle-generator": "^9.3.1",
"esbuild": "^0.20.2",
"puppeteer": "^22.6.3",
Expand Down
68 changes: 34 additions & 34 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/components/childrens.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Comp, EmptyComp } from "kaboom";

type ChildrenDefinition<T extends Comp[]> = {
export type ChildrenDefinition<T extends Comp[]> = {
[name: string]: () => T;
};

Expand Down
10 changes: 6 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { children } from "./components/childrens";
import { custom } from "./components/custom";
import { extendMaker, makeMaker } from "./factory/makers";
import { makeOptions } from "./factory/options";
import { makeArea } from "./objects/makeArea";
Expand All @@ -8,18 +10,18 @@ import { makeRect } from "./objects/makeRect";
import { makeRender } from "./objects/makeRender";
import { makeSprite } from "./objects/makeSprite";
import { makeText } from "./objects/makeText";
import { createOptions } from "./options/createOptions";
import { createKaboomPlugin } from "./plugin";
import { kiScene } from "./scenes/kiScene";
import { KiboomPlugin } from "./types";

const { run: kiboom } = createKaboomPlugin<KiboomPlugin>(() => {
return {
// kiScene,
kiScene,
// createKaboomPlugin,

// components
// custom,
// children,
custom: custom,
children: children,

// objects
makeObject,
Expand Down
18 changes: 0 additions & 18 deletions src/options/createOptions.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/scenes/SceneState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ export class SceneState<T> {

k.go(scene, ...args);
}
}
}
2 changes: 1 addition & 1 deletion src/scenes/kiScene.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SceneState } from "./SceneState";
import { getK } from "../plugin";
import { SceneState } from "./SceneState";

export const kiScene = <T extends {}>(
name: string,
Expand Down
26 changes: 25 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import type {
AreaComp,
Comp,
EmptyComp,
GameObj,
KaboomCtx,
RectComp,
SpriteComp,
TextComp,
} from "kaboom";
import { extendMaker, makeMaker } from "./factory/makers";
import { ChildrenDefinition } from "./components/childrens";
import { extendMaker } from "./factory/makers";
import type { AreaOpt } from "./objects/makeArea";
import type { BackgroundOpt } from "./objects/makeBg";
import type { CircleOpt } from "./objects/makeCircle";
Expand All @@ -15,6 +18,7 @@ import type { RectOpt } from "./objects/makeRect";
import type { RenderComps, RenderOpt } from "./objects/makeRender";
import type { SpriteOpt } from "./objects/makeSprite";
import type { TextOpt } from "./objects/makeText";
import { SceneState } from "./scenes/SceneState";
import { ApplierFN, MakerFN, OptionalOptionFN, OptionFN } from "./utils/types";

export declare function kiboom(k: KaboomCtx): KiboomPlugin;
Expand Down Expand Up @@ -164,4 +168,24 @@ export interface KiboomPlugin {
componentsApply: ApplierFN<TNewComps, TNewOpt & TBaseOpt>,
baseDefaultOpt?: OptionalOptionFN<TBaseOpt>,
): MakerFN<TNewOpt & TBaseOpt, TNewComps & TBaseComps>;

/**
* Create an scene with an SceneManager
*
* @alpha In development
*/
kiScene<T extends {}>(
name: string,
def: (sceneData: SceneState<T>, ...args: any[]) => void,
): () => void;

/**
* A component for define a custom component
*/
custom<T>(custom: () => T): Comp & T;

/**
* A component for define a childrens
*/
children(childrens: ChildrenDefinition<Comp[]>): EmptyComp;
}

0 comments on commit d40b27a

Please sign in to comment.