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/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "modern-canvas",
3
3
  "type": "module",
4
- "version": "0.0.3",
5
- "packageManager": "pnpm@7.26.2",
6
- "description": "A data driven modern canvas library",
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": "./types/index.d.ts",
27
- "require": "./dist/index.cjs",
28
- "import": "./dist/index.mjs"
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": "types/index.d.ts",
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
- "./types/*",
39
- "./types/index.d.ts"
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
- "@qq15725/eslint-config": "^1.1.0",
58
- "@types/node": "^18.14.0",
59
- "@vitejs/plugin-vue": "^4.1.0",
60
- "bumpp": "^8.2.1",
61
- "conventional-changelog-cli": "^2.2.2",
62
- "eslint": "^8.34.0",
63
- "typescript": "^4.9.5",
64
- "vite": "^4.1.2",
65
- "vitest": "^0.28.5",
66
- "vue": "^3.2.47"
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
- }
@@ -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;
@@ -1,3 +0,0 @@
1
- import type { Options } from './options';
2
- import type { App } from './app';
3
- export declare function createApp(options?: Options): App;
package/types/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from './plugins';
2
- export * from './app';
3
- export * from './create-app';
4
- export type { Node } from './node';
@@ -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
@@ -1,4 +0,0 @@
1
- export interface Node {
2
- [key: string]: any;
3
- children?: Node[];
4
- }
@@ -1,7 +0,0 @@
1
- import type { Node } from './node';
2
- import type { Plugin } from './plugin';
3
- export interface Options extends WebGLContextAttributes {
4
- view?: HTMLCanvasElement;
5
- children?: Node[];
6
- plugins?: Plugin[];
7
- }
package/types/plugin.d.ts DELETED
@@ -1,6 +0,0 @@
1
- import type { App } from './app';
2
- export interface Plugin {
3
- name: string;
4
- register?(app: App): void;
5
- }
6
- export declare function definePlugin(plugin: Plugin | (() => Plugin)): Plugin;
@@ -1 +0,0 @@
1
- export * from './renderer2d';
@@ -1 +0,0 @@
1
- export declare const Renderer2d: import("../plugin").Plugin;
package/types/query.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import type { App } from './app';
2
- import type { Node } from './node';
3
- export type QueryOptions = string | string[];
4
- export declare function query(app: App, options?: QueryOptions): Node[];
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
@@ -1,2 +0,0 @@
1
- import type { App } from './app';
2
- export declare function setup(app: App): void;
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
@@ -1,5 +0,0 @@
1
- import type { App } from './app';
2
- export interface System {
3
- update?(time?: number): void;
4
- }
5
- export declare function registerSystem(app: App, system: System): void;
@@ -1,7 +0,0 @@
1
- import type { App } from './app';
2
- export interface Texture {
3
- loading: boolean;
4
- value: WebGLTexture | null;
5
- source: TexImageSource;
6
- }
7
- export declare function registerTexture(app: App, name: number, source: TexImageSource): Promise<void>;
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];