@inkweave/core 1.0.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/dist/create.d.ts +4 -0
- package/dist/extensions/ChoiceParser.d.ts +10 -0
- package/dist/extensions/ExternalFunctions.d.ts +10 -0
- package/dist/extensions/Parser.d.ts +20 -0
- package/dist/extensions/Patches.d.ts +11 -0
- package/dist/extensions/Tags.d.ts +18 -0
- package/dist/index.cjs +45 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +8628 -0
- package/dist/index.js.map +1 -0
- package/dist/state/choices.d.ts +18 -0
- package/dist/state/contents.d.ts +18 -0
- package/dist/state/createSelectors.d.ts +10 -0
- package/dist/state/variables.d.ts +15 -0
- package/dist/story/InkStory.d.ts +31 -0
- package/dist/types.d.ts +41 -0
- package/package.json +44 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Choice } from '../types';
|
|
2
|
+
import { Choice as InkChoice } from 'inkjs/engine/Choice';
|
|
3
|
+
type StoryChoices = {
|
|
4
|
+
choices: Choice[];
|
|
5
|
+
setChoices: (choices: InkChoice[]) => void;
|
|
6
|
+
clear: () => void;
|
|
7
|
+
};
|
|
8
|
+
declare const _default: {
|
|
9
|
+
(): StoryChoices;
|
|
10
|
+
<U>(selector: (state: StoryChoices) => U): U;
|
|
11
|
+
} & import('zustand').StoreApi<StoryChoices> & {
|
|
12
|
+
use: {
|
|
13
|
+
choices: () => Choice[];
|
|
14
|
+
setChoices: () => (choices: InkChoice[]) => void;
|
|
15
|
+
clear: () => () => void;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type StoryContent = {
|
|
2
|
+
contents: string[];
|
|
3
|
+
setContents: (contents: string[]) => void;
|
|
4
|
+
add: (content: string[]) => void;
|
|
5
|
+
clear: () => void;
|
|
6
|
+
};
|
|
7
|
+
declare const _default: {
|
|
8
|
+
(): StoryContent;
|
|
9
|
+
<U>(selector: (state: StoryContent) => U): U;
|
|
10
|
+
} & import('zustand').StoreApi<StoryContent> & {
|
|
11
|
+
use: {
|
|
12
|
+
contents: () => string[];
|
|
13
|
+
setContents: () => (contents: string[]) => void;
|
|
14
|
+
add: () => (content: string[]) => void;
|
|
15
|
+
clear: () => () => void;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { StoreApi, UseBoundStore } from 'zustand';
|
|
2
|
+
type WithSelectors<S> = S extends {
|
|
3
|
+
getState: () => infer T;
|
|
4
|
+
} ? S & {
|
|
5
|
+
use: {
|
|
6
|
+
[K in keyof T]: () => T[K];
|
|
7
|
+
};
|
|
8
|
+
} : never;
|
|
9
|
+
declare const createSelectors: <S extends UseBoundStore<StoreApi<object>>>(_store: S) => WithSelectors<S>;
|
|
10
|
+
export default createSelectors;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { VariablesState } from 'inkjs/engine/VariablesState';
|
|
2
|
+
type StoryVariables = {
|
|
3
|
+
variables: Map<string, unknown>;
|
|
4
|
+
setGlobalVars: (variablesState: VariablesState) => void;
|
|
5
|
+
};
|
|
6
|
+
declare const _default: {
|
|
7
|
+
(): StoryVariables;
|
|
8
|
+
<U>(selector: (state: StoryVariables) => U): U;
|
|
9
|
+
} & import('zustand').StoreApi<StoryVariables> & {
|
|
10
|
+
use: {
|
|
11
|
+
variables: () => Map<string, unknown>;
|
|
12
|
+
setGlobalVars: () => (variablesState: VariablesState) => void;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Story } from 'inkjs/engine/Story';
|
|
2
|
+
import { InkStoryOptions, InkStoryContext } from '../types';
|
|
3
|
+
type CleanupFunction = () => void;
|
|
4
|
+
type SideEffectFunction = () => void;
|
|
5
|
+
type ClearFunction = () => void;
|
|
6
|
+
export declare class InkStory implements InkStoryContext {
|
|
7
|
+
title: string;
|
|
8
|
+
story: Story;
|
|
9
|
+
options: InkStoryOptions;
|
|
10
|
+
_side_effects: SideEffectFunction[];
|
|
11
|
+
_cleanups: CleanupFunction[];
|
|
12
|
+
_clears: ClearFunction[];
|
|
13
|
+
_save_label: string[];
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
constructor(story: Story, title: string, options?: InkStoryOptions);
|
|
16
|
+
get contents(): string[];
|
|
17
|
+
set contents(newContent: string[]);
|
|
18
|
+
get choices(): import('..').Choice[];
|
|
19
|
+
get clears(): ClearFunction[];
|
|
20
|
+
get cleanups(): CleanupFunction[];
|
|
21
|
+
get effects(): SideEffectFunction[];
|
|
22
|
+
get save_label(): string[];
|
|
23
|
+
continue(): void;
|
|
24
|
+
choose(index: number): void;
|
|
25
|
+
clear(): void;
|
|
26
|
+
restart(): void;
|
|
27
|
+
useEffect(): void;
|
|
28
|
+
dispose(): void;
|
|
29
|
+
bindExternalFunctions: (content: string) => void;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export declare const CHOICE_SEPARATOR = "\0ink-divider\0";
|
|
2
|
+
export declare const DEFAULT_STORY_OPTIONS: InkStoryOptions;
|
|
3
|
+
export interface FileHandler {
|
|
4
|
+
loadFile(filename: string): string;
|
|
5
|
+
}
|
|
6
|
+
export declare class BaseFileHandler implements FileHandler {
|
|
7
|
+
protected basePath: string;
|
|
8
|
+
constructor(options?: {
|
|
9
|
+
basePath?: string;
|
|
10
|
+
});
|
|
11
|
+
resolveFilename(filename: string): string;
|
|
12
|
+
loadFile(_filename: string): string;
|
|
13
|
+
}
|
|
14
|
+
export interface InkStoryOptions {
|
|
15
|
+
title?: string;
|
|
16
|
+
debug?: boolean;
|
|
17
|
+
linedelay?: number;
|
|
18
|
+
fileHandler?: FileHandler;
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
}
|
|
21
|
+
export interface InkStoryContext {
|
|
22
|
+
options: InkStoryOptions;
|
|
23
|
+
save_label: string[];
|
|
24
|
+
clears: Array<() => void>;
|
|
25
|
+
cleanups: Array<() => void>;
|
|
26
|
+
_side_effects: Array<() => void>;
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
}
|
|
29
|
+
export interface SaveData {
|
|
30
|
+
state: string;
|
|
31
|
+
contents?: string[];
|
|
32
|
+
image?: string;
|
|
33
|
+
[key: string]: unknown;
|
|
34
|
+
}
|
|
35
|
+
export declare class Choice {
|
|
36
|
+
text: string;
|
|
37
|
+
index: number;
|
|
38
|
+
type: string;
|
|
39
|
+
val?: string;
|
|
40
|
+
constructor(text: string, index: number, type?: string);
|
|
41
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@inkweave/core",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Core engine for InkWeave - ink story runtime with extension system",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc --noEmit && vite build",
|
|
21
|
+
"typecheck": "tsc --noEmit",
|
|
22
|
+
"test": "bun test",
|
|
23
|
+
"test:watch": "bun test --watch"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"ink",
|
|
27
|
+
"interactive-fiction",
|
|
28
|
+
"game-engine",
|
|
29
|
+
"inkweave"
|
|
30
|
+
],
|
|
31
|
+
"author": "Uglyboy",
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"inkjs": "^2.3.0",
|
|
35
|
+
"zustand": "^5.0.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"inkjs": "^2.3.1",
|
|
39
|
+
"zustand": "^5.0.3",
|
|
40
|
+
"typescript": "^5.0.0",
|
|
41
|
+
"vite": "^6.0.0",
|
|
42
|
+
"vite-plugin-dts": "^4.5.4"
|
|
43
|
+
}
|
|
44
|
+
}
|