modern-canvas 0.0.3 → 0.1.0
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 +33 -42
- package/dist/index.cjs +14067 -17
- package/dist/index.d.cts +3115 -0
- package/dist/index.d.mts +3115 -0
- package/dist/index.d.ts +3115 -0
- package/dist/index.js +869 -17
- package/dist/index.mjs +13861 -614
- package/package.json +59 -28
- package/types/app.d.ts +0 -63
- package/types/container.d.ts +0 -13
- package/types/create-app.d.ts +0 -3
- package/types/index.d.ts +0 -4
- package/types/material.d.ts +0 -24
- package/types/node.d.ts +0 -4
- package/types/options.d.ts +0 -7
- package/types/plugin.d.ts +0 -6
- package/types/plugins/index.d.ts +0 -1
- package/types/plugins/renderer2d.d.ts +0 -1
- package/types/query.d.ts +0 -4
- package/types/render.d.ts +0 -13
- package/types/setup.d.ts +0 -2
- package/types/shape.d.ts +0 -12
- package/types/system.d.ts +0 -5
- package/types/texture.d.ts +0 -7
- package/types/utils.d.ts +0 -11
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "modern-canvas",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0
|
|
5
|
-
"packageManager": "pnpm@
|
|
6
|
-
"description": "A
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"packageManager": "pnpm@9.15.1",
|
|
6
|
+
"description": "A JavaScript WebGL rendering engine.",
|
|
7
7
|
"author": "wxm",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"homepage": "https://github.com/qq15725/modern-canvas",
|
|
@@ -23,46 +23,77 @@
|
|
|
23
23
|
"sideEffects": false,
|
|
24
24
|
"exports": {
|
|
25
25
|
".": {
|
|
26
|
-
"types": "./
|
|
27
|
-
"
|
|
28
|
-
"
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"import": "./dist/index.mjs",
|
|
28
|
+
"require": "./dist/index.cjs"
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
|
-
"main": "dist/index.mjs",
|
|
32
|
-
"module": "dist/index.mjs",
|
|
33
|
-
"types": "
|
|
34
|
-
"browser": "dist/index.js",
|
|
31
|
+
"main": "./dist/index.mjs",
|
|
32
|
+
"module": "./dist/index.mjs",
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"browser": "./dist/index.js",
|
|
35
35
|
"typesVersions": {
|
|
36
36
|
"*": {
|
|
37
37
|
"*": [
|
|
38
|
-
"./
|
|
39
|
-
"./
|
|
38
|
+
"./dist/*",
|
|
39
|
+
"./dist/index.d.ts"
|
|
40
40
|
]
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
"files": [
|
|
44
|
-
"dist"
|
|
45
|
-
"types"
|
|
44
|
+
"dist"
|
|
46
45
|
],
|
|
47
46
|
"scripts": {
|
|
47
|
+
"build": "vite build && unbuild",
|
|
48
48
|
"dev": "vite docs",
|
|
49
49
|
"lint": "eslint src",
|
|
50
|
-
"test": "vitest --no-threads --no-isolate",
|
|
51
|
-
"build": "vite build && tsc --project tsconfig.build.json",
|
|
52
|
-
"build:docs": "vite build docs",
|
|
53
50
|
"version": "conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md",
|
|
54
|
-
"release": "bumpp package.json --commit \"release: v%s\" --push --all --tag"
|
|
51
|
+
"release": "bumpp package.json --commit \"release: v%s\" --push --all --tag",
|
|
52
|
+
"start": "esno src/index.ts",
|
|
53
|
+
"test": "vitest",
|
|
54
|
+
"typecheck": "tsc --noEmit",
|
|
55
|
+
"prepare": "simple-git-hooks"
|
|
56
|
+
},
|
|
57
|
+
"peerDependencies": {
|
|
58
|
+
"lottie-web": "^5",
|
|
59
|
+
"modern-gif": "^2"
|
|
60
|
+
},
|
|
61
|
+
"peerDependenciesMeta": {
|
|
62
|
+
"lottie-web": {
|
|
63
|
+
"optional": true
|
|
64
|
+
},
|
|
65
|
+
"modern-gif": {
|
|
66
|
+
"optional": true
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"dependencies": {
|
|
70
|
+
"colord": "^2.9.3",
|
|
71
|
+
"earcut": "^3.0.1",
|
|
72
|
+
"modern-font": "^0.3.5",
|
|
73
|
+
"modern-idoc": "^0.1.4",
|
|
74
|
+
"modern-path2d": "^1.0.1",
|
|
75
|
+
"modern-text": "^1.0.7"
|
|
55
76
|
},
|
|
56
77
|
"devDependencies": {
|
|
57
|
-
"@
|
|
58
|
-
"@types/
|
|
59
|
-
"@
|
|
60
|
-
"bumpp": "^
|
|
61
|
-
"conventional-changelog-cli": "^
|
|
62
|
-
"eslint": "^
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
78
|
+
"@antfu/eslint-config": "^3.12.1",
|
|
79
|
+
"@types/earcut": "^2.1.4",
|
|
80
|
+
"@types/node": "^22.10.3",
|
|
81
|
+
"bumpp": "^9.9.2",
|
|
82
|
+
"conventional-changelog-cli": "^5.0.0",
|
|
83
|
+
"eslint": "^9.17.0",
|
|
84
|
+
"lint-staged": "^15.3.0",
|
|
85
|
+
"lottie-web": "^5.12.2",
|
|
86
|
+
"modern-gif": "^2.0.4",
|
|
87
|
+
"simple-git-hooks": "^2.11.1",
|
|
88
|
+
"typescript": "^5.7.2",
|
|
89
|
+
"unbuild": "^3.2.0",
|
|
90
|
+
"vite": "^6.0.6",
|
|
91
|
+
"vitest": "^2.1.8"
|
|
92
|
+
},
|
|
93
|
+
"simple-git-hooks": {
|
|
94
|
+
"pre-commit": "pnpm lint-staged"
|
|
95
|
+
},
|
|
96
|
+
"lint-staged": {
|
|
97
|
+
"*": "eslint src --fix"
|
|
67
98
|
}
|
|
68
99
|
}
|
package/types/app.d.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import type { QueryOptions } from './query';
|
|
2
|
-
import type { RenderNodeOptions } from './render';
|
|
3
|
-
import type { System } from './system';
|
|
4
|
-
import type { Texture } from './texture';
|
|
5
|
-
import type { Shape, UserShape } from './shape';
|
|
6
|
-
import type { Node } from './node';
|
|
7
|
-
import type { Material, UserMaterial } from './material';
|
|
8
|
-
import type { Plugin } from './plugin';
|
|
9
|
-
import type { Container } from './container';
|
|
10
|
-
export interface App extends Container {
|
|
11
|
-
view: HTMLCanvasElement;
|
|
12
|
-
children: Node[];
|
|
13
|
-
context: WebGLRenderingContext;
|
|
14
|
-
defaultTexture: WebGLTexture;
|
|
15
|
-
framebuffers: {
|
|
16
|
-
buffer: WebGLFramebuffer | null;
|
|
17
|
-
depthBuffer: WebGLRenderbuffer | null;
|
|
18
|
-
texture: WebGLTexture | null;
|
|
19
|
-
resize(): void;
|
|
20
|
-
}[];
|
|
21
|
-
drawModes: {
|
|
22
|
-
points: GLenum;
|
|
23
|
-
linear: GLenum;
|
|
24
|
-
triangles: GLenum;
|
|
25
|
-
triangleStrip: GLenum;
|
|
26
|
-
triangleFan: GLenum;
|
|
27
|
-
};
|
|
28
|
-
slTypes: Record<number, 'float' | 'vec2' | 'vec3' | 'vec4' | 'int' | 'ivec2' | 'ivec3' | 'ivec4' | 'uint' | 'uvec2' | 'uvec3' | 'uvec4' | 'bool' | 'bvec2' | 'bvec3' | 'bvec4' | 'mat2' | 'mat3' | 'mat4' | 'sampler2D' | 'samplerCube' | 'sampler2DArray'>;
|
|
29
|
-
extensions: {
|
|
30
|
-
loseContext: WEBGL_lose_context | null;
|
|
31
|
-
};
|
|
32
|
-
width: number;
|
|
33
|
-
height: number;
|
|
34
|
-
plugins: Map<string, Plugin>;
|
|
35
|
-
shapes: Map<string, Shape>;
|
|
36
|
-
registerShape(name: string, shape: UserShape): void;
|
|
37
|
-
materials: Map<string, Material>;
|
|
38
|
-
registerMaterial(name: string, material: UserMaterial): void;
|
|
39
|
-
textures: Map<number, Texture>;
|
|
40
|
-
registerTexture(id: number, source: TexImageSource): Promise<void>;
|
|
41
|
-
lastState?: {
|
|
42
|
-
material: string;
|
|
43
|
-
shape: string;
|
|
44
|
-
};
|
|
45
|
-
entities: Map<number, {
|
|
46
|
-
path: number[];
|
|
47
|
-
archetypeId: string;
|
|
48
|
-
}>;
|
|
49
|
-
components: Map<string, number>;
|
|
50
|
-
archetypes: Map<string, {
|
|
51
|
-
entityIds: Set<number>;
|
|
52
|
-
codePoints: number[];
|
|
53
|
-
}>;
|
|
54
|
-
systems: System[];
|
|
55
|
-
registerSystem(system: System): void;
|
|
56
|
-
query(where?: QueryOptions): Node;
|
|
57
|
-
setup(): void;
|
|
58
|
-
load(): Promise<void>;
|
|
59
|
-
renderNode(options: RenderNodeOptions): void;
|
|
60
|
-
render(time?: number): void;
|
|
61
|
-
start(): void;
|
|
62
|
-
destroy(): void;
|
|
63
|
-
}
|
package/types/container.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export interface Container {
|
|
2
|
-
instances: Map<string, any>;
|
|
3
|
-
bindings: Map<string, {
|
|
4
|
-
value: () => any;
|
|
5
|
-
shared: boolean;
|
|
6
|
-
}>;
|
|
7
|
-
get<T = any>(key: string): T;
|
|
8
|
-
has(key: string): boolean;
|
|
9
|
-
set<T = any>(key: string, value: T): void;
|
|
10
|
-
bind<T = any>(key: string, value: () => T, shared?: boolean): void;
|
|
11
|
-
singleton<T = any>(key: string, value: () => T): void;
|
|
12
|
-
}
|
|
13
|
-
export declare function createContainer(): Container;
|
package/types/create-app.d.ts
DELETED
package/types/index.d.ts
DELETED
package/types/material.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { App } from './app';
|
|
2
|
-
export interface UserMaterial {
|
|
3
|
-
vertexShader: string;
|
|
4
|
-
fragmentShader: string;
|
|
5
|
-
uniforms?: Record<string, any>;
|
|
6
|
-
}
|
|
7
|
-
export type Material = UserMaterial & {
|
|
8
|
-
program: WebGLProgram;
|
|
9
|
-
attributes: Record<string, MaterialAttribute>;
|
|
10
|
-
uniforms: Record<string, MaterialUniform>;
|
|
11
|
-
setupAttributes(attributes: Record<string, any>): void;
|
|
12
|
-
setupUniforms(uniforms: Record<string, any>): void;
|
|
13
|
-
};
|
|
14
|
-
export interface MaterialAttribute {
|
|
15
|
-
type: App['slTypes'][keyof App['slTypes']];
|
|
16
|
-
isArray: boolean;
|
|
17
|
-
location: GLint;
|
|
18
|
-
}
|
|
19
|
-
export interface MaterialUniform {
|
|
20
|
-
type: App['slTypes'][keyof App['slTypes']];
|
|
21
|
-
isArray: boolean;
|
|
22
|
-
location: WebGLUniformLocation | null;
|
|
23
|
-
}
|
|
24
|
-
export declare function registerMaterial(app: App, name: string, userMaterial: UserMaterial): void;
|
package/types/node.d.ts
DELETED
package/types/options.d.ts
DELETED
package/types/plugin.d.ts
DELETED
package/types/plugins/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './renderer2d';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const Renderer2d: import("../plugin").Plugin;
|
package/types/query.d.ts
DELETED
package/types/render.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { App } from './app';
|
|
2
|
-
export interface RenderNodeOptions {
|
|
3
|
-
shape: string;
|
|
4
|
-
material: string;
|
|
5
|
-
uniforms?: Record<string, any>;
|
|
6
|
-
extraRenderers?: {
|
|
7
|
-
shape: string;
|
|
8
|
-
material: string;
|
|
9
|
-
uniforms?: Record<string, any>;
|
|
10
|
-
}[];
|
|
11
|
-
}
|
|
12
|
-
export declare function renderNode(app: App, options: RenderNodeOptions): void;
|
|
13
|
-
export declare function render(app: App, time?: number): void;
|
package/types/setup.d.ts
DELETED
package/types/shape.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { App } from './app';
|
|
2
|
-
export interface UserShape {
|
|
3
|
-
type?: '2d' | '3d';
|
|
4
|
-
mode?: keyof App['drawModes'];
|
|
5
|
-
buffer?: Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array | Int8Array | Int16Array | Int32Array | BigUint64Array | BigInt64Array | Float32Array | Float64Array;
|
|
6
|
-
}
|
|
7
|
-
export interface Shape {
|
|
8
|
-
mode: GLenum;
|
|
9
|
-
count: number;
|
|
10
|
-
buffer: WebGLBuffer | null;
|
|
11
|
-
}
|
|
12
|
-
export declare function registerShape(app: App, name: string, userShape: UserShape): void;
|
package/types/system.d.ts
DELETED
package/types/texture.d.ts
DELETED
package/types/utils.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare class Matrix3 extends Float32Array {
|
|
2
|
-
static identity(): Matrix3;
|
|
3
|
-
static translation(tx: number, ty: number): Matrix3;
|
|
4
|
-
static rotation(radians: number): Matrix3;
|
|
5
|
-
static scaling(sx: number, sy: number): Matrix3;
|
|
6
|
-
multiply(matrix3: Matrix3): this;
|
|
7
|
-
}
|
|
8
|
-
export declare function getArchetypeIdCodePoints(componentIds: number[]): number[];
|
|
9
|
-
export declare function createVideo(url: string): HTMLVideoElement;
|
|
10
|
-
export declare function createImage(url: string): HTMLImageElement;
|
|
11
|
-
export declare function resolveColor(value: string, defaultValue?: number[]): [number, number, number, number];
|