-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #442 from videlais/440-consider-typescript-types
TypeScript types
- Loading branch information
Showing
18 changed files
with
1,247 additions
and
11,282 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
// Change this to match your project | ||
"include": ["src/**/*"], | ||
"compilerOptions": { | ||
// Tells TypeScript to read JS files, as | ||
// normally they are ignored as source files | ||
"allowJs": true, | ||
// Generate d.ts files | ||
"declaration": true, | ||
// This compiler run should | ||
// only output d.ts files | ||
"emitDeclarationOnly": true, | ||
// Types should go into this directory. | ||
// Removing this would place the .d.ts files | ||
// next to the .js files | ||
"outDir": "types", | ||
// go to js file when using IDE functions like | ||
// "Go to Definition" in VSCode | ||
"declarationMap": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { parse as parseTwee } from './src/Twee/parse.js'; | ||
import { parse as parseJSON } from './src/JSON/parse.js'; | ||
import { parse as parseTWS } from './src/TWS/parse.js'; | ||
import { parse as parseStoryFormat } from './src/StoryFormat/parse.js'; | ||
import { parse as parseTwine1HTML } from './src/Twine1HTML/parse.js'; | ||
import { parse as parseTwine2HTML } from './src/Twine2HTML/parse.js'; | ||
import { parse as parseTwine2ArchiveHTML } from './src/Twine2ArchiveHTML/parse.js'; | ||
import { compile as compileTwine1HTML } from './src/Twine1HTML/compile.js'; | ||
import { compile as compileTwine2HTML } from './src/Twine2HTML/compile.js'; | ||
import { compile as compileTwine2ArchiveHTML } from './src/Twine2ArchiveHTML/compile.js'; | ||
import Story from './src/Story.js'; | ||
import Passage from './src/Passage.js'; | ||
import StoryFormat from './src/StoryFormat.js'; | ||
export { parseTwee, parseJSON, parseTWS, parseStoryFormat, parseTwine1HTML, parseTwine2HTML, parseTwine2ArchiveHTML, compileTwine1HTML, compileTwine2HTML, compileTwine2ArchiveHTML, Story, Passage, StoryFormat }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* Parse JSON representation into Story. | ||
* @function parse | ||
* @param {string} jsonString - JSON string to convert to Story. | ||
* @returns {Story} Story object. | ||
*/ | ||
export function parse(jsonString: string): Story; | ||
import Story from '../Story.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** | ||
* A passage is the smallest unit of a Twine story. | ||
*/ | ||
export default class Passage { | ||
/** | ||
* Create a passage. | ||
* @param {string} name - Name | ||
* @param {string} text - Content | ||
* @param {Array} tags - Tags | ||
* @param {object} metadata - Metadata | ||
*/ | ||
constructor(name?: string, text?: string, tags?: any[], metadata?: object); | ||
/** | ||
* @param {string} s - Name to replace | ||
*/ | ||
set name(s: string); | ||
/** | ||
* Name | ||
* @returns {string} Name | ||
*/ | ||
get name(): string; | ||
/** | ||
* @param {Array} t - Replacement array | ||
*/ | ||
set tags(t: any[]); | ||
/** | ||
* Tags | ||
* @returns {Array} Tags | ||
*/ | ||
get tags(): any[]; | ||
/** | ||
* @param {object} m - Replacement object | ||
*/ | ||
set metadata(m: any); | ||
/** | ||
* Metadata | ||
* @returns {object} Metadata | ||
*/ | ||
get metadata(): any; | ||
/** | ||
* @param {string} t - Replacement text | ||
*/ | ||
set text(t: string); | ||
/** | ||
* Text | ||
* @returns {string} Text | ||
*/ | ||
get text(): string; | ||
/** | ||
* Return a Twee representation. | ||
* @returns {string} String form of passage. | ||
*/ | ||
toTwee(): string; | ||
/** | ||
* Return JSON representation. | ||
* @returns {string} JSON string. | ||
*/ | ||
toJSON(): string; | ||
/** | ||
* Return Twine 2 HTML representation. | ||
* (Default Passage ID is 1.) | ||
* @param {number} pid - Passage ID (PID) to record in HTML. | ||
* @returns {string} Twine 2 HTML string. | ||
*/ | ||
toTwine2HTML(pid?: number): string; | ||
/** | ||
* Return Twine 1 HTML representation. | ||
* @returns {string} Twine 1 HTML string. | ||
*/ | ||
toTwine1HTML(): string; | ||
#private; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
export default class Story { | ||
/** | ||
* Creates a story. | ||
* @param {string} name - Name of the story. | ||
*/ | ||
constructor(name?: string); | ||
/** | ||
* @param {string} a - Replacement story name | ||
*/ | ||
set name(a: string); | ||
/** | ||
* Each story has a name | ||
* @returns {string} Name | ||
*/ | ||
get name(): string; | ||
/** | ||
* @param {object} a - Replacement tag colors | ||
*/ | ||
set tagColors(a: any); | ||
/** | ||
* Tag Colors object (each property is a tag and its color) | ||
* @returns {object} tag colors array | ||
*/ | ||
get tagColors(): any; | ||
/** | ||
* @param {string} i - Replacement IFID | ||
*/ | ||
set IFID(i: string); | ||
/** | ||
* Interactive Fiction ID (IFID) of Story | ||
* @returns {string} IFID | ||
*/ | ||
get IFID(): string; | ||
/** | ||
* @param {string} s - Replacement start | ||
*/ | ||
set start(s: string); | ||
/** | ||
* Name of start passage. | ||
* @returns {string} start | ||
*/ | ||
get start(): string; | ||
/** | ||
* @param {string} f - Replacement format version | ||
*/ | ||
set formatVersion(f: string); | ||
/** | ||
* Story format version of Story. | ||
* @returns {string} story format version | ||
*/ | ||
get formatVersion(): string; | ||
/** | ||
* @param {object} o - Replacement metadata | ||
*/ | ||
set metadata(o: any); | ||
/** | ||
* Metadata of Story. | ||
* @returns {object} metadata of story | ||
*/ | ||
get metadata(): any; | ||
/** | ||
* @param {string} f - Replacement format | ||
*/ | ||
set format(f: string); | ||
/** | ||
* Story format of Story. | ||
* @returns {string} format | ||
*/ | ||
get format(): string; | ||
/** | ||
* @param {string} c - Creator Program of Story | ||
*/ | ||
set creator(c: string); | ||
/** | ||
* Program used to create Story. | ||
* @returns {string} Creator Program | ||
*/ | ||
get creator(): string; | ||
/** | ||
* @param {string} c - Version of creator program | ||
*/ | ||
set creatorVersion(c: string); | ||
/** | ||
* Version used to create Story. | ||
* @returns {string} Version | ||
*/ | ||
get creatorVersion(): string; | ||
/** | ||
* @param {number} n - Replacement zoom level | ||
*/ | ||
set zoom(n: number); | ||
/** | ||
* Zoom level. | ||
* @returns {number} Zoom level | ||
*/ | ||
get zoom(): number; | ||
/** | ||
* Add a passage to the story. | ||
* `StoryData` will override story metadata and `StoryTitle` will override story name. | ||
* @param {Passage} p - Passage to add to Story. | ||
*/ | ||
addPassage(p: Passage): void; | ||
/** | ||
* Remove a passage from the story by name. | ||
* @param {string} name - Passage name to remove | ||
*/ | ||
removePassageByName(name: string): void; | ||
/** | ||
* Find passages by tag. | ||
* @param {string} t - Passage name to search for | ||
* @returns {Array} Return array of passages | ||
*/ | ||
getPassagesByTag(t: string): any[]; | ||
/** | ||
* Find passage by name. | ||
* @param {string} name - Passage name to search for | ||
* @returns {Passage | null} Return passage or null | ||
*/ | ||
getPassageByName(name: string): Passage | null; | ||
/** | ||
* Size (number of passages). | ||
* @returns {number} Return number of passages | ||
*/ | ||
size(): number; | ||
/** | ||
* forEach-style iterator of passages in Story. | ||
* @param {Function} callback - Callback function | ||
*/ | ||
forEachPassage(callback: Function): void; | ||
/** | ||
* Export Story as JSON representation. | ||
* @returns {string} JSON string. | ||
*/ | ||
toJSON(): string; | ||
/** | ||
* Return Twee representation. | ||
* | ||
* See: Twee 3 Specification | ||
* (https://github.com/iftechfoundation/twine-specs/blob/master/twee-3-specification.md) | ||
* @returns {string} Twee String | ||
*/ | ||
toTwee(): string; | ||
/** | ||
* Return Twine 2 HTML. | ||
* | ||
* See: Twine 2 HTML Output | ||
* (https://github.com/iftechfoundation/twine-specs/blob/master/twine-2-htmloutput-spec.md) | ||
* @returns {string} Twine 2 HTML string | ||
*/ | ||
toTwine2HTML(): string; | ||
/** | ||
* Return Twine 1 HTML. | ||
* | ||
* See: Twine 1 HTML Output | ||
* (https://github.com/iftechfoundation/twine-specs/blob/master/twine-1-htmloutput-doc.md) | ||
* @returns {string} Twine 1 HTML string. | ||
*/ | ||
toTwine1HTML(): string; | ||
#private; | ||
} | ||
import Passage from './Passage.js'; |
Oops, something went wrong.