From df8b4ee1073eab25466514abbff7822dbce9966b Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Tue, 7 Apr 2015 15:27:10 -0700 Subject: [PATCH] ability to specify client-side imports --- ast/ast.ts | 1 + ast/typeChecker.ts | 9 +++++++++ lib/App.ts | 4 ++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ast/ast.ts b/ast/ast.ts index 375e3244..17ac639c 100644 --- a/ast/ast.ts +++ b/ast/ast.ts @@ -2067,6 +2067,7 @@ module TDev.AST { public diffRemovedThings:Decl[]; public npmModules: StringMap = {}; public bowerModules: StringMap = {}; + public clientScripts: StringMap = {}; public cordovaPlugins: StringMap = {}; public pipPackages: StringMap = {}; public touchDevelopPlugins: StringMap = {}; diff --git a/ast/typeChecker.ts b/ast/typeChecker.ts index 825080bb..c1813468 100644 --- a/ast/typeChecker.ts +++ b/ast/typeChecker.ts @@ -1632,6 +1632,8 @@ module TDev.AST this.importCordova(t, plugin, v); break; case "bower": this.importBower(t, plugin, v); break; + case "client": + this.importClientScript(t, plugin, v); break; case "pip": if (!this.topApp.canUseCapability(PlatformCapability.Npm)) this.unsupportedCapability(plugin, PlatformCapability.Npm); @@ -1685,6 +1687,13 @@ module TDev.AST } } + private importClientScript(t: Call, mod: string, v: string) { + if (mod && v != null) { + var imports = this.topApp.clientScripts; + imports[mod] = v; + } + } + private importBower(t: Call, mod: string, v: string) { if (mod && v != null) { var imports = this.topApp.bowerModules diff --git a/lib/App.ts b/lib/App.ts index 3c7da856..dda2733d 100644 --- a/lib/App.ts +++ b/lib/App.ts @@ -616,8 +616,8 @@ module TDev.RT { r.resume() } - //? Imports a dependent package which may be versioned. Package managers may be Node.JS npm, Bower, Apache cordova, Python Pip and TouchDevelop plugins. Bower packages are not available within the touchdevelop.com domain. - //@ name("import") [manager].deflStrings("npm", "cordova", "bower", "touchdevelop", "pip") [version].defl("*") + //? Imports a dependent package which may be versioned. Package managers may be Node.JS npm, Bower, Apache cordova, Python Pip and TouchDevelop plugins. ``bower`` and ``client`` imports are not available within the touchdevelop.com domain. + //@ name("import") [manager].deflStrings("npm", "cordova", "bower", "client", "touchdevelop", "pip") [version].defl("*") export function import_(manager : string, module: string, version: string): void { }