Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add require.on function to loader. Taken example from Dojo 1.0. Related to Issue #14 #43

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
862be35
added require.on function, utilising example form dojo 1.0 loader
Feb 19, 2016
8b21694
added enum and removed typing- https://github.com/Microsoft/TypeScrip…
Feb 19, 2016
db3e6eb
switched to string literal for type or signal
Feb 19, 2016
3e8ff8c
reorder interface
Feb 19, 2016
977c341
checkpoint with BF
Feb 19, 2016
bd3a739
added node unit tests
Feb 22, 2016
0234801
added functional tests
Feb 22, 2016
12616b9
added functional tests
Feb 22, 2016
4fd26db
fix failed ie tests
Feb 23, 2016
32fd398
update to TS1.8
Feb 24, 2016
6d66b5d
passed noImplicieUseStrict via additionalFlags param in GruntFile
Feb 24, 2016
2b2cea7
tslint update
Feb 25, 2016
1db58ce
updated tslint
Feb 25, 2016
e8bf185
used globalObject work around and move loadNodeModule function
Feb 25, 2016
bfb9ae9
fixed browser tests;
Feb 25, 2016
02c8def
ident to indent, fixed spaces
Feb 25, 2016
ccfe58d
fix tab
Feb 25, 2016
1bf81d6
updated comments from bforbes
Feb 25, 2016
95849c9
moved interfaces to .d.ts file
Feb 25, 2016
773e559
moved interfaces to .d.ts file
Feb 25, 2016
377ba0c
reorder exports
Feb 26, 2016
c600f8c
parent mid in interface
Feb 26, 2016
cdac75a
comment addressing
Feb 26, 2016
640119f
set edit flag to false
Feb 29, 2016
3fe2501
gitignore
Mar 1, 2016
ae80fa2
moved function def
Mar 1, 2016
ce57790
Update .gitignore
Mar 2, 2016
281ffd0
moved loadNodeModule def and added noop
Mar 2, 2016
6c6b04c
Merge branch 'ts1.8' into moduleLoadErrorReporting
Mar 2, 2016
1a77e3b
updated lint error
Mar 2, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@
"devDependencies": {
"codecov.io": "0.1.6",
"dts-generator": "1.6.3",
"glob": "3.2.7",
"glob": "7.0.0",
"grunt": "0.4.5",
"grunt-contrib-clean": "0.6.0",
"grunt-contrib-copy": "0.8.0",
"grunt-contrib-clean": "1.0.0",
"grunt-contrib-copy": "0.8.2",
"grunt-contrib-uglify": "0.11.0",
"grunt-contrib-watch": "0.6.1",
"grunt-exec": "0.4.6",
"grunt-release": "0.13.0",
"grunt-text-replace": "0.4.0",
"grunt-ts": "5.2.0",
"grunt-tslint": "3.0.0",
"intern": "~3.0.6",
"istanbul": "0.4.1",
"remap-istanbul": "~0.4.0",
"tslint": "3.1.1",
"typescript": "1.7.5"
"grunt-ts": "^5.3.2",
"grunt-tslint": "3.0.3",
"intern": "3.0.6",
"istanbul": "0.4.2",
"remap-istanbul": "0.5.1",
"tslint": "3.5.0",
"typescript": "1.8.2"
}
}
135 changes: 135 additions & 0 deletions src/interfaces.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
export interface Config {
baseUrl?: string;
map?: ModuleMap;
packages?: Package[];
paths?: { [ path: string ]: string; };
}

export interface Define {
(moduleId: string, dependencies: string[], factory: Factory): void;
(dependencies: string[], factory: Factory): void;
(factory: Factory): void;
(value: any): void;
}

export interface Factory {
(...modules: any[]): any;
}

export interface Has {
(name: string): any;
add(name: string, value: (global: Window, document?: HTMLDocument, element?: HTMLDivElement) => any,
now?: boolean, force?: boolean): void;
add(name: string, value: any, now?: boolean, force?: boolean): void;
}

export interface LoaderError extends Error {
src: string;
info: { module: Module, url: string, parentMid: string };
}

export interface LoaderPlugin {
load?: (resourceId: string, require: Require, load: (value?: any) => void, config?: Object) => void;
normalize?: (moduleId: string, normalize: (moduleId: string) => string) => string;
}

export interface MapItem extends Array<any> {
/* prefix */ 0: string;
/* replacement */ 1: any;
/* regExp */ 2: RegExp;
/* length */ 3: number;
}

export interface MapReplacement extends MapItem {
/* replacement */ 1: string;
}

export interface MapRoot extends Array<MapSource> {
star?: MapSource;
}

export interface MapSource extends MapItem {
/* replacement */ 1: MapReplacement[];
}

// TODO are we still abbreviating these properties?
export interface Module extends LoaderPlugin {
cjs: {
exports: any;
id: string;
setExports: (exports: any) => void;
uri: string;
};
def: Factory;
deps: Module[];
executed: any; // TODO: enum
injected: boolean;
fix?: (module: Module) => void;
gc: boolean;
mid: string;
pack: Package;
req: Require;
require?: Require; // TODO: WTF?
result: any;
url: string;

// plugin interface
loadQ?: Module[];
plugin?: Module;
prid: string;
}

export interface ModuleDefinitionArguments extends Array<any> {
0: string[];
1: Factory;
}

export interface ModuleMap extends ModuleMapItem {
[ sourceMid: string ]: ModuleMapReplacement;
}

export interface ModuleMapItem {
[ mid: string ]: /* ModuleMapReplacement | ModuleMap */ any;
}

export interface ModuleMapReplacement extends ModuleMapItem {
[ findMid: string ]: /* replaceMid */ string;
}

export interface ObjectMap { [ key: string ]: any; }

export interface Package {
location?: string;
main?: string;
name?: string;
}

export interface PackageMap {
[ packageId: string ]: Package;
}

export interface PathMap extends MapReplacement {}

export interface Require {
(config: Config, dependencies?: string[], callback?: RequireCallback): void;
(dependencies: string[], callback: RequireCallback): void;
<ModuleType>(moduleId: string): ModuleType;

toAbsMid(moduleId: string): string;
toUrl(path: string): string;
}

export interface RequireCallback {
(...modules: any[]): void;
}

export interface RootRequire extends Require {
has: Has;
on(type: SignalType, listener: any): { remove: () => void };
config(config: Config): void;
inspect?(name: string): any;
nodeRequire?(id: string): any;
undef(moduleId: string): void;
}

export type SignalType = 'error';
Loading