@aethervtt/shard-project 0.0.1
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/LICENSE +21 -0
- package/README.md +3 -0
- package/dist/define.d.ts +55 -0
- package/dist/define.js +56 -0
- package/dist/docs.d.ts +26 -0
- package/dist/docs.js +1336 -0
- package/dist/host.d.ts +47 -0
- package/dist/host.js +118 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +61 -0
- package/dist/manifest.d.ts +49 -0
- package/dist/manifest.js +147 -0
- package/dist/reload.d.ts +53 -0
- package/dist/reload.js +247 -0
- package/dist/session.d.ts +73 -0
- package/dist/session.js +144 -0
- package/dist/sourcemap.d.ts +31 -0
- package/dist/sourcemap.js +91 -0
- package/dist/templates.d.ts +9 -0
- package/dist/templates.js +283 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Patrick Dias
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/dist/define.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type DataType, type DataTypeOptions } from '@aethervtt/shard-assets';
|
|
2
|
+
import { type ComponentDef, type ComponentOptions, type EventDef, type Fields, type ResourceDef, type ResourceOptions, type TagDef } from '@aethervtt/shard-core';
|
|
3
|
+
import { type Generator, type GeneratorOptions, type OutputSpec } from '@aethervtt/shard-procgen';
|
|
4
|
+
import { type MaterialType, type MaterialTypeOptions } from '@aethervtt/shard-render';
|
|
5
|
+
import type { App, Plugin } from '@aethervtt/shard-runtime';
|
|
6
|
+
import { type SettingsDef } from '@aethervtt/shard-save';
|
|
7
|
+
export interface ProjectOptions {
|
|
8
|
+
/** Must match `shard.json`'s name. Becomes the namespace of every project type. */
|
|
9
|
+
name: string;
|
|
10
|
+
build?(app: App): void;
|
|
11
|
+
ready?(app: App): Promise<void> | void;
|
|
12
|
+
}
|
|
13
|
+
export interface ProjectDef extends Plugin {
|
|
14
|
+
readonly namespace: string;
|
|
15
|
+
/** Defines `<project>/<name>`. A name in another namespace throws `project/namespace`. */
|
|
16
|
+
component<const F extends Fields>(name: string, fields: F, options?: ComponentOptions): ComponentDef<F>;
|
|
17
|
+
tag(name: string, options?: {
|
|
18
|
+
description?: string;
|
|
19
|
+
}): TagDef;
|
|
20
|
+
resource<T>(name: string, options?: ResourceOptions<T>): ResourceDef<T>;
|
|
21
|
+
event<T = undefined>(name: string, options?: {
|
|
22
|
+
description?: string;
|
|
23
|
+
}): EventDef<T>;
|
|
24
|
+
/**
|
|
25
|
+
* Defines the project's settings, `<project>/Settings`: a resource persisted per player in
|
|
26
|
+
* `settings.json` (defaults from `settings/*.json`), loaded before Startup. Read it like any
|
|
27
|
+
* resource; `setSettings` changes it and applies at once.
|
|
28
|
+
*/
|
|
29
|
+
settings<const F extends Fields>(fields: F, options?: Pick<ComponentOptions, 'description' | 'version' | 'migrate'> & {
|
|
30
|
+
name?: string;
|
|
31
|
+
}): SettingsDef<F>;
|
|
32
|
+
/**
|
|
33
|
+
* Defines the material type `<project>/<name>`: fields (numbers, colors, texture handles) and a
|
|
34
|
+
* shader in `shaders/` (`project::<file>`) that overrides hooks. Assets name it in `"type"`.
|
|
35
|
+
*/
|
|
36
|
+
material<const F extends Fields>(name: string, options: MaterialTypeOptions<F>): MaterialType;
|
|
37
|
+
/**
|
|
38
|
+
* Defines the data asset type `<project>/<name>`: `*.<extension>.json` files under the asset
|
|
39
|
+
* roots are validated by `fields`, can `$extends` each other, and load into `store`. Components
|
|
40
|
+
* reference them with `t.handle('<project>/<name>')`.
|
|
41
|
+
*/
|
|
42
|
+
dataAsset<const F extends Fields, const N extends string>(name: N, fields: F, options: DataTypeOptions): DataType<F, N extends `${string}/${string}` ? N : `${string}/${N}`>;
|
|
43
|
+
/**
|
|
44
|
+
* Defines the generator `<project>/<name>`: `(seed, params) → output` (a mesh, texture, data
|
|
45
|
+
* value, or entities), cached by the hash of its inputs and run on the worker pool. Place its
|
|
46
|
+
* output with a `generators/*.gen.json` file, a `procedural:<project>/<name>?…` ref, a
|
|
47
|
+
* `procgen/GeneratorInstance`, or `generate(world, gen, params, seed)`.
|
|
48
|
+
*/
|
|
49
|
+
generator<const P extends Fields, const O extends OutputSpec>(name: string, options: GeneratorOptions<P, O>): Generator<P, O>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The project plugin: the game's own code, exported as the default of `scripts/main.ts`. Project
|
|
53
|
+
* types are namespaced by the project name, so they never collide with engine types.
|
|
54
|
+
*/
|
|
55
|
+
export declare function defineProject(options: ProjectOptions): ProjectDef;
|
package/dist/define.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { defineDataType } from "@aethervtt/shard-assets";
|
|
2
|
+
import {
|
|
3
|
+
defineComponent,
|
|
4
|
+
defineEvent,
|
|
5
|
+
defineResource,
|
|
6
|
+
defineTag,
|
|
7
|
+
ShardError
|
|
8
|
+
} from "@aethervtt/shard-core";
|
|
9
|
+
import {
|
|
10
|
+
defineGenerator
|
|
11
|
+
} from "@aethervtt/shard-procgen";
|
|
12
|
+
import {
|
|
13
|
+
defineMaterial
|
|
14
|
+
} from "@aethervtt/shard-render";
|
|
15
|
+
import { defineSettings } from "@aethervtt/shard-save";
|
|
16
|
+
function defineProject(options) {
|
|
17
|
+
const ns = options.name;
|
|
18
|
+
const qualify = (name) => {
|
|
19
|
+
const slash = name.indexOf("/");
|
|
20
|
+
if (slash === -1) return `${ns}/${name}`;
|
|
21
|
+
if (name.slice(0, slash) !== ns) {
|
|
22
|
+
throw new ShardError(
|
|
23
|
+
"project/namespace",
|
|
24
|
+
`"${name}" is outside the project namespace "${ns}"`,
|
|
25
|
+
{
|
|
26
|
+
hint: `Project types are named "${ns}/<Name>"; pass just "<Name>".`
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
return name;
|
|
31
|
+
};
|
|
32
|
+
return {
|
|
33
|
+
name: `project:${ns}`,
|
|
34
|
+
namespace: ns,
|
|
35
|
+
dependencies: ["core/time"],
|
|
36
|
+
build: (app) => options.build?.(app),
|
|
37
|
+
ready: (app) => options.ready?.(app),
|
|
38
|
+
component: (name, fields, componentOptions) => defineComponent(qualify(name), fields, componentOptions),
|
|
39
|
+
tag: (name, tagOptions) => defineTag(qualify(name), tagOptions),
|
|
40
|
+
resource: (name, resourceOptions) => defineResource(qualify(name), resourceOptions),
|
|
41
|
+
event: (name, eventOptions) => defineEvent(qualify(name), eventOptions),
|
|
42
|
+
settings: (fields, settingsOptions = {}) => {
|
|
43
|
+
const { name = "Settings", ...rest } = settingsOptions;
|
|
44
|
+
return defineSettings(qualify(name), fields, {
|
|
45
|
+
description: `${ns} settings, persisted per player.`,
|
|
46
|
+
...rest
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
material: (name, materialOptions) => defineMaterial(qualify(name), materialOptions),
|
|
50
|
+
dataAsset: (name, fields, dataOptions) => defineDataType(qualify(name), fields, dataOptions),
|
|
51
|
+
generator: (name, generatorOptions) => defineGenerator(qualify(name), generatorOptions)
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
defineProject
|
|
56
|
+
};
|
package/dist/docs.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type DataType, type ImporterDef } from '@aethervtt/shard-assets';
|
|
2
|
+
import { type ComponentDef } from '@aethervtt/shard-core';
|
|
3
|
+
import { type Generator } from '@aethervtt/shard-procgen';
|
|
4
|
+
import { type ManifestValue } from './manifest.js';
|
|
5
|
+
export declare const GENERATED_START = "<!-- shard:generated -->";
|
|
6
|
+
export declare const GENERATED_END = "<!-- /shard:generated -->";
|
|
7
|
+
export interface ErrorCode {
|
|
8
|
+
code: string;
|
|
9
|
+
hint?: string;
|
|
10
|
+
/** Package or file it comes from. */
|
|
11
|
+
source: string;
|
|
12
|
+
}
|
|
13
|
+
/** A readable catalog of components: the same facts as the JSON Schemas, for agents to skim. */
|
|
14
|
+
export declare function renderComponentCatalog(defs?: readonly ComponentDef[]): string;
|
|
15
|
+
export declare function renderErrorCatalog(codes: readonly ErrorCode[]): string;
|
|
16
|
+
/**
|
|
17
|
+
* Importers: which files they handle, what they produce, and their `.meta` settings. Then the
|
|
18
|
+
* project's own data types: fields, file extension, and schema.
|
|
19
|
+
*/
|
|
20
|
+
export declare function renderAssetCatalog(importers?: readonly ImporterDef[], dataTypes?: readonly DataType[]): string;
|
|
21
|
+
/** Every generator: what it makes, its params with units and ranges, and an example file. */
|
|
22
|
+
export declare function renderGeneratorCatalog(gens?: readonly Generator[]): string;
|
|
23
|
+
/** Replaces the generated block in AGENTS.md, keeping everything outside the markers. */
|
|
24
|
+
export declare function mergeAgentsMd(existing: string | undefined, manifest: ManifestValue): string;
|
|
25
|
+
/** Every generated file except AGENTS.md (see `mergeAgentsMd`), by project-relative path. */
|
|
26
|
+
export declare function generateDocs(manifest: ManifestValue, errors: readonly ErrorCode[]): Record<string, string>;
|