@sharpee/plugins 0.9.61-beta
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/dist-npm/index.d.ts +4 -0
- package/dist-npm/index.d.ts.map +1 -0
- package/dist-npm/index.js +6 -0
- package/dist-npm/index.js.map +1 -0
- package/dist-npm/plugin-registry.d.ts +11 -0
- package/dist-npm/plugin-registry.d.ts.map +1 -0
- package/dist-npm/plugin-registry.js +40 -0
- package/dist-npm/plugin-registry.js.map +1 -0
- package/dist-npm/turn-plugin-context.d.ts +18 -0
- package/dist-npm/turn-plugin-context.d.ts.map +1 -0
- package/dist-npm/turn-plugin-context.js +3 -0
- package/dist-npm/turn-plugin-context.js.map +1 -0
- package/dist-npm/turn-plugin.d.ts +10 -0
- package/dist-npm/turn-plugin.d.ts.map +1 -0
- package/dist-npm/turn-plugin.js +3 -0
- package/dist-npm/turn-plugin.js.map +1 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 David Cornelson
|
|
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.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PluginRegistry = void 0;
|
|
4
|
+
var plugin_registry_1 = require("./plugin-registry");
|
|
5
|
+
Object.defineProperty(exports, "PluginRegistry", { enumerable: true, get: function () { return plugin_registry_1.PluginRegistry; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAEA,qDAAmD;AAA1C,iHAAA,cAAc,OAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TurnPlugin } from './turn-plugin';
|
|
2
|
+
export declare class PluginRegistry {
|
|
3
|
+
private plugins;
|
|
4
|
+
register(plugin: TurnPlugin): void;
|
|
5
|
+
unregister(id: string): void;
|
|
6
|
+
getAll(): TurnPlugin[];
|
|
7
|
+
getById(id: string): TurnPlugin | undefined;
|
|
8
|
+
getStates(): Record<string, unknown>;
|
|
9
|
+
setStates(states: Record<string, unknown>): void;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=plugin-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-registry.d.ts","sourceRoot":"","sources":["../src/plugin-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAAsC;IAErD,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAOlC,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAI5B,MAAM,IAAI,UAAU,EAAE;IAMtB,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAI3C,SAAS,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAUpC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;CAQjD"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PluginRegistry = void 0;
|
|
4
|
+
class PluginRegistry {
|
|
5
|
+
plugins = new Map();
|
|
6
|
+
register(plugin) {
|
|
7
|
+
if (this.plugins.has(plugin.id)) {
|
|
8
|
+
throw new Error(`Plugin already registered: ${plugin.id}`);
|
|
9
|
+
}
|
|
10
|
+
this.plugins.set(plugin.id, plugin);
|
|
11
|
+
}
|
|
12
|
+
unregister(id) {
|
|
13
|
+
this.plugins.delete(id);
|
|
14
|
+
}
|
|
15
|
+
getAll() {
|
|
16
|
+
return Array.from(this.plugins.values()).sort((a, b) => b.priority - a.priority);
|
|
17
|
+
}
|
|
18
|
+
getById(id) {
|
|
19
|
+
return this.plugins.get(id);
|
|
20
|
+
}
|
|
21
|
+
getStates() {
|
|
22
|
+
const states = {};
|
|
23
|
+
for (const plugin of this.plugins.values()) {
|
|
24
|
+
if (plugin.getState) {
|
|
25
|
+
states[plugin.id] = plugin.getState();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return states;
|
|
29
|
+
}
|
|
30
|
+
setStates(states) {
|
|
31
|
+
for (const [id, state] of Object.entries(states)) {
|
|
32
|
+
const plugin = this.plugins.get(id);
|
|
33
|
+
if (plugin?.setState) {
|
|
34
|
+
plugin.setState(state);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.PluginRegistry = PluginRegistry;
|
|
40
|
+
//# sourceMappingURL=plugin-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-registry.js","sourceRoot":"","sources":["../src/plugin-registry.ts"],"names":[],"mappings":";;;AAEA,MAAa,cAAc;IACjB,OAAO,GAA4B,IAAI,GAAG,EAAE,CAAC;IAErD,QAAQ,CAAC,MAAkB;QACzB,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,8BAA8B,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC;QAC7D,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC;IAED,UAAU,CAAC,EAAU;QACnB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC1B,CAAC;IAED,MAAM;QACJ,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAC3C,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAClC,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,EAAU;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;IAED,SAAS;QACP,MAAM,MAAM,GAA4B,EAAE,CAAC;QAC3C,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;YAC3C,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;gBACpB,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;YACxC,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,SAAS,CAAC,MAA+B;QACvC,KAAK,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YACjD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACpC,IAAI,MAAM,EAAE,QAAQ,EAAE,CAAC;gBACrB,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YACzB,CAAC;QACH,CAAC;IACH,CAAC;CACF;AA1CD,wCA0CC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { EntityId, SeededRandom, ISemanticEvent } from '@sharpee/core';
|
|
2
|
+
import { WorldModel } from '@sharpee/world-model';
|
|
3
|
+
export interface TurnPluginActionResult {
|
|
4
|
+
actionId: string;
|
|
5
|
+
success: boolean;
|
|
6
|
+
targetId?: EntityId;
|
|
7
|
+
sharedData?: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
export interface TurnPluginContext {
|
|
10
|
+
world: WorldModel;
|
|
11
|
+
turn: number;
|
|
12
|
+
playerId: EntityId;
|
|
13
|
+
playerLocation: EntityId;
|
|
14
|
+
random: SeededRandom;
|
|
15
|
+
actionResult?: TurnPluginActionResult;
|
|
16
|
+
actionEvents?: ISemanticEvent[];
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=turn-plugin-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turn-plugin-context.d.ts","sourceRoot":"","sources":["../src/turn-plugin-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,UAAU,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,QAAQ,CAAC;IACnB,cAAc,EAAE,QAAQ,CAAC;IACzB,MAAM,EAAE,YAAY,CAAC;IACrB,YAAY,CAAC,EAAE,sBAAsB,CAAC;IACtC,YAAY,CAAC,EAAE,cAAc,EAAE,CAAC;CACjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turn-plugin-context.js","sourceRoot":"","sources":["../src/turn-plugin-context.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ISemanticEvent } from '@sharpee/core';
|
|
2
|
+
import { TurnPluginContext } from './turn-plugin-context';
|
|
3
|
+
export interface TurnPlugin {
|
|
4
|
+
id: string;
|
|
5
|
+
priority: number;
|
|
6
|
+
onAfterAction(context: TurnPluginContext): ISemanticEvent[];
|
|
7
|
+
getState?(): unknown;
|
|
8
|
+
setState?(state: unknown): void;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=turn-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turn-plugin.d.ts","sourceRoot":"","sources":["../src/turn-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,OAAO,EAAE,iBAAiB,GAAG,cAAc,EAAE,CAAC;IAC5D,QAAQ,CAAC,IAAI,OAAO,CAAC;IACrB,QAAQ,CAAC,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;CACjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turn-plugin.js","sourceRoot":"","sources":["../src/turn-plugin.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sharpee/plugins",
|
|
3
|
+
"version": "0.9.61-beta",
|
|
4
|
+
"description": "Plugin contracts for Sharpee engine turn-cycle extensibility",
|
|
5
|
+
"main": "dist-npm/index.js",
|
|
6
|
+
"module": "dist-npm/index.js",
|
|
7
|
+
"types": "dist-npm/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist-npm/index.d.ts",
|
|
11
|
+
"import": "./dist-npm/index.js",
|
|
12
|
+
"require": "./dist-npm/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@sharpee/core": "0.9.61-beta",
|
|
17
|
+
"@sharpee/world-model": "0.9.61-beta"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@types/node": "^20.11.19",
|
|
21
|
+
"typescript": "^5.3.3",
|
|
22
|
+
"rimraf": "^5.0.5"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist-npm"
|
|
26
|
+
],
|
|
27
|
+
"keywords": [
|
|
28
|
+
"interactive-fiction",
|
|
29
|
+
"sharpee",
|
|
30
|
+
"plugins",
|
|
31
|
+
"turn-cycle"
|
|
32
|
+
],
|
|
33
|
+
"author": "Sharpee Team",
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "https://github.com/ChicagoDave/sharpee.git",
|
|
38
|
+
"directory": "packages/plugins"
|
|
39
|
+
},
|
|
40
|
+
"homepage": "https://github.com/ChicagoDave/sharpee#readme",
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "https://github.com/ChicagoDave/sharpee/issues"
|
|
43
|
+
},
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=18.0.0"
|
|
46
|
+
},
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"build": "tsc",
|
|
52
|
+
"clean": "rimraf dist",
|
|
53
|
+
"build:npm": "tsc --outDir dist-npm"
|
|
54
|
+
}
|
|
55
|
+
}
|