js-game-zero 0.0.0-stage → 0.3.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.
Files changed (53) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +138 -2
  3. package/dist/active-service.d.ts +21 -0
  4. package/dist/actor.d.ts +182 -0
  5. package/dist/animation.d.ts +61 -0
  6. package/dist/assets.d.ts +148 -0
  7. package/dist/audio.d.ts +150 -0
  8. package/dist/browser-asset-backends.d.ts +8 -0
  9. package/dist/browser.d.ts +10 -0
  10. package/dist/chunk-brk0rjcy.js +7846 -0
  11. package/dist/clock.d.ts +29 -0
  12. package/dist/color.d.ts +15 -0
  13. package/dist/events.d.ts +145 -0
  14. package/dist/friendly-names.d.ts +43 -0
  15. package/dist/geometry.d.ts +125 -0
  16. package/dist/helpers.d.ts +28 -0
  17. package/dist/host.d.ts +58 -0
  18. package/dist/host.js +435 -0
  19. package/dist/index.d.ts +340 -0
  20. package/dist/index.js +258 -0
  21. package/dist/input.d.ts +200 -0
  22. package/dist/inspection.d.ts +58 -0
  23. package/dist/jgz.js +8419 -0
  24. package/dist/node.d.ts +14 -0
  25. package/dist/node.js +145 -0
  26. package/dist/pixel-density.d.ts +23 -0
  27. package/dist/random.d.ts +31 -0
  28. package/dist/reference/actor.md +197 -0
  29. package/dist/reference/audio.md +128 -0
  30. package/dist/reference/clock.md +150 -0
  31. package/dist/reference/helpers.md +46 -0
  32. package/dist/reference/hooks.md +379 -0
  33. package/dist/reference/index.d.ts +2 -0
  34. package/dist/reference/index.js +39 -0
  35. package/dist/reference/loaders.md +164 -0
  36. package/dist/reference/rect.md +129 -0
  37. package/dist/reference/runtime.md +478 -0
  38. package/dist/reference/screen.md +313 -0
  39. package/dist/reference/storage.md +90 -0
  40. package/dist/rendering.d.ts +188 -0
  41. package/dist/runtime-contracts.d.ts +117 -0
  42. package/dist/runtime-diagnostics.d.ts +37 -0
  43. package/dist/runtime-persistence.d.ts +32 -0
  44. package/dist/runtime-source.d.ts +82 -0
  45. package/dist/runtime.d.ts +81 -0
  46. package/dist/source-scan.d.ts +49 -0
  47. package/dist/storage-path.d.ts +3 -0
  48. package/dist/storage.d.ts +88 -0
  49. package/dist/tone.d.ts +81 -0
  50. package/dist/touch-controls.d.ts +24 -0
  51. package/dist/touch-pointer.d.ts +11 -0
  52. package/dist/util.d.ts +62 -0
  53. package/package.json +69 -4
package/dist/util.d.ts ADDED
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Internal cross-cutting utilities shared between core modules. This module
3
+ * is intentionally NOT re-exported from `index.ts`, so none of these helpers
4
+ * become part of the public package API. The only geometry dependency is a
5
+ * type-only import, so there is no runtime import cycle.
6
+ */
7
+ import type { Point } from "./geometry.js";
8
+ /** Standard Levenshtein edit distance between two strings. */
9
+ export declare function levenshtein(a: string, b: string): number;
10
+ /**
11
+ * Optimal string alignment distance: Levenshtein where swapping two adjacent
12
+ * characters (`widht` for `width`) costs one edit instead of two.
13
+ */
14
+ export declare function editDistance(a: string, b: string): number;
15
+ /** Case- and underscore-insensitive form, so `filled_circle` meets `filledCircle`. */
16
+ export declare function looseName(name: string): string;
17
+ /**
18
+ * The candidate `name` most plausibly misspells, if any. Capitals and
19
+ * underscores don't count, so another spelling of a name (`filled_circle`,
20
+ * `on_key_down`, `Screen`) is always matched. Short names get one edit of
21
+ * slack and longer ones two (so `drow` and `onKeyDwon` match while `row` and
22
+ * `dow` do not), a transposition counts as one edit, and a name that
23
+ * contains a candidate whole (`redraw`, `updates`) is taken as deliberately
24
+ * derived from it rather than mistyped.
25
+ */
26
+ export declare function closestName(name: string, candidates: Iterable<string>): string | undefined;
27
+ /**
28
+ * A value as an error message should show it: strings quoted, lists as
29
+ * lists, and numbers as written (`NaN`, not JSON's `null`).
30
+ */
31
+ export declare function describeValue(value: unknown): string;
32
+ /** ` Did you mean NAME?` for a likely misspelling, or an empty string. */
33
+ export declare function didYouMean(name: string, candidates: Iterable<string>): string;
34
+ /**
35
+ * Throws a TypeError naming the first key of `options` that `allowed` does
36
+ * not contain, with a suggestion when the key looks like a typo — so a
37
+ * misspelled option fails loudly instead of being silently ignored.
38
+ */
39
+ export declare function rejectUnknownOptions(options: object, allowed: ReadonlySet<string>, label: string): void;
40
+ /** True when `value` is a thenable (a Promise or Promise-like object). */
41
+ export declare function isPromiseLike<T>(value: unknown): value is PromiseLike<T>;
42
+ export declare function clamp(value: number, minimum: number, maximum: number): number;
43
+ export declare function isFiniteNumber(value: unknown): value is number;
44
+ export declare function requireFiniteNumber(value: unknown, label: string): number;
45
+ export declare function isPair(value: unknown): value is readonly [number, number];
46
+ /**
47
+ * Validates that `value` is a `[number, number]` tuple of finite numbers,
48
+ * returning a fresh mutable `Point`. Shared by geometry/actor/assets/
49
+ * rendering, which each used to define an identical private copy.
50
+ */
51
+ export declare function requirePoint(value: unknown, label: string): Point;
52
+ export declare function horizontalAnchorOffset(value: number | "left" | "center" | "middle" | "right", width: number): number;
53
+ export declare function verticalAnchorOffset(value: number | "top" | "center" | "middle" | "bottom", height: number): number;
54
+ /**
55
+ * The compound Rect-anchor position keys (`topLeft`…`center`), shared by the
56
+ * actor, assets, and rendering modules for validating position keywords.
57
+ */
58
+ export declare const rectPositionKeys: readonly ["topLeft", "topRight", "bottomLeft", "bottomRight", "midTop", "midLeft", "midRight", "midBottom", "center"];
59
+ /** Recognized image asset file extensions. */
60
+ export declare const imageExtensions: string[];
61
+ /** Recognized sound asset file extensions. */
62
+ export declare const soundExtensions: string[];
package/package.json CHANGED
@@ -1,6 +1,71 @@
1
1
  {
2
2
  "name": "js-game-zero",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.3.0",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "description": "A beginner-friendly framework for browser games in the spirit of Pygame Zero: set WIDTH and HEIGHT, write draw(), and play. Actors, drawing, input, sound, animation and storage, with a script-tag build.",
7
+ "keywords": [
8
+ "game",
9
+ "gamedev",
10
+ "canvas",
11
+ "education",
12
+ "beginner",
13
+ "pygame-zero"
14
+ ],
15
+ "author": "Taha Rafiq",
16
+ "homepage": "https://github.com/Leaf-Learning/js-game-zero#readme",
17
+ "bugs": {
18
+ "url": "https://github.com/Leaf-Learning/js-game-zero/issues"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/Leaf-Learning/js-game-zero.git",
23
+ "directory": "packages/js-game-zero"
24
+ },
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "main": "./dist/index.js",
29
+ "types": "./dist/index.d.ts",
30
+ "jsdelivr": "./dist/jgz.js",
31
+ "unpkg": "./dist/jgz.js",
32
+ "files": [
33
+ "dist",
34
+ "LICENSE"
35
+ ],
36
+ "sideEffects": [
37
+ "./dist/jgz.js"
38
+ ],
39
+ "exports": {
40
+ ".": {
41
+ "types": "./dist/index.d.ts",
42
+ "import": "./dist/index.js",
43
+ "default": "./dist/index.js"
44
+ },
45
+ "./host": {
46
+ "types": "./dist/host.d.ts",
47
+ "import": "./dist/host.js",
48
+ "default": "./dist/host.js"
49
+ },
50
+ "./node": {
51
+ "types": "./dist/node.d.ts",
52
+ "import": "./dist/node.js",
53
+ "default": "./dist/node.js"
54
+ },
55
+ "./reference": {
56
+ "types": "./dist/reference/index.d.ts",
57
+ "import": "./dist/reference/index.js",
58
+ "default": "./dist/reference/index.js"
59
+ },
60
+ "./reference/*.md": "./dist/reference/*.md",
61
+ "./iife": {
62
+ "types": "./dist/browser.d.ts",
63
+ "default": "./dist/jgz.js"
64
+ },
65
+ "./package.json": "./package.json"
66
+ },
67
+ "scripts": {
68
+ "build": "bun ../../scripts/build.ts js-game-zero",
69
+ "test": "bun test"
70
+ }
71
+ }