Skip to content

Commit

Permalink
Merge pull request #522 from GrimoireGL/fix/readme
Browse files Browse the repository at this point in the history
Fix/readme
  • Loading branch information
kyasbal committed Aug 21, 2017
2 parents 14bc599 + 150fea9 commit f4cacdd
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 23 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,18 @@ Please see official site and [Download page](https://grimoire.gl/guide/1_essenti

* **Official Site**・・・http://grimoire.gl

### API Reference

See [here](https://api.grimoire.gl/core).

This document is automatically generated.

<!--DOCUMENT STAMP-->

Make sure the API reference is only containing core stuff(Mutating goml stuff, operating attributes, methods being available on Component instance and so on).

If you want to see WebGL related feature of API, you should see [renderer plugin page](https://api.grimoire.gl/grimoirejs-fundamental).

## LICENSE

**MIT License**
Expand Down
24 changes: 24 additions & 0 deletions doc-timestamp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const fs = require("fs");

fs.readFile("./package.json","utf8",(err,data)=>{
if(err){
console.error(err);
process.exit(1);
}else{
const version = JSON.parse(data).version;
fs.readFile("./README.md","utf8",(err,original)=>{
if(err){
console.error(err);
process.exit(1);
}else{
const replaced = original.replace("<!--DOCUMENT STAMP-->",`* Update date: \`${new Date()}\`\n* Build version: \`${version}\``);
fs.writeFile("./README.md",replaced,(err,data)=>{
if(err){
console.error(err);
process.exit(1);
}
});
}
});
}
});
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,33 @@
"eventemitter3": "^2.0.3"
},
"devDependencies": {
"ava": "^0.21.0",
"babel-cli": "^6.24.0",
"babel-loader": "^7.1.1",
"ava": "^0.22.0",
"babel-cli": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-polyfill": "^6.23.0",
"babel-polyfill": "^6.26.0",
"babel-preset-es2015": "^6.24.0",
"babel-preset-stage-2": "^6.22.0",
"babel-register": "^6.24.1",
"babel-register": "^6.26.0",
"condition-circle": "^1.5.0",
"cpx": "^1.5.0",
"grimoirejs-cauldron": "^3.1.6",
"jsdom": "^11.1.0",
"lodash": "^4.17.2",
"nyc": "^11.0.3",
"nyc": "^11.1.0",
"proxyquire": "^1.7.11",
"regenerator-runtime": "^0.10.3",
"regenerator-runtime": "^0.11.0",
"remap-istanbul": "^0.9.5",
"semantic-release": "^6.3.2",
"sinon": "^2.3.8",
"semantic-release": "^7.0.2",
"sinon": "^3.2.1",
"trash-cli": "^1.4.0",
"ts-loader": "^2.3.0",
"tslint": "^5.5.0",
"typedoc": "^0.7.0",
"ts-loader": "^2.3.3",
"tslint": "^5.6.0",
"typedoc": "^0.8.0",
"typedoc-md-theme": "^1.0.1",
"typescript": "^2.4.1",
"typescript": "^2.4.2",
"typescript-awaiter": "^1.0.0",
"webpack": "^3.3.0",
"webpack": "^3.5.5",
"webpack-shell-plugin": "^0.5.0",
"xhr-mock": "^1.7.0",
"xmldom": "^0.1.27",
Expand All @@ -59,7 +59,7 @@
"generate-expose": "cauldron generate-exposure --src ./src --dest ./src/index.ts --ts --main ./src/main.ts --core",
"generate-reference": "cauldron generate-reference --src ./src --dest ./src/index.ts --ts --main ./src/main.ts --dts ./ref --core",
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
"doc": "typedoc --out ./docs/ --options typedoc.json ./tsconfig.json",
"doc": "node ./doc-timestamp.js && typedoc --out ./docs/ --options typedoc.json ./tsconfig.json",
"clear-test": "rm -rf coverage .nyc_output test-lib",
"clear": "rm -rf ref register && npm run clear-test"
},
Expand Down
12 changes: 8 additions & 4 deletions src/Interface/GrimoireInterface.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
import GrimoireInterfaceImpl from "./GrimoireInterfaceImpl";
import GomlInterfaceImpl from "./GomlInterfaceImpl";
import GomlNode from "../Node/GomlNode";
import {GomlInterface, GrimoireInterface} from "../Base/Types";
import { GomlInterface, GrimoireInterface } from "../Base/Types";


const context = new GrimoireInterfaceImpl();

function obtainGomlInterface(query: string): GomlInterface;
function obtainGomlInterface(query: GomlNode[]): GomlInterface;
function obtainGomlInterface(callback: (scriptTags: HTMLScriptElement[]) => void): void;
function obtainGomlInterface(query: string | GomlNode[] | ((scriptTags: HTMLScriptElement[]) => void)): void | GomlInterface {
function obtainGomlInterface(callback: () => void): void;
function obtainGomlInterface(query: string | GomlNode[] | (() => void)): void | GomlInterface {
if (typeof query === "string") {
const gomlContext = new GomlInterfaceImpl(context.queryRootNodes(query));
const queryFunc = gomlContext.queryFunc.bind(gomlContext);
Object.setPrototypeOf(queryFunc, gomlContext);
return queryFunc;
} else if (typeof query === "function") {
context.initializedEventHandler.push(query);
if (context.callInitializedAlready) {
query();
} else {
context.initializedEventHandler.push(query);
}
} else {
const gomlContext = new GomlInterfaceImpl(query);
const queryFunc = gomlContext.queryFunc.bind(gomlContext);
Expand Down
19 changes: 17 additions & 2 deletions src/Interface/GrimoireInterfaceImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import NSIdentity from "../Base/NSIdentity";
import Namespace from "../Base/Namespace";
import NSDictionary from "../Base/NSDictionary";
import Ensure from "../Base/Ensure";
import {Name, Nullable, Ctor, ComponentRegistering} from "../Base/Types";
import { Name, Nullable, Ctor, ComponentRegistering } from "../Base/Types";

export default class GrimoireInterfaceImpl extends EEObject {

Expand Down Expand Up @@ -64,6 +64,10 @@ export default class GrimoireInterfaceImpl extends EEObject {
return GomlLoader.initializedEventHandlers;
}

public get callInitializedAlready(): boolean {
return GomlLoader.callInitializedAlready;
}

/**
* [obsolete] use `Namespace.define` instead of.
* @param {string} ns namespace URI to be used
Expand Down Expand Up @@ -191,6 +195,12 @@ export default class GrimoireInterfaceImpl extends EEObject {
throw new Error("scriptTag is not goml");
}
}
/**
* Add specified nodes as root node managed by Grimoire.js
* This method is typically used for internal.
* @param tag the script element containing GOML source
* @param rootNode root node of Goml
*/
public addRootNode(tag: HTMLScriptElement, rootNode: GomlNode): string {
if (!rootNode) {
throw new Error("can not register null to rootNodes.");
Expand All @@ -209,6 +219,11 @@ export default class GrimoireInterfaceImpl extends EEObject {
ownerScriptTag: tag,
id: rootNode.id
});
// send events to catch root node appended
this.emit("root-node-added", {
ownerScriptTag: tag,
rootNode: rootNode
});
return rootNode.id;
}

Expand Down Expand Up @@ -358,7 +373,7 @@ export default class GrimoireInterfaceImpl extends EEObject {

private _ensureTobeNSIdentityOnRegister(name: Name): NSIdentity;
private _ensureTobeNSIdentityOnRegister(name: null | undefined): null;
private _ensureTobeNSIdentityOnRegister(name: Name |null | undefined): Nullable<NSIdentity> {
private _ensureTobeNSIdentityOnRegister(name: Name | null | undefined): Nullable<NSIdentity> {
if (!name) {
return null;
}
Expand Down
7 changes: 5 additions & 2 deletions src/Node/GomlLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import XMLHttpRequestAsync from "../Base/XMLHttpRequestAsync";
* Provides the features to fetch Goml source.
*/
class GomlLoader {
public static initializedEventHandlers: ((scriptTags: HTMLScriptElement[]) => void)[] = [];
public static callInitializedAlready = false;

public static initializedEventHandlers: (() => void)[] = [];

/**
* Obtain the Goml source from specified tag.
Expand Down Expand Up @@ -48,8 +50,9 @@ class GomlLoader {
}
await Promise.all<void>(pArray);
GomlLoader.initializedEventHandlers.forEach(handler => {
handler(elements);
handler();
});
this.callInitializedAlready = true;
}

/**
Expand Down

0 comments on commit f4cacdd

Please sign in to comment.