Commit 3f995e95 authored by Laurent Wouters's avatar Laurent Wouters
Browse files

Implementing the embedded application

parent 7a2b23b1625a
......@@ -21,9 +21,10 @@
import { RawContent, TabData, fetchLinkedData } from "./api";
/// <reference path="./rdflib-interface.d.ts"/>
let $rdf = require("rdflib");
import { RDF } from "rdflib";
let _rdf = require("rdflib");
export const RDF = $rdf;
export const $rdf: RDF = _rdf;
export function loadRdfStore(tabData: TabData): Promise<any> {
if (!tabData.isActive) {
......
......@@ -22,7 +22,77 @@
* RDF stubs for Typescript
*/
declare module "rdflib" {
export interface Store {}
let $rdf: any;
export interface RdfIriNode {
uri: string;
}
export interface RdfBlankNode {
id: string;
}
export interface RdfLiteralNode {
value: string;
language: string;
datatype: RdfIriNode;
}
export type RdfSubjectNode = RdfIriNode | RdfBlankNode;
export type RdfNode = RdfIriNode | RdfBlankNode | RdfLiteralNode;
export interface RdfTriple {
subject: RdfSubjectNode;
property: RdfIriNode;
object: RdfNode;
why: RdfIriNode;
}
export interface RdfStore {
add(
subject: RdfSubjectNode,
property: RdfIriNode,
object: RdfNode,
why: RdfIriNode
): void;
any(
subject: RdfSubjectNode,
property: RdfIriNode,
object: RdfNode,
why: RdfIriNode
): RdfTriple;
each(
subject: RdfSubjectNode,
property: RdfIriNode,
object: RdfNode,
why: RdfIriNode
): RdfTriple[];
}
export type Namespace = (fragment: string) => RdfIriNode;
export interface RDF {
graph(): RdfStore;
parse(
input: string,
store: RdfStore,
origin: string,
contentType: string
): void;
sym(iri: string): RdfIriNode;
bnode(): RdfBlankNode;
literal(value: string): RdfLiteralNode;
literal(value: string, language: string): RdfLiteralNode;
literal(
value: string,
language: string,
datatype: RdfIriNode
): RdfLiteralNode;
Namespace(iriRadical: string): Namespace;
}
let $rdf: RDF;
export default $rdf;
}
......@@ -21,7 +21,7 @@
import * as React from "react";
/// <reference path="../../common/rdflib-interface.d.ts"/>
import { Store } from "rdflib";
import { RdfStore } from "rdflib";
import { Application } from "./interface";
enum StateType {
......@@ -32,7 +32,7 @@ enum StateType {
class State {
stateType: StateType;
message: string;
content: Store;
content: RdfStore;
}
export class Viewer extends React.Component<any, State> implements Application {
......@@ -52,7 +52,7 @@ export class Viewer extends React.Component<any, State> implements Application {
* Sets the content for the application
* @param content The content
*/
public onContent(content: Store): void {
public onContent(content: RdfStore): void {
let newState: State = {
stateType: StateType.Displaying,
message: "",
......
......@@ -19,7 +19,7 @@
******************************************************************************/
/// <reference path="../../common/rdflib-interface.d.ts"/>
import { Store } from "rdflib";
import { RdfStore } from "rdflib";
/**
* The public interface for the application
......@@ -29,7 +29,7 @@ export interface Application {
* Sets the content for the application
* @param content The content
*/
onContent(content: Store): void;
onContent(content: RdfStore): void;
/**
* Sets the application on error
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment