<commit_before>module.exports = function(grunt) {

    var targetName = "WinJSGruntTest";
    var buildDate = new Date();
    var month = buildDate.getMonth() + 1;
    var buildDateString = buildDate.getFullYear() + "." + month + "." + buildDate.getDate();
    var localeFolder = "en-US";

    var baseJSFiles = [
        "src/js/build/Copyright.js",
        "src/js/build/startbase.js",
        "src/js/base/references.js",
        "src/js/base/base.js",
        "src/js/base/baseutils.js",
        "src/js/base/log.js",
        "src/js/base/events.js",
        "src/js/base/resources.js",
        "src/js/base/promise.js",
        "src/js/base/scheduler.js",
        "src/js/base/errors.js",
        "src/js/base/xhr.js",
        "src/js/base/safehtml.js",
        "src/js/base/getwinjsstring.js",
        "src/js/base/dispose.js",

        "src/js/ui/control.js",
        "src/js/ui/declarativecontrols.js",
        "src/js/ui/elementlistutilities.js",
        "src/js/ui/elementutilities.js",
        "src/js/ui/fragmentcontrol.js",
        "src/js/ui/fragmentloader.js",
        "src/js/ui/optionslexer.js",
        "src/js/ui/optionsparser.js",
        "src/js/ui/tabmanager.js",
        "src/js/ui/transitionanimation.js",
        "src/js/ui/utilities.js",

        "src/js/wwa-app/application.js",
        "src/js/wwa-app/navigation2.js",
        "src/js/wwa-app/state.js",

        "src/js/binding/bindingparser.js",
        "src/js/binding/data.js",
        "src/js/binding/datatemplate.js",
        "src/js/binding/declarative.js",
        "src/js/binding/domweakreftable.js",
        "src/js/binding/list.js",
        "src/js/binding/datatemplatecompiler.js",

        "src/js/res/res.js",

        "src/js/build/endbase.js"
    ];

    var baseJSFilesPhone = [
        "src/js/startBase.js",
        "src/js/base/references.js",
        "src/js/base/base.js",
        "src/js/base/baseUtils.js",
        "src/js/base/baseUtils-phone.js",
        "src/js/base/log.js",
        "src/js/base/events.js",
        "src/js/base/resources.js",
        "src/js/base/promise.js",
        "src/js/base/scheduler.js",
        "src/js/base/errors.js",
        "src/js/base/xhr.js",
        "src/js/base/safeHTML.js",
        "src/js/base/getWintsString.js",
        "src/js/base/dispose.js",

        "src/js/ui/control.js",
        "src/js/ui/declarativeControls.js",
        "src/js/ui/elementListUtilities.js",
        "src/js/ui/elementUtilities.js",
        "src/js/ui/fragmentControl.js",
        "src/js/ui/fragmentLoader.js",
        "src/js/ui/optionsLexer.js",
        "src/js/ui/optionsParser.js",
        "src/js/ui/tabManager.js",
        "src/js/ui/transitionAnimation.js",
        "src/js/ui/utilities.js",

        "src/js/wwa-app/application.js",
        "src/js/wwa-app/navigation2.js",
        "src/js/wwa-app/state.js",

        "src/js/binding/bindingParser.js",
        "src/js/binding/data.js",
        "src/js/binding/dataTemplate.js",
        "src/js/binding/declarative.js",
        "src/js/binding/DOMWeakRefTable.js",
        "src/js/binding/list.js",
        "src/js/binding/dataTemplateCompiler.js",

        "src/js/res/Res.js",

        "src/js/endBase.js"
    ];

    var baseStringsFiles = [
        "src/js/build/Copyright.js",
        "src/js/library/stringsHeader.js",
        "src/js/library/stringsBlockHeader.js",
        "src/js/" + localeFolder + "/base.prefix.js",
        "src/js/" + localeFolder + "/base.resjson",
        "src/js/library/stringsBlockFooter.js",
        "src/js/library/stringsFooter.js"
    ];

    var uiJSFiles = [
        "src/js/build/Copyright.js",
        "src/js/build/startUI.js",
        "src/js/animations/animations.js",
        "src/js/uicollections/Assert.js",
        "src/js/uicollections/ItemsManager/BindingListDataSource.js",
        "src/js/uicollections/ItemsManager/ListDataSource.js",
        "src/js/uicollections/ItemsManager/GroupDataSource.js",
        "src/js/uicollections/ItemsManager/GroupedItemDataSource.js",
        "src/js/uicollections/ItemsManager/StorageDataSource.js",
        "src/js/uicollections/ItemsManager/ItemsManager.js",
        "src/js/uicollections/ItemsManager/ParallelWorkQueue.js",
        "src/js/uicollections/ItemsManager/VersionManager.js",
        "src/js/uicollections/Flipper/Flipper.js",
        "src/js/uicollections/Flipper/FlipperPageManager.js",
        "src/js/uicollections/ListView/BrowseMode.js",
        "src/js/uicollections/ListView/Constants.js",
        "src/js/uicollections/ListView/ErrorMessages.js",
        "src/js/uicollections/ListView/GroupFocusCache.js",
        "src/js/uicollections/ListView/GroupsContainer.js",
        "src/js/uicollections/ListView/ItemEventsHandler.js",
        "src/js/uicollections/ListView/ItemsContainer.js",
        "src/js/uicollections/ListView/Layouts2.js",
        "src/js/uicollections/ListView/ListViewImpl.js",
        "src/js/uicollections/Repeater/Repeater.js",
        "src/js/uicollections/ListView/SelectionManager.js",
        "src/js/uicollections/ListView/VirtualizeContentsView.js",
        "src/js/controls/DatePicker/datePicker.js",
        "src/js/controls/TimePicker/timePicker.js",
        "src/js/controls/Select/select.js",
        "src/js/controls/BackButton/backButton.js",
        "src/js/controls/Rating/rating.js",
        "src/js/controls/Toggle/Toggle.js",
        "src/js/controls/SemanticZoom/SemanticZoom.js",
        "src/js/controls/Hub/hub.js",
        "src/js/controls/Hub/hubSection.js",
        "src/js/controls/AppBar/Overlay.js",
        "src/js/controls/AppBar/AppBarIcon.js",
        "src/js/controls/AppBar/AppBarCommand.js",
        "src/js/controls/AppBar/AppBar.js",
        "src/js/controls/AppBar/Flyout.js",
        "src/js/controls/AppBar/Menu.js",
        "src/js/controls/AppBar/MenuCommand.js",
        "src/js/controls/SearchBox/searchBox.js",
        "src/js/controls/AppBar/SettingsFlyout.js",
        "src/js/controls/ItemContainer/itemContainer.js",
        "src/js/controls/NavBar/keyboardBehavior.js",
        "src/js/controls/NavBar/navBar.js",
        "src/js/controls/NavBar/navBarContainer.js",
        "src/js/controls/NavBar/navBarCommand.js",
        "src/js/controls/Tooltip/tooltip.js",
        "src/js/controls/ViewBox/ViewBox.js",
        "src/js/build/endUI.js"
    ];

    var uiJSFilesPhone = [
        "src/js/startUI.js",
        "src/js/uicollections/references.js",
        "src/js/animations/animations.js",
        "src/js/uicollections/Assert.js",
        "src/js/uicollections/ItemsManager/BindingListDataSource.js",
        "src/js/uicollections/ItemsManager/ListDataSource.js",
        "src/js/uicollections/ItemsManager/GroupDataSource.js",
        "src/js/uicollections/ItemsManager/GroupedItemDataSource.js",
        "src/js/uicollections/ItemsManager/StorageDataSource.js",
        "src/js/uicollections/ItemsManager/ItemsManager.js",
        "src/js/uicollections/ItemsManager/ParallelWorkQueue.js",
        "src/js/uicollections/ItemsManager/VersionManager.js",
        "src/js/uicollections/Flipper/Flipper.js",
        "src/js/uicollections/Flipper/FlipperPageManager.js",
        "src/js/uicollections/ListView/BrowseMode.js",
        "src/js/uicollections/ListView/Constants.js",
        "src/js/uicollections/ListView/ErrorMessages.js",
        "src/js/uicollections/ListView/GroupFocusCache.js",
        "src/js/uicollections/ListView/GroupsContainer.js",
        "src/js/uicollections/ListView/ItemEventsHandler.js",
        "src/js/uicollections/ListView/ItemsContainer.js",
        "src/js/uicollections/ListView/Layouts2.js",
        "src/js/uicollections/ListView/ListViewImpl.js",
        "src/js/uicollections/Repeater/Repeater.js",
        "src/js/uicollections/ListView/SelectionManager.js",
        "src/js/uicollections/ListView/VirtualizeContentsView.js",
        "src/js/controls/AppBar/AppBarIcon.js",
        "src/js/controls/AppBar/AppBarCommand-phone.js",
        "src/js/controls/AppBar/AppBar-phone.js",
        "src/js/controls/Pivot/Pivot.js",
        "src/js/controls/Pivot/PivotItem.js",
        "src/js/controls/Toggle/Toggle.js",
        "src/js/controls/ItemContainer/itemContainer.js",
        "src/js/controls/SemanticZoom/SemanticZoom.js",
        "src/js/controls/ViewBox/ViewBox.js",
        "src/js/endUI.js",
    ];

    var uiStringsFiles = [
        "src/js/build/Copyright.js",
        "src/js/library/stringsHeader.js",
        "src/js/library/stringsBlockHeader.js",
        "src/js/" + localeFolder + "/ui.prefix.js",
        "src/js/" + localeFolder + "/ui.resjson",
        "src/js/library/stringsBlockFooter.js",
        "src/js/library/stringsFooter.js"
    ];

    // Project config
    grunt.initConfig({
        pkg: grunt.file.readJSON("package.json"),

        clean: {
            base: [
                "bin/WinJS.Desktop/js/base.js",
                "bin/WinJS.Desktop/js/" + localeFolder + "/base.strings.js",
                "bin/WinJS.Phone/js/base.js",
                "bin/WinJS.Phone/js/" + localeFolder + "/base.strings.js",
            ],
            ui: [
                "bin/WinJS.Desktop/js/ui.js",
                "bin/WinJS.Desktop/js/" + localeFolder + "/ui.strings.js",
                "bin/WinJS.Phone/js/ui.js",
                "bin/WinJS.Phone/js/" + localeFolder + "/ui.strings.js"
            ],
            css: [
                "bin/WinJS.Desktop/css/ui-dark.css",
                "bin/WinJS.Desktop/css/ui-light.css",
                "bin/WinJS.Phone/css/ui-dark.css",
                "bin/WinJS.Phone/css/ui-light.css"
            ]
        },

        concat: {
            baseDesktop: {
                src: baseJSFiles,
                dest: "bin/WinJS.Desktop/js/base.js"
            },
            basePhone: {
                src: baseJSFilesPhone,
                dest: "bin/WinJS.Phone/js/base.js"
            },
            baseStringsDesktop: {
                src: baseStringsFiles,
                dest: "bin/WinJS.Desktop/js/" + localeFolder + "/base.strings.js"
            },
            baseStringsPhone: {
                src: baseStringsFiles,
                dest: "bin/WinJS.Phone/js/" + localeFolder + "/base.strings.js"
            },
            uiDesktop: {
                src: uiJSFiles,
                dest: "bin/WinJS.Desktop/js/ui.js"
            },
            uiPhone: {
                src: uiJSFilesPhone,
                dest: "bin/WinJS.Phone/js/ui.js"
            },
            uiStringsDesktop: {
                src: uiStringsFiles,
                dest: "bin/WinJS.Desktop/js/" + localeFolder + "/ui.strings.js"
            },
            uiStringsPhone: {
                src: uiStringsFiles,
                dest: "bin/WinJS.Phone/js/" + localeFolder + "/ui.strings.js"
            }
        },

        replace: {
            base: {
                options: {
                    patterns: [
                        {
                            match: /\$\(TARGET_DESTINATION\)/g,
                            replacement: targetName
                        },
                        {
                            match: /\$\(build.version\)/g,
                            replacement: "<%= pkg.version %>"
                        },
                        {
                            match: /\$\(build.date\)/g,
                            replacement: buildDateString
                        },
                        {
                            match: /\$\(build.branch\)/g,
                            replacement: "<%= pkg.name %>"
                        },
                        {   // Strip file references
                            match: /(.*)<reference(.*)\r\n/g,
                            replacement: ""
                        }
                    ]
                },
                files: [
                  {expand: true, flatten: true, src: ["bin/WinJS.Desktop/js/*.js"], dest: "bin/WinJS.Desktop/js/"},
                  {expand: true, flatten: true, src: ["bin/WinJS.Desktop/js/" + localeFolder + "/*.js"], dest: "bin/WinJS.Desktop/js/" + localeFolder + "/"},
                  {expand: true, flatten: true, src: ["bin/WinJS.Phone/js/*.js"], dest: "bin/WinJS.Phone/js/"},
                  {expand: true, flatten: true, src: ["bin/WinJS.Phone/js/" + localeFolder + "/*.js"], dest: "bin/WinJS.Phone/js/" + localeFolder + "/"}
                ]
            }
        },

        less: {
            desktopDark: {
                src: ["src/less/desktop-dark.less"],
                dest: "bin/WinJS.Desktop/css/ui-dark.css"
            },
            desktopLight: {
                src: ["src/less/desktop-light.less"],
                dest: "bin/WinJS.Desktop/css/ui-light.css"
            },
            phoneDark: {
                src: ["src/less/phone-dark.less"],
                dest: "bin/WinJS.Phone/css/ui-dark.css"
            },
            phoneLight: {
                src: ["src/less/phone-light.less"],
                dest: "bin/WinJS.Phone/css/ui-light.css"
            },
        }
    });

    grunt.loadNpmTasks("grunt-contrib-concat");
    grunt.loadNpmTasks("grunt-typescript");
    grunt.loadNpmTasks("grunt-contrib-less");
    grunt.loadNpmTasks("grunt-replace");
    grunt.loadNpmTasks("grunt-contrib-clean");

    grunt.registerTask("default", ["clean", "less", "concat", "replace"]);
    grunt.registerTask("css", ["less"]);
    grunt.registerTask("base", ["clean:base", "concat:baseDesktop", "concat:basePhone", "concat:baseStrings", "replace"]);
    grunt.registerTask("ui", ["clean:ui", "concat:uiDesktop", "concat:uiPhone", "concat:uiStrings", "replace"]);
}<commit_msg>Remove typescript npm task<commit_after>module.exports = function(grunt) {

    var targetName = "WinJSGruntTest";
    var buildDate = new Date();
    var month = buildDate.getMonth() + 1;
    var buildDateString = buildDate.getFullYear() + "." + month + "." + buildDate.getDate();
    var localeFolder = "en-US";

    var baseJSFiles = [
        "src/js/build/Copyright.js",
        "src/js/build/startbase.js",
        "src/js/base/references.js",
        "src/js/base/base.js",
        "src/js/base/baseutils.js",
        "src/js/base/log.js",
        "src/js/base/events.js",
        "src/js/base/resources.js",
        "src/js/base/promise.js",
        "src/js/base/scheduler.js",
        "src/js/base/errors.js",
        "src/js/base/xhr.js",
        "src/js/base/safehtml.js",
        "src/js/base/getwinjsstring.js",
        "src/js/base/dispose.js",

        "src/js/ui/control.js",
        "src/js/ui/declarativecontrols.js",
        "src/js/ui/elementlistutilities.js",
        "src/js/ui/elementutilities.js",
        "src/js/ui/fragmentcontrol.js",
        "src/js/ui/fragmentloader.js",
        "src/js/ui/optionslexer.js",
        "src/js/ui/optionsparser.js",
        "src/js/ui/tabmanager.js",
        "src/js/ui/transitionanimation.js",
        "src/js/ui/utilities.js",

        "src/js/wwa-app/application.js",
        "src/js/wwa-app/navigation2.js",
        "src/js/wwa-app/state.js",

        "src/js/binding/bindingparser.js",
        "src/js/binding/data.js",
        "src/js/binding/datatemplate.js",
        "src/js/binding/declarative.js",
        "src/js/binding/domweakreftable.js",
        "src/js/binding/list.js",
        "src/js/binding/datatemplatecompiler.js",

        "src/js/res/res.js",

        "src/js/build/endbase.js"
    ];

    var baseJSFilesPhone = [
        "src/js/startBase.js",
        "src/js/base/references.js",
        "src/js/base/base.js",
        "src/js/base/baseUtils.js",
        "src/js/base/baseUtils-phone.js",
        "src/js/base/log.js",
        "src/js/base/events.js",
        "src/js/base/resources.js",
        "src/js/base/promise.js",
        "src/js/base/scheduler.js",
        "src/js/base/errors.js",
        "src/js/base/xhr.js",
        "src/js/base/safeHTML.js",
        "src/js/base/getWintsString.js",
        "src/js/base/dispose.js",

        "src/js/ui/control.js",
        "src/js/ui/declarativeControls.js",
        "src/js/ui/elementListUtilities.js",
        "src/js/ui/elementUtilities.js",
        "src/js/ui/fragmentControl.js",
        "src/js/ui/fragmentLoader.js",
        "src/js/ui/optionsLexer.js",
        "src/js/ui/optionsParser.js",
        "src/js/ui/tabManager.js",
        "src/js/ui/transitionAnimation.js",
        "src/js/ui/utilities.js",

        "src/js/wwa-app/application.js",
        "src/js/wwa-app/navigation2.js",
        "src/js/wwa-app/state.js",

        "src/js/binding/bindingParser.js",
        "src/js/binding/data.js",
        "src/js/binding/dataTemplate.js",
        "src/js/binding/declarative.js",
        "src/js/binding/DOMWeakRefTable.js",
        "src/js/binding/list.js",
        "src/js/binding/dataTemplateCompiler.js",

        "src/js/res/Res.js",

        "src/js/endBase.js"
    ];

    var baseStringsFiles = [
        "src/js/build/Copyright.js",
        "src/js/library/stringsHeader.js",
        "src/js/library/stringsBlockHeader.js",
        "src/js/" + localeFolder + "/base.prefix.js",
        "src/js/" + localeFolder + "/base.resjson",
        "src/js/library/stringsBlockFooter.js",
        "src/js/library/stringsFooter.js"
    ];

    var uiJSFiles = [
        "src/js/build/Copyright.js",
        "src/js/build/startUI.js",
        "src/js/animations/animations.js",
        "src/js/uicollections/Assert.js",
        "src/js/uicollections/ItemsManager/BindingListDataSource.js",
        "src/js/uicollections/ItemsManager/ListDataSource.js",
        "src/js/uicollections/ItemsManager/GroupDataSource.js",
        "src/js/uicollections/ItemsManager/GroupedItemDataSource.js",
        "src/js/uicollections/ItemsManager/StorageDataSource.js",
        "src/js/uicollections/ItemsManager/ItemsManager.js",
        "src/js/uicollections/ItemsManager/ParallelWorkQueue.js",
        "src/js/uicollections/ItemsManager/VersionManager.js",
        "src/js/uicollections/Flipper/Flipper.js",
        "src/js/uicollections/Flipper/FlipperPageManager.js",
        "src/js/uicollections/ListView/BrowseMode.js",
        "src/js/uicollections/ListView/Constants.js",
        "src/js/uicollections/ListView/ErrorMessages.js",
        "src/js/uicollections/ListView/GroupFocusCache.js",
        "src/js/uicollections/ListView/GroupsContainer.js",
        "src/js/uicollections/ListView/ItemEventsHandler.js",
        "src/js/uicollections/ListView/ItemsContainer.js",
        "src/js/uicollections/ListView/Layouts2.js",
        "src/js/uicollections/ListView/ListViewImpl.js",
        "src/js/uicollections/Repeater/Repeater.js",
        "src/js/uicollections/ListView/SelectionManager.js",
        "src/js/uicollections/ListView/VirtualizeContentsView.js",
        "src/js/controls/DatePicker/datePicker.js",
        "src/js/controls/TimePicker/timePicker.js",
        "src/js/controls/Select/select.js",
        "src/js/controls/BackButton/backButton.js",
        "src/js/controls/Rating/rating.js",
        "src/js/controls/Toggle/Toggle.js",
        "src/js/controls/SemanticZoom/SemanticZoom.js",
        "src/js/controls/Hub/hub.js",
        "src/js/controls/Hub/hubSection.js",
        "src/js/controls/AppBar/Overlay.js",
        "src/js/controls/AppBar/AppBarIcon.js",
        "src/js/controls/AppBar/AppBarCommand.js",
        "src/js/controls/AppBar/AppBar.js",
        "src/js/controls/AppBar/Flyout.js",
        "src/js/controls/AppBar/Menu.js",
        "src/js/controls/AppBar/MenuCommand.js",
        "src/js/controls/SearchBox/searchBox.js",
        "src/js/controls/AppBar/SettingsFlyout.js",
        "src/js/controls/ItemContainer/itemContainer.js",
        "src/js/controls/NavBar/keyboardBehavior.js",
        "src/js/controls/NavBar/navBar.js",
        "src/js/controls/NavBar/navBarContainer.js",
        "src/js/controls/NavBar/navBarCommand.js",
        "src/js/controls/Tooltip/tooltip.js",
        "src/js/controls/ViewBox/ViewBox.js",
        "src/js/build/endUI.js"
    ];

    var uiJSFilesPhone = [
        "src/js/startUI.js",
        "src/js/uicollections/references.js",
        "src/js/animations/animations.js",
        "src/js/uicollections/Assert.js",
        "src/js/uicollections/ItemsManager/BindingListDataSource.js",
        "src/js/uicollections/ItemsManager/ListDataSource.js",
        "src/js/uicollections/ItemsManager/GroupDataSource.js",
        "src/js/uicollections/ItemsManager/GroupedItemDataSource.js",
        "src/js/uicollections/ItemsManager/StorageDataSource.js",
        "src/js/uicollections/ItemsManager/ItemsManager.js",
        "src/js/uicollections/ItemsManager/ParallelWorkQueue.js",
        "src/js/uicollections/ItemsManager/VersionManager.js",
        "src/js/uicollections/Flipper/Flipper.js",
        "src/js/uicollections/Flipper/FlipperPageManager.js",
        "src/js/uicollections/ListView/BrowseMode.js",
        "src/js/uicollections/ListView/Constants.js",
        "src/js/uicollections/ListView/ErrorMessages.js",
        "src/js/uicollections/ListView/GroupFocusCache.js",
        "src/js/uicollections/ListView/GroupsContainer.js",
        "src/js/uicollections/ListView/ItemEventsHandler.js",
        "src/js/uicollections/ListView/ItemsContainer.js",
        "src/js/uicollections/ListView/Layouts2.js",
        "src/js/uicollections/ListView/ListViewImpl.js",
        "src/js/uicollections/Repeater/Repeater.js",
        "src/js/uicollections/ListView/SelectionManager.js",
        "src/js/uicollections/ListView/VirtualizeContentsView.js",
        "src/js/controls/AppBar/AppBarIcon.js",
        "src/js/controls/AppBar/AppBarCommand-phone.js",
        "src/js/controls/AppBar/AppBar-phone.js",
        "src/js/controls/Pivot/Pivot.js",
        "src/js/controls/Pivot/PivotItem.js",
        "src/js/controls/Toggle/Toggle.js",
        "src/js/controls/ItemContainer/itemContainer.js",
        "src/js/controls/SemanticZoom/SemanticZoom.js",
        "src/js/controls/ViewBox/ViewBox.js",
        "src/js/endUI.js",
    ];

    var uiStringsFiles = [
        "src/js/build/Copyright.js",
        "src/js/library/stringsHeader.js",
        "src/js/library/stringsBlockHeader.js",
        "src/js/" + localeFolder + "/ui.prefix.js",
        "src/js/" + localeFolder + "/ui.resjson",
        "src/js/library/stringsBlockFooter.js",
        "src/js/library/stringsFooter.js"
    ];

    // Project config
    grunt.initConfig({
        pkg: grunt.file.readJSON("package.json"),

        clean: {
            base: [
                "bin/WinJS.Desktop/js/base.js",
                "bin/WinJS.Desktop/js/" + localeFolder + "/base.strings.js",
                "bin/WinJS.Phone/js/base.js",
                "bin/WinJS.Phone/js/" + localeFolder + "/base.strings.js",
            ],
            ui: [
                "bin/WinJS.Desktop/js/ui.js",
                "bin/WinJS.Desktop/js/" + localeFolder + "/ui.strings.js",
                "bin/WinJS.Phone/js/ui.js",
                "bin/WinJS.Phone/js/" + localeFolder + "/ui.strings.js"
            ],
            css: [
                "bin/WinJS.Desktop/css/ui-dark.css",
                "bin/WinJS.Desktop/css/ui-light.css",
                "bin/WinJS.Phone/css/ui-dark.css",
                "bin/WinJS.Phone/css/ui-light.css"
            ]
        },

        concat: {
            baseDesktop: {
                src: baseJSFiles,
                dest: "bin/WinJS.Desktop/js/base.js"
            },
            basePhone: {
                src: baseJSFilesPhone,
                dest: "bin/WinJS.Phone/js/base.js"
            },
            baseStringsDesktop: {
                src: baseStringsFiles,
                dest: "bin/WinJS.Desktop/js/" + localeFolder + "/base.strings.js"
            },
            baseStringsPhone: {
                src: baseStringsFiles,
                dest: "bin/WinJS.Phone/js/" + localeFolder + "/base.strings.js"
            },
            uiDesktop: {
                src: uiJSFiles,
                dest: "bin/WinJS.Desktop/js/ui.js"
            },
            uiPhone: {
                src: uiJSFilesPhone,
                dest: "bin/WinJS.Phone/js/ui.js"
            },
            uiStringsDesktop: {
                src: uiStringsFiles,
                dest: "bin/WinJS.Desktop/js/" + localeFolder + "/ui.strings.js"
            },
            uiStringsPhone: {
                src: uiStringsFiles,
                dest: "bin/WinJS.Phone/js/" + localeFolder + "/ui.strings.js"
            }
        },

        replace: {
            base: {
                options: {
                    patterns: [
                        {
                            match: /\$\(TARGET_DESTINATION\)/g,
                            replacement: targetName
                        },
                        {
                            match: /\$\(build.version\)/g,
                            replacement: "<%= pkg.version %>"
                        },
                        {
                            match: /\$\(build.date\)/g,
                            replacement: buildDateString
                        },
                        {
                            match: /\$\(build.branch\)/g,
                            replacement: "<%= pkg.name %>"
                        },
                        {   // Strip file references
                            match: /(.*)<reference(.*)\r\n/g,
                            replacement: ""
                        }
                    ]
                },
                files: [
                  {expand: true, flatten: true, src: ["bin/WinJS.Desktop/js/*.js"], dest: "bin/WinJS.Desktop/js/"},
                  {expand: true, flatten: true, src: ["bin/WinJS.Desktop/js/" + localeFolder + "/*.js"], dest: "bin/WinJS.Desktop/js/" + localeFolder + "/"},
                  {expand: true, flatten: true, src: ["bin/WinJS.Phone/js/*.js"], dest: "bin/WinJS.Phone/js/"},
                  {expand: true, flatten: true, src: ["bin/WinJS.Phone/js/" + localeFolder + "/*.js"], dest: "bin/WinJS.Phone/js/" + localeFolder + "/"}
                ]
            }
        },

        less: {
            desktopDark: {
                src: ["src/less/desktop-dark.less"],
                dest: "bin/WinJS.Desktop/css/ui-dark.css"
            },
            desktopLight: {
                src: ["src/less/desktop-light.less"],
                dest: "bin/WinJS.Desktop/css/ui-light.css"
            },
            phoneDark: {
                src: ["src/less/phone-dark.less"],
                dest: "bin/WinJS.Phone/css/ui-dark.css"
            },
            phoneLight: {
                src: ["src/less/phone-light.less"],
                dest: "bin/WinJS.Phone/css/ui-light.css"
            },
        }
    });

    grunt.loadNpmTasks("grunt-contrib-concat");
    grunt.loadNpmTasks("grunt-contrib-less");
    grunt.loadNpmTasks("grunt-replace");
    grunt.loadNpmTasks("grunt-contrib-clean");

    grunt.registerTask("default", ["clean", "less", "concat", "replace"]);
    grunt.registerTask("css", ["less"]);
    grunt.registerTask("base", ["clean:base", "concat:baseDesktop", "concat:basePhone", "concat:baseStrings", "replace"]);
    grunt.registerTask("ui", ["clean:ui", "concat:uiDesktop", "concat:uiPhone", "concat:uiStrings", "replace"]);
}<|endoftext|>


<commit_before>import express from 'express';
import BusinessController from './controllers/BusinessController';
import InvoiceController from './controllers/InvoiceController';

let mongoose = require('mongoose');
let bodyParser = require('body-parser');

mongoose.connect('mongodb://db:27017/db');
const app = express();

app.use(bodyParser.json({ limit: '5mb' }));

let port = 7004;
let router = express.Router();

app.use((req, res, next) => {
  res.header("Access-Control-Allow-Origin", "*");
  res.header(
    "Access-Control-Allow-Headers",
    "Origin, X-Requested-With, Content-Type, Accept"
  );
  next();
});

let businessesRoute = router.route('/businesses');
businessesRoute.get(BusinessController.getBusinesses);

let businessIDRoute = router.route('/businesses/:id');
businessIDRoute.get(BusinessController.getSingleBusiness);

let invoicesRoute = router.route('/invoices');
invoicesRoute.post(InvoiceController.uploadInvoice);
invoicesRoute.get(InvoiceController.getInvoices);

let invoiceRoute = router.route('/invoices/:id')
invoiceRoute.get(InvoiceController.findInvoice);

app.use('/api', router);
app.listen(port);
console.log("🌎 Listening for Database API calls!");
<commit_msg>bit more reduction in router code.<commit_after>import express from 'express';
import BusinessController from './controllers/BusinessController';
import InvoiceController from './controllers/InvoiceController';

let mongoose = require('mongoose');
let bodyParser = require('body-parser');

mongoose.connect('mongodb://db:27017/db');
const app = express();

app.use(bodyParser.json({ limit: '5mb' }));

let port = 7004;
let router = express.Router();

app.use((req, res, next) => {
  res.header("Access-Control-Allow-Origin", "*");
  res.header(
    "Access-Control-Allow-Headers",
    "Origin, X-Requested-With, Content-Type, Accept"
  );
  next();
});

router.route('/businesses')
  .get(BusinessController.getBusinesses);

router.route('/businesses/:id')
  .get(BusinessController.getSingleBusiness);

router.route('/invoices')
  .post(InvoiceController.uploadInvoice)
  .get(InvoiceController.getInvoices);

router.route('/invoices/:id')
  .get(InvoiceController.findInvoice);

app.use('/api', router);
app.listen(port);
console.log("🌎 Listening for Database API calls!");
<|endoftext|>


<commit_before>/**
 * Created by Kemal on 07/30/15.
 */
/*
 * CONCAT APP JS
 * CONCAT ASSET CSS
 * CONCAT VENDOR JS
 * CONCAT VENDOR CSS
 * WATCH APP JS
 * WATCH ASSET CSS
 * COPY ICONS
 * COPY FONTS
 * CONDITIONAL GRUNT DEV VS PROD
 *
 * NICE TO HAVS
 * NOT HAVING TO EXPLICTLY INCLUDE VENDOR .JS OR .CSS
 *
 * NPM, bower, grunt
 *
 */

module.exports = function (grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        concat: {
            appdist: {
                src: ['src/app/appdist.js',
                    'src/app/directives/watgFeedbackDirective.js',
                    'src/app/services/watgFeedbackService.js'],
                dest: 'dist/js/watg-angular-feedback.js'
            },
            app: {
                src: ['src/app/app.js',
                    'src/app/controllers/watgFeedbackTestController.js',
                    'src/app/directives/watgFeedbackDirective.js',
                    'src/app/services/watgFeedbackService.js'],
                dest: 'dev/js/watg-angular-feedback.js'
            },
            vendor: {
                src: [
                    'bower_components/jquery/dist/jquery.min.js',
                    'bower_components/bootstrap/dist/js/bootstrap.min.js',
                    'bower_components/moment/min/moment.min.js',
                    'bower_components/angular/angular.min.js',
                    'bower_components/angular-sanitize/angular-sanitize.min.js',
                    'bower_components/angular-route/angular-route.min.js',
                    'bower_components/angular-animate/angular-animate.min.js'
                ],
                dest: 'dev/js/vendor.min.js'
            }
        },
        uglify: {
            options: {
                banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n',
                mangle: false
            },
            app: {
                files: {
                    'dev/js/watg-angular-feedback.min.js': ['dev/js/watg-angular-feedback.js']
                }
            },
            appdist: {
                files: {
                    'dist/js/watg-angular-feedback.min.js': ['dist/js/watg-angular-feedback.js']
                }
            }
        },
        concat_css: {
            assets: {
                src: ["src/assets/watg-angular-feedback.css"],
                dest: "dev/css/watg-angular-feedback.css"
            },
            assetsdist: {
                src: ["src/assets/watg-angular-feedback.css"],
                dest: "dist/css/watg-angular-feedback.css"
            }
        },
        cssmin: {
            options: {
                keepSpecialComments: 0
            },
            assets: {
                files: {
                    'dev/css/watg-angular-feedback.min.css': ['dev/css/watg-angular-feedback.css']
                }
            },
            assetsdist: {
                files: {
                    'dist/css/watg-angular-feedback.min.css': ['dist/css/watg-angular-feedback.css']
                }
            },
            vendor: {
                files: {
                    'dev/css/vendor.min.css': [
                        'bower_components/bootstrap/dist/css/bootstrap.css',
                        'bower_components/fontawesome/css/font-awesome.css'
                    ]
                }
            }
        },
        watch: {
            files: ['src/app/**/*.js', 'src/assets/*.css'],
            tasks: ['concat:app','concat:appdist', 'uglify', 'concat_css', 'cssmin:assets', 'cssmin:assetsdist']
        },
        copy: {
            main: {
                files: [
                    {
                        expand: true,
                        src: ['bower_components/fontawesome/fonts/*', 'bower_components/bootstrap/fonts/*'],
                        dest: 'dev/fonts/',
                        filter: 'isFile',
                        flatten: true
                    },
                    {
                        expand: true,
                        src: ['bower_components/footable/css/fonts/*'],
                        dest: 'dev/css/fonts/',
                        filter: 'isFile',
                        flatten: true
                    },
                    {
                        expand: true,
                        src: ['content/images/*', 'bower_components/jquery-ui/themes/base/images/*'],
                        dest: 'dev/css/images/',
                        filter: 'isFile',
                        flatten: true
                    }
                ]
            },
        },
        html2js: {
            options: {
                base: 'src',
                module: 'watgFeedback.templates',
                singleModule: true,
                useStrict: true,
                htmlmin: {
                    collapseBooleanAttributes: true,
                    collapseWhitespace: true,
                    removeAttributeQuotes: true,
                    removeComments: true,
                    removeEmptyAttributes: true,
                    removeRedundantAttributes: true,
                    removeScriptTypeAttributes: true,
                    removeStyleLinkTypeAttributes: true
                }
            },
            main: {
                src: ['src/app/templates/*.html'],
                dest: 'dist/js/watg-angular-feedback.tpl.js'
            }
        }
    });

    grunt.loadNpmTasks('grunt-concat-css');
    grunt.loadNpmTasks('grunt-html2js');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-watch');

    grunt.registerTask('default', ['concat', 'uglify', 'concat_css', 'cssmin', 'copy']);
    grunt.registerTask('dist', ['concat:appdist', 'uglify:appdist', 'concat_css:assetsdist', 'cssmin:assetsdist', 'html2js']);

};<commit_msg>Cleaning and compacting dist files. Only using required dependencies<commit_after>/**
 * Created by Kemal on 07/30/15.
 */
/*
 * CONCAT APP JS
 * CONCAT ASSET CSS
 * CONCAT VENDOR JS
 * CONCAT VENDOR CSS
 * WATCH APP JS
 * WATCH ASSET CSS
 * COPY ICONS
 * COPY FONTS
 * CONDITIONAL GRUNT DEV VS PROD
 *
 * NICE TO HAVS
 * NOT HAVING TO EXPLICTLY INCLUDE VENDOR .JS OR .CSS
 *
 * NPM, bower, grunt
 *
 */

module.exports = function (grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        concat: {
            appdist: {
                src: ['src/app/appdist.js',
                    'src/app/directives/watgFeedbackDirective.js',
                    'src/app/services/watgFeedbackService.js'],
                dest: 'dist/js/watg-angular-feedback.js'
            },
            app: {
                src: ['src/app/app.js',
                    'src/app/controllers/watgFeedbackTestController.js',
                    'src/app/directives/watgFeedbackDirective.js',
                    'src/app/services/watgFeedbackService.js'],
                dest: 'dev/js/watg-angular-feedback.js'
            },
            vendor: {
                src: [
                    'bower_components/jquery/dist/jquery.min.js',
                    'bower_components/bootstrap/dist/js/bootstrap.min.js',
                    'bower_components/moment/min/moment.min.js',
                    'bower_components/angular/angular.min.js',
                    'bower_components/angular-sanitize/angular-sanitize.min.js',
                    'bower_components/angular-route/angular-route.min.js',
                    'bower_components/angular-animate/angular-animate.min.js'
                ],
                dest: 'dev/js/vendor.min.js'
            }
        },
        uglify: {
            options: {
                banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n',
                mangle: false
            },
            app: {
                files: {
                    'dev/js/watg-angular-feedback.min.js': ['dev/js/watg-angular-feedback.js']
                }
            },
            appdist: {
                files: {
                    'dist/js/watg-angular-feedback.min.js': ['dist/js/watg-angular-feedback.js']
                }
            }
        },
        concat_css: {
            assets: {
                src: ["src/assets/watg-angular-feedback.css"],
                dest: "dev/css/watg-angular-feedback.css"
            },
            assetsdist: {
                src: ["src/assets/watg-angular-feedback.css"],
                dest: "dist/css/watg-angular-feedback.css"
            }
        },
        cssmin: {
            options: {
                keepSpecialComments: 0
            },
            assets: {
                files: {
                    'dev/css/watg-angular-feedback.min.css': ['dev/css/watg-angular-feedback.css']
                }
            },
            assetsdist: {
                files: {
                    'dist/css/watg-angular-feedback.min.css': ['dist/css/watg-angular-feedback.css']
                }
            },
            vendor: {
                files: {
                    'dev/css/vendor.min.css': [
                        'bower_components/bootstrap/dist/css/bootstrap.css',
                        'bower_components/fontawesome/css/font-awesome.css'
                    ]
                }
            }
        },
        watch: {
            files: ['src/app/**/*.js', 'src/assets/*.css'],
            tasks: ['concat:app','concat:appdist', 'uglify', 'concat_css', 'cssmin:assets', 'cssmin:assetsdist']
        },
        copy: {
            main: {
                files: [
                    {
                        expand: true,
                        src: ['bower_components/fontawesome/fonts/*', 'bower_components/bootstrap/fonts/*'],
                        dest: 'dev/fonts/',
                        filter: 'isFile',
                        flatten: true
                    },
                    {
                        expand: true,
                        src: ['bower_components/footable/css/fonts/*'],
                        dest: 'dev/css/fonts/',
                        filter: 'isFile',
                        flatten: true
                    },
                    {
                        expand: true,
                        src: ['content/images/*', 'bower_components/jquery-ui/themes/base/images/*'],
                        dest: 'dev/css/images/',
                        filter: 'isFile',
                        flatten: true
                    }
                ]
            }
        },
        html2js: {
            options: {
                base: 'src',
                module: 'watgFeedback.templates',
                singleModule: true,
                useStrict: true,
                htmlmin: {
                    collapseBooleanAttributes: true,
                    collapseWhitespace: true,
                    removeAttributeQuotes: true,
                    removeComments: true,
                    removeEmptyAttributes: true,
                    removeRedundantAttributes: true,
                    removeScriptTypeAttributes: true,
                    removeStyleLinkTypeAttributes: true
                }
            },
            main: {
                src: ['src/app/templates/*.html'],
                dest: 'dist/js/watg-angular-feedback.tpl.js'
            }
        }
    });

    grunt.loadNpmTasks('grunt-concat-css');
    grunt.loadNpmTasks('grunt-html2js');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-watch');

    grunt.registerTask('default', ['concat', 'uglify', 'concat_css', 'cssmin', 'copy']);
    grunt.registerTask('dist', ['concat:appdist', 'uglify:appdist', 'concat_css:assetsdist', 'cssmin:assetsdist', 'html2js']);

};<|endoftext|>


<commit_before>define(['react', 'components/page_header', 'components/mixins/loading',
'collections/instances', 'rsvp', 'components/common/time'], function(React,
PageHeader, LoadingMixin, Instances, RSVP, Time) {

    var InstanceAttributes = React.createClass({
        renderPair: function(k, v) {
            return [React.DOM.dt({}, k), React.DOM.dd({}, v)];
        },
        renderIdentity: function(identity) {
            var text = identity.id + " on provider ";
            if (this.props.providers) {
                var provider = this.props.providers.get(identity.provider);
                text += provider.get('name');
            } else
                text += identity.provider;
            return text;
        },
        render: function() {
            var instance = this.props.instance;
            return React.DOM.dl({},
                this.renderPair("Status", instance.get('status')),
                this.renderPair("IP Address", instance.get('ip_address')),
                this.renderPair("Identity", this.renderIdentity(instance.get('identity'))),
                this.renderPair("ID", instance.id),
                this.renderPair("Date Launched", Time({date: instance.get('start_date')})));
        }
    });

    var InstanceLinks = React.createClass({
        renderLink: function(text, url) {
            return React.DOM.li({},
                React.DOM.a({href: url, rel: 'external'}, text));
        },
        render: function() {
            var instance = this.props.instance;
            return React.DOM.ul({},
                this.renderLink("Web Shell", instance.get('shell_url')),
                this.renderLink("Remote Desktop", instance.get('vnc_url')));
        }
    });

    var InstancePage = React.createClass({
        render: function() {
            var instance = this.props.instance;
            return React.DOM.div({},
                PageHeader({title: "Instance: " + instance.get('name_or_id')}),
                InstanceAttributes({instance: instance,
                    providers: this.props.providers}),
                InstanceLinks({instance: instance}));
        }
    });

    var InstanceDetail = React.createClass({
        mixins: [LoadingMixin],
        model: function() {
            var coll = new Instances([], {
                provider_id: this.props.providerId,
                identity_id: this.props.identityId
            });
            var instanceId = this.props.instanceId;
            return new RSVP.Promise(function(resolve, reject) {
                coll.fetch({success: function() {
                    var instance = coll.get(instanceId);
                    if (instance === undefined)
                        reject("Unknown instance " + instanceId);
                    resolve(instance);
                }});
            });
        },
        renderContent: function() {
            console.log(this.state.model);
            return InstancePage({instance: this.state.model, providers: this.props.providers});
        }
    });

    return InstanceDetail;
});
<commit_msg>Shell and vnc links styled to indicate they open new windows<commit_after>define(['react', 'components/page_header', 'components/mixins/loading',
'collections/instances', 'rsvp', 'components/common/time'], function(React,
PageHeader, LoadingMixin, Instances, RSVP, Time) {

    var InstanceAttributes = React.createClass({
        renderPair: function(k, v) {
            return [React.DOM.dt({}, k), React.DOM.dd({}, v)];
        },
        renderIdentity: function(identity) {
            var text = identity.id + " on provider ";
            if (this.props.providers) {
                var provider = this.props.providers.get(identity.provider);
                text += provider.get('name');
            } else
                text += identity.provider;
            return text;
        },
        render: function() {
            var instance = this.props.instance;
            return React.DOM.dl({},
                this.renderPair("Status", instance.get('status')),
                this.renderPair("IP Address", instance.get('ip_address')),
                this.renderPair("Identity", this.renderIdentity(instance.get('identity'))),
                this.renderPair("ID", instance.id),
                this.renderPair("Date Launched", Time({date: instance.get('start_date')})));
        }
    });

    var InstanceLinks = React.createClass({
        renderLink: function(text, url) {
            return React.DOM.li({},
                React.DOM.a({href: url,
                    target: '_blank',
                    className: 'new-window'}, text));
        },
        render: function() {
            var instance = this.props.instance;
            return React.DOM.ul({},
                this.renderLink("Web Shell", instance.get('shell_url')),
                this.renderLink("Remote Desktop", instance.get('vnc_url')));
        }
    });

    var InstancePage = React.createClass({
        render: function() {
            var instance = this.props.instance;
            return React.DOM.div({},
                PageHeader({title: "Instance: " + instance.get('name_or_id')}),
                InstanceAttributes({instance: instance,
                    providers: this.props.providers}),
                InstanceLinks({instance: instance}));
        }
    });

    var InstanceDetail = React.createClass({
        mixins: [LoadingMixin],
        model: function() {
            var coll = new Instances([], {
                provider_id: this.props.providerId,
                identity_id: this.props.identityId
            });
            var instanceId = this.props.instanceId;
            return new RSVP.Promise(function(resolve, reject) {
                coll.fetch({success: function() {
                    var instance = coll.get(instanceId);
                    if (instance === undefined)
                        reject("Unknown instance " + instanceId);
                    resolve(instance);
                }});
            });
        },
        renderContent: function() {
            console.log(this.state.model);
            return InstancePage({instance: this.state.model, providers: this.props.providers});
        }
    });

    return InstanceDetail;
});
<|endoftext|>


<commit_before>define(["dojo/_base/kernel","dojo/_base/lang","./_base", "dojo/_base/html","dojo/_base/array", "dojo/_base/window", "dojo/_base/json",
	"dojo/_base/Deferred", "dojo/_base/sniff", "require","dojo/_base/config"],
  function(kernel, lang, g, html, arr, win, jsonLib, Deferred, has, require, config){
	var gu = g.utils = {};

	lang.mixin(gu, {
		forEach: function(
			/*dojox/gfx/shape.Surface|dojox/gfx/shape.Shape*/ object,
			/*Function|String|Array*/ f, /*Object?*/ o
		){
			// summary:
			//		Takes a shape or a surface and applies a function "f" to in the context of "o"
			//		(or global, if missing). If "shape" was a surface or a group, it applies the same
			//		function to all children recursively effectively visiting all shapes of the underlying scene graph.
			// object:
			//		The gfx container to iterate.
			// f:
			//		The function to apply.
			// o:
			//		The scope.
			o = o || kernel.global;
			f.call(o, object);
			if(object instanceof g.Surface || object instanceof g.Group){
				arr.forEach(object.children, function(shape){
					gu.forEach(shape, f, o);
				});
			}
		},

		serialize: function(object){
			// summary:
			//		Takes a shape or a surface and returns a JSON-like object, which describes underlying shapes.
			// object: dojox/gfx/shape.Surface|dojox/gfx/shape.Shape
			//		The container to serialize.

			var t = {}, v, isSurface = object instanceof g.Surface;
			if(isSurface || object instanceof g.Group){
				t.children = arr.map(object.children, gu.serialize);
				if(isSurface){
					return t.children;	// Array
				}
			}else{
				t.shape = object.getShape();
			}
			if(object.getTransform){
				v = object.getTransform();
				if(v){ t.transform = v; }
			}
			if(object.getStroke){
				v = object.getStroke();
				if(v){ t.stroke = v; }
			}
			if(object.getFill){
				v = object.getFill();
				if(v){ t.fill = v; }
			}
			if(object.getFont){
				v = object.getFont();
				if(v){ t.font = v; }
			}
			return t;	// Object
		},

		toJson: function(object, prettyPrint){
			// summary:
			//		Works just like serialize() but returns a JSON string. If prettyPrint is true, the string is pretty-printed to make it more human-readable.
			// object: dojox/gfx/shape.Surface|dojox/gfx/shape.Shape
			//		The container to serialize.
			// prettyPrint: Boolean?
			//		Indicates whether the output string should be formatted.
			// returns: String

			return jsonLib.toJson(gu.serialize(object), prettyPrint);	// String
		},

		deserialize: function(parent, object){
			// summary:
			//		Takes a surface or a shape and populates it with an object produced by serialize().
			// parent: dojox/gfx/shape.Surface|dojox/gfx/shape.Shape
			//		The destination container for the deserialized shapes.
			// object: dojox/gfx/shape.Shape|Array
			//		The shapes to deserialize.

			if(object instanceof Array){
				return arr.map(object, lang.hitch(null, gu.deserialize, parent));	// Array
			}
			var shape = ("shape" in object) ? parent.createShape(object.shape) : parent.createGroup();
			if("transform" in object){
				shape.setTransform(object.transform);
			}
			if("stroke" in object){
				shape.setStroke(object.stroke);
			}
			if("fill" in object){
				shape.setFill(object.fill);
			}
			if("font" in object){
				shape.setFont(object.font);
			}
			if("children" in object){
				arr.forEach(object.children, lang.hitch(null, gu.deserialize, shape));
			}
			return shape;	// dojox/gfx/shape.Shape
		},

		fromJson: function(parent, json){
			// summary:
			//		Works just like deserialize() but takes a JSON representation of the object.
			// parent: dojox/gfx/shape.Surface|dojox/gfx/shape.Shape
			//		The destination container for the deserialized shapes.
			// json: String
			//		The shapes to deserialize.

			return gu.deserialize(parent, jsonLib.fromJson(json));	// Array|dojox/gfx/shape.Shape
		},

		toSvg: function(/*dojox/gfx/shape.Surface*/surface){
			// summary:
			//		Function to serialize a GFX surface to SVG text.
			// description:
			//		Function to serialize a GFX surface to SVG text.  The value of this output
			//		is that there are numerous serverside parser libraries that can render
			//		SVG into images in various formats.  This provides a way that GFX objects
			//		can be captured in a known format and sent serverside for serialization
			//		into an image.
			// surface:
			//		The GFX surface to serialize.
			// returns:
			//		Deferred object that will be called when SVG serialization is complete.

			//Since the init and even surface creation can be async, we need to
			//return a deferred that will be called when content has serialized.
			var deferred = new Deferred();

			if(g.renderer === "svg"){
				//If we're already in SVG mode, this is easy and quick.
				try{
					var svg = gu._cleanSvg(gu._innerXML(surface.rawNode));
					deferred.callback(svg);
				}catch(e){
					deferred.errback(e);
				}
			}else{
				//Okay, now we have to get creative with hidden iframes and the like to
				//serialize SVG.
				if (!gu._initSvgSerializerDeferred) {
					gu._initSvgSerializer();
				}
				var jsonForm = gu.toJson(surface);
				var serializer = function(){
					try{
						var sDim = surface.getDimensions();
						var width = sDim.width;
						var	height = sDim.height;

						//Create an attach point in the iframe for the contents.
						var node = gu._gfxSvgProxy.document.createElement("div");
						gu._gfxSvgProxy.document.body.appendChild(node);
						//Set the node scaling.
						win.withDoc(gu._gfxSvgProxy.document, function() {
							html.style(node, "width", width);
							html.style(node, "height", height);
						}, this);

						//Create temp surface to render object to and render.
						var ts = gu._gfxSvgProxy[dojox._scopeName].gfx.createSurface(node, width, height);

						//It's apparently possible that a suface creation is async, so we need to use
						//the whenLoaded function.  Probably not needed for SVG, but making it common
						var draw = function(surface) {
							try{
								gu._gfxSvgProxy[dojox._scopeName].gfx.utils.fromJson(surface, jsonForm);

								//Get contents and remove temp surface.
								var svg = gu._cleanSvg(node.innerHTML);
								surface.clear();
								surface.destroy();
								gu._gfxSvgProxy.document.body.removeChild(node);
								deferred.callback(svg);
							}catch(e){
								deferred.errback(e);
							}
						};
						ts.whenLoaded(null,draw);
					 }catch (ex) {
						deferred.errback(ex);
					}
				};
				//See if we can call it directly or pass it to the deferred to be
				//called on initialization.
				if(gu._initSvgSerializerDeferred.fired > 0){
					serializer();
				}else{
					gu._initSvgSerializerDeferred.addCallback(serializer);
				}
			}
			return deferred; //dojo.Deferred that will be called when serialization finishes.
		},

		//iFrame document used for handling SVG serialization.
		_gfxSvgProxy: null,

		//Serializer loaded.
		_initSvgSerializerDeferred: null,

		_svgSerializerInitialized: function() {
			// summary:
			//		Internal function to call when the serializer init completed.
			// tags:
			//		private
			gu._initSvgSerializerDeferred.callback(true);
		},

		_initSvgSerializer: function(){
			// summary:
			//		Internal function to initialize the hidden iframe where SVG rendering
			//		will occur.
			// tags:
			//		private
			if(!gu._initSvgSerializerDeferred){
				gu._initSvgSerializerDeferred = new Deferred();
				var f = win.doc.createElement("iframe");
				html.style(f, {
					display: "none",
					position: "absolute",
					width: "1em",
					height: "1em",
					top: "-10000px"
				});
				var intv;
				if(has("ie")){
					f.onreadystatechange = function(){
						if(f.contentWindow.document.readyState == "complete"){
							f.onreadystatechange = function() {};
							intv = setInterval(function() {
								if(f.contentWindow[kernel.scopeMap["dojo"][1]._scopeName] &&
								   f.contentWindow[kernel.scopeMap["dojox"][1]._scopeName].gfx &&
								   f.contentWindow[kernel.scopeMap["dojox"][1]._scopeName].gfx.utils){
									clearInterval(intv);
									f.contentWindow.parent[kernel.scopeMap["dojox"][1]._scopeName].gfx.utils._gfxSvgProxy = f.contentWindow;
									f.contentWindow.parent[kernel.scopeMap["dojox"][1]._scopeName].gfx.utils._svgSerializerInitialized();
								}
							}, 50);
						}
					};
				}else{
					f.onload = function(){
						f.onload = function() {};
						intv = setInterval(function() {
							if(f.contentWindow[kernel.scopeMap["dojo"][1]._scopeName] &&
							   f.contentWindow[kernel.scopeMap["dojox"][1]._scopeName].gfx &&
							   f.contentWindow[kernel.scopeMap["dojox"][1]._scopeName].gfx.utils){
								clearInterval(intv);
								f.contentWindow.parent[kernel.scopeMap["dojox"][1]._scopeName].gfx.utils._gfxSvgProxy = f.contentWindow;
								f.contentWindow.parent[kernel.scopeMap["dojox"][1]._scopeName].gfx.utils._svgSerializerInitialized();
							}
						}, 50);
					};
				}
				//We have to load the GFX SVG proxy frame.  Default is to use the one packaged in dojox.
				var uri = (config["dojoxGfxSvgProxyFrameUrl"]||require.toUrl("dojox/gfx/resources/gfxSvgProxyFrame.html"));
				f.setAttribute("src", uri.toString());
				win.body().appendChild(f);
			}
		},

		_innerXML: function(/*Node*/node){
			// summary:
			//		Implementation of MS's innerXML function, borrowed from dojox.xml.parser.
			// node:
			//		The node from which to generate the XML text representation.
			// tags:
			//		private
			if(node.innerXML){
				return node.innerXML;	//String
			}else if(node.xml){
				return node.xml;		//String
			}else if(typeof XMLSerializer != "undefined"){
				return (new XMLSerializer()).serializeToString(node);	//String
			}
			return null;
		},

		_cleanSvg: function(svg) {
			// summary:
			//		Internal function that cleans up artifacts in extracted SVG content.
			// tags:
			//		private
			if(svg){
				//Make sure the namespace is set.
				if(svg.indexOf("xmlns=\"http://www.w3.org/2000/svg\"") == -1){
					svg = svg.substring(4, svg.length);
					svg = "<svg xmlns=\"http://www.w3.org/2000/svg\"" + svg;
				}
				//Same for xmlns:xlink (missing in Chrome and Safari)
				if(svg.indexOf("xmlns:xlink=\"http://www.w3.org/1999/xlink\"") == -1){
					svg = svg.substring(4, svg.length);
					svg = "<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\"" + svg;
				}
				//and add namespace to href attribute if not done yet
				//(FF 5+ adds xlink:href but not the xmlns def)
				if(svg.indexOf("xlink:href") === -1){
					svg = svg.replace(/href\s*=/g, "xlink:href=");
				}
				// in IE, <image are serialized as <img>
				svg = svg.replace(/<img\b([^>]*)>/gi,"<image $1 />");
				//Do some other cleanup, like stripping out the
				//dojoGfx attributes and quoting ids.
				svg = svg.replace(/\bdojoGfx\w*\s*=\s*(['"])\w*\1/g, "");
				svg = svg.replace(/\b__gfxObject__\s*=\s*(['"])\w*\1/g, "");
				svg = svg.replace(/[=]([^"']+?)(\s|>)/g,'="$1"$2');
			}
			return svg;  //Cleaned SVG text.
		}
	});

	return gu;
});
<commit_msg>fix doc<commit_after>define(["dojo/_base/kernel","dojo/_base/lang","./_base", "dojo/_base/html","dojo/_base/array", "dojo/_base/window", "dojo/_base/json",
	"dojo/_base/Deferred", "dojo/_base/sniff", "require","dojo/_base/config"],
  function(kernel, lang, g, html, arr, win, jsonLib, Deferred, has, require, config){
	var gu = g.utils = {};

	lang.mixin(gu, {
		forEach: function(
			/*dojox/gfx/shape.Surface|dojox/gfx/shape.Shape*/ object,
			/*Function|String|Array*/ f, /*Object?*/ o
		){
			// summary:
			//		Takes a shape or a surface and applies a function "f" to in the context of "o"
			//		(or global, if missing). If "shape" was a surface or a group, it applies the same
			//		function to all children recursively effectively visiting all shapes of the underlying scene graph.
			// object:
			//		The gfx container to iterate.
			// f:
			//		The function to apply.
			// o:
			//		The scope.
			o = o || kernel.global;
			f.call(o, object);
			if(object instanceof g.Surface || object instanceof g.Group){
				arr.forEach(object.children, function(shape){
					gu.forEach(shape, f, o);
				});
			}
		},

		serialize: function(object){
			// summary:
			//		Takes a shape or a surface and returns an object, which describes underlying shapes.
			// object: dojox/gfx/shape.Surface|dojox/gfx/shape.Shape
			//		The container to serialize.

			var t = {}, v, isSurface = object instanceof g.Surface;
			if(isSurface || object instanceof g.Group){
				t.children = arr.map(object.children, gu.serialize);
				if(isSurface){
					return t.children;	// Array
				}
			}else{
				t.shape = object.getShape();
			}
			if(object.getTransform){
				v = object.getTransform();
				if(v){ t.transform = v; }
			}
			if(object.getStroke){
				v = object.getStroke();
				if(v){ t.stroke = v; }
			}
			if(object.getFill){
				v = object.getFill();
				if(v){ t.fill = v; }
			}
			if(object.getFont){
				v = object.getFont();
				if(v){ t.font = v; }
			}
			return t;	// Object
		},

		toJson: function(object, prettyPrint){
			// summary:
			//		Works just like serialize() but returns a JSON string. If prettyPrint is true, the string is pretty-printed to make it more human-readable.
			// object: dojox/gfx/shape.Surface|dojox/gfx/shape.Shape
			//		The container to serialize.
			// prettyPrint: Boolean?
			//		Indicates whether the output string should be formatted.
			// returns: String

			return jsonLib.toJson(gu.serialize(object), prettyPrint);	// String
		},

		deserialize: function(parent, object){
			// summary:
			//		Takes a surface or a shape and populates it with an object produced by serialize().
			// parent: dojox/gfx/shape.Surface|dojox/gfx/shape.Shape
			//		The destination container for the deserialized shapes.
			// object: dojox/gfx/shape.Shape|Array
			//		The shapes to deserialize.

			if(object instanceof Array){
				return arr.map(object, lang.hitch(null, gu.deserialize, parent));	// Array
			}
			var shape = ("shape" in object) ? parent.createShape(object.shape) : parent.createGroup();
			if("transform" in object){
				shape.setTransform(object.transform);
			}
			if("stroke" in object){
				shape.setStroke(object.stroke);
			}
			if("fill" in object){
				shape.setFill(object.fill);
			}
			if("font" in object){
				shape.setFont(object.font);
			}
			if("children" in object){
				arr.forEach(object.children, lang.hitch(null, gu.deserialize, shape));
			}
			return shape;	// dojox/gfx/shape.Shape
		},

		fromJson: function(parent, json){
			// summary:
			//		Works just like deserialize() but takes a JSON representation of the object.
			// parent: dojox/gfx/shape.Surface|dojox/gfx/shape.Shape
			//		The destination container for the deserialized shapes.
			// json: String
			//		The shapes to deserialize.

			return gu.deserialize(parent, jsonLib.fromJson(json));	// Array|dojox/gfx/shape.Shape
		},

		toSvg: function(/*dojox/gfx/shape.Surface*/surface){
			// summary:
			//		Function to serialize a GFX surface to SVG text.
			// description:
			//		Function to serialize a GFX surface to SVG text.  The value of this output
			//		is that there are numerous serverside parser libraries that can render
			//		SVG into images in various formats.  This provides a way that GFX objects
			//		can be captured in a known format and sent serverside for serialization
			//		into an image.
			// surface:
			//		The GFX surface to serialize.
			// returns:
			//		Deferred object that will be called when SVG serialization is complete.

			//Since the init and even surface creation can be async, we need to
			//return a deferred that will be called when content has serialized.
			var deferred = new Deferred();

			if(g.renderer === "svg"){
				//If we're already in SVG mode, this is easy and quick.
				try{
					var svg = gu._cleanSvg(gu._innerXML(surface.rawNode));
					deferred.callback(svg);
				}catch(e){
					deferred.errback(e);
				}
			}else{
				//Okay, now we have to get creative with hidden iframes and the like to
				//serialize SVG.
				if (!gu._initSvgSerializerDeferred) {
					gu._initSvgSerializer();
				}
				var jsonForm = gu.toJson(surface);
				var serializer = function(){
					try{
						var sDim = surface.getDimensions();
						var width = sDim.width;
						var	height = sDim.height;

						//Create an attach point in the iframe for the contents.
						var node = gu._gfxSvgProxy.document.createElement("div");
						gu._gfxSvgProxy.document.body.appendChild(node);
						//Set the node scaling.
						win.withDoc(gu._gfxSvgProxy.document, function() {
							html.style(node, "width", width);
							html.style(node, "height", height);
						}, this);

						//Create temp surface to render object to and render.
						var ts = gu._gfxSvgProxy[dojox._scopeName].gfx.createSurface(node, width, height);

						//It's apparently possible that a suface creation is async, so we need to use
						//the whenLoaded function.  Probably not needed for SVG, but making it common
						var draw = function(surface) {
							try{
								gu._gfxSvgProxy[dojox._scopeName].gfx.utils.fromJson(surface, jsonForm);

								//Get contents and remove temp surface.
								var svg = gu._cleanSvg(node.innerHTML);
								surface.clear();
								surface.destroy();
								gu._gfxSvgProxy.document.body.removeChild(node);
								deferred.callback(svg);
							}catch(e){
								deferred.errback(e);
							}
						};
						ts.whenLoaded(null,draw);
					 }catch (ex) {
						deferred.errback(ex);
					}
				};
				//See if we can call it directly or pass it to the deferred to be
				//called on initialization.
				if(gu._initSvgSerializerDeferred.fired > 0){
					serializer();
				}else{
					gu._initSvgSerializerDeferred.addCallback(serializer);
				}
			}
			return deferred; //dojo.Deferred that will be called when serialization finishes.
		},

		//iFrame document used for handling SVG serialization.
		_gfxSvgProxy: null,

		//Serializer loaded.
		_initSvgSerializerDeferred: null,

		_svgSerializerInitialized: function() {
			// summary:
			//		Internal function to call when the serializer init completed.
			// tags:
			//		private
			gu._initSvgSerializerDeferred.callback(true);
		},

		_initSvgSerializer: function(){
			// summary:
			//		Internal function to initialize the hidden iframe where SVG rendering
			//		will occur.
			// tags:
			//		private
			if(!gu._initSvgSerializerDeferred){
				gu._initSvgSerializerDeferred = new Deferred();
				var f = win.doc.createElement("iframe");
				html.style(f, {
					display: "none",
					position: "absolute",
					width: "1em",
					height: "1em",
					top: "-10000px"
				});
				var intv;
				if(has("ie")){
					f.onreadystatechange = function(){
						if(f.contentWindow.document.readyState == "complete"){
							f.onreadystatechange = function() {};
							intv = setInterval(function() {
								if(f.contentWindow[kernel.scopeMap["dojo"][1]._scopeName] &&
								   f.contentWindow[kernel.scopeMap["dojox"][1]._scopeName].gfx &&
								   f.contentWindow[kernel.scopeMap["dojox"][1]._scopeName].gfx.utils){
									clearInterval(intv);
									f.contentWindow.parent[kernel.scopeMap["dojox"][1]._scopeName].gfx.utils._gfxSvgProxy = f.contentWindow;
									f.contentWindow.parent[kernel.scopeMap["dojox"][1]._scopeName].gfx.utils._svgSerializerInitialized();
								}
							}, 50);
						}
					};
				}else{
					f.onload = function(){
						f.onload = function() {};
						intv = setInterval(function() {
							if(f.contentWindow[kernel.scopeMap["dojo"][1]._scopeName] &&
							   f.contentWindow[kernel.scopeMap["dojox"][1]._scopeName].gfx &&
							   f.contentWindow[kernel.scopeMap["dojox"][1]._scopeName].gfx.utils){
								clearInterval(intv);
								f.contentWindow.parent[kernel.scopeMap["dojox"][1]._scopeName].gfx.utils._gfxSvgProxy = f.contentWindow;
								f.contentWindow.parent[kernel.scopeMap["dojox"][1]._scopeName].gfx.utils._svgSerializerInitialized();
							}
						}, 50);
					};
				}
				//We have to load the GFX SVG proxy frame.  Default is to use the one packaged in dojox.
				var uri = (config["dojoxGfxSvgProxyFrameUrl"]||require.toUrl("dojox/gfx/resources/gfxSvgProxyFrame.html"));
				f.setAttribute("src", uri.toString());
				win.body().appendChild(f);
			}
		},

		_innerXML: function(/*Node*/node){
			// summary:
			//		Implementation of MS's innerXML function, borrowed from dojox.xml.parser.
			// node:
			//		The node from which to generate the XML text representation.
			// tags:
			//		private
			if(node.innerXML){
				return node.innerXML;	//String
			}else if(node.xml){
				return node.xml;		//String
			}else if(typeof XMLSerializer != "undefined"){
				return (new XMLSerializer()).serializeToString(node);	//String
			}
			return null;
		},

		_cleanSvg: function(svg) {
			// summary:
			//		Internal function that cleans up artifacts in extracted SVG content.
			// tags:
			//		private
			if(svg){
				//Make sure the namespace is set.
				if(svg.indexOf("xmlns=\"http://www.w3.org/2000/svg\"") == -1){
					svg = svg.substring(4, svg.length);
					svg = "<svg xmlns=\"http://www.w3.org/2000/svg\"" + svg;
				}
				//Same for xmlns:xlink (missing in Chrome and Safari)
				if(svg.indexOf("xmlns:xlink=\"http://www.w3.org/1999/xlink\"") == -1){
					svg = svg.substring(4, svg.length);
					svg = "<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\"" + svg;
				}
				//and add namespace to href attribute if not done yet
				//(FF 5+ adds xlink:href but not the xmlns def)
				if(svg.indexOf("xlink:href") === -1){
					svg = svg.replace(/href\s*=/g, "xlink:href=");
				}
				// in IE, <image are serialized as <img>
				svg = svg.replace(/<img\b([^>]*)>/gi,"<image $1 />");
				//Do some other cleanup, like stripping out the
				//dojoGfx attributes and quoting ids.
				svg = svg.replace(/\bdojoGfx\w*\s*=\s*(['"])\w*\1/g, "");
				svg = svg.replace(/\b__gfxObject__\s*=\s*(['"])\w*\1/g, "");
				svg = svg.replace(/[=]([^"']+?)(\s|>)/g,'="$1"$2');
			}
			return svg;  //Cleaned SVG text.
		}
	});

	return gu;
});
<|endoftext|>


<commit_before>module.exports = function(grunt)
{
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        ts: {
            typedoc: {
                tsconfig: { passThrough: true }
            },
            typescript: {
                options: {
                    sourceMap: false,
                    declaration: true
                },
                src: [
                    'typescript/src/compiler/core.ts',
                    'typescript/src/compiler/sys.ts',
                    'typescript/src/compiler/types.ts',
                    'typescript/src/compiler/scanner.ts',
                    'typescript/src/compiler/parser.ts',
                    'typescript/src/compiler/utilities.ts',
                    'typescript/src/compiler/binder.ts',
                    'typescript/src/compiler/checker.ts',
                    'typescript/src/compiler/declarationEmitter.ts',
                    'typescript/src/compiler/emitter.ts',
                    'typescript/src/compiler/program.ts',
                    'typescript/src/compiler/commandLineParser.ts',
                    'typescript/src/compiler/diagnosticInformationMap.generated.ts'
                ],
                out: 'src/typings/typescript/typescript.js'
            }
        },
        'string-replace': {
            version: {
                files: {
                    'lib/application.js': ['lib/application.js']
                },
                options: {
                    replacements: [{
                        pattern: /{{ VERSION }}/g,
                        replacement: '<%= pkg.version %>'
                    }]
                }
            },
            typescript: {
                files: {
                    'src/typings/typescript/typescript.d.ts': ['src/typings/typescript/typescript.d.ts']
                },
                options: {
                    replacements: [{
                        pattern: /\}[\s\n\r]*declare namespace ts \{/g,
                        replacement: ''
                    }, {
                        pattern: /declare namespace ts/g,
                        replacement: 'declare module "typescript"'
                    }]
                }
            }
        },
        clean: {
            specsBefore: ['test/renderer/specs'],
            specsAfter: ['test/renderer/specs/assets']
        },
        watch: {
            source: {
                files: ['src/**/*.ts'],
                tasks: ['ts:typedoc', 'string-replace:version']
            }
        },
        mocha_istanbul: {
            coverage: {
                src: 'test',
                options: {
                    mask: '*.js',
                    timeout: 4000
                }
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-string-replace');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-ts');
    grunt.loadNpmTasks('grunt-mocha-istanbul');

    grunt.registerTask('default', ['ts:typedoc', 'string-replace:version']);
    grunt.registerTask('build_and_test', ['default', 'specs', 'mocha_istanbul:coverage']);
    grunt.registerTask('specs', ['clean:specsBefore', 'build-specs', 'clean:specsAfter']);

    grunt.registerTask('build-specs', function() {
        var FS = require('fs-extra');
        var Path = require('path');
        var TypeDoc = require('./');

        var base = Path.join(__dirname, 'test', 'converter');
        var app = new TypeDoc.Application({
            mode:   'Modules',
            target: 'ES5',
            module: 'CommonJS',
            experimentalDecorators: true,
            jsx: 'react'
        });

        FS.readdirSync(Path.join(base)).forEach(function(directory) {
            console.log(directory);

            var path = Path.join(base, directory);
            if (!FS.lstatSync(path).isDirectory()) return;
            TypeDoc.resetReflectionID();

            var src = app.expandInputFiles([path]);
            var out = Path.join(base, directory, 'specs.json');
            var result = app.convert(src);
            var data = JSON.stringify(result.toObject(), null, '  ');
            data = data.split(TypeDoc.normalizePath(base)).join('%BASE%');
            FS.writeFileSync(out, data);
        });

        var src = Path.join(__dirname, 'examples', 'basic', 'src');
        var out = Path.join(__dirname, 'test', 'renderer', 'specs');

        FS.removeSync(out);
        app.generateDocs(app.expandInputFiles([src]), out);

        function getFileIndex(base, dir, results) {
            results = results || [];
            dir = dir || '';
            var files = FS.readdirSync(Path.join(base, dir));
            files.forEach(function(file) {
                file = Path.join(dir, file);
                if (FS.statSync(Path.join(base, file)).isDirectory()) {
                    getFileIndex(base, file, results);
                } else {
                    results.push(file);
                }
            });

            return results.sort();
        }

        FS.removeSync(Path.join(out, 'assets'));
        var gitHubRegExp = /https:\/\/github.com\/[A-Za-z0-9\-]+\/typedoc\/blob\/[^\/]*\/examples/g;
        getFileIndex(out).forEach(function (file) {
            file = Path.join(out, file);
            FS.writeFileSync(file, FS.readFileSync(file, {encoding:'utf-8'}).replace(gitHubRegExp, 'https://github.com/sebastian-lenz/typedoc/blob/master/examples'));
        });
    });
};
<commit_msg>fix(grunt): replace correctly the version string (#427)<commit_after>module.exports = function(grunt)
{
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        ts: {
            typedoc: {
                tsconfig: { passThrough: true }
            },
            typescript: {
                options: {
                    sourceMap: false,
                    declaration: true
                },
                src: [
                    'typescript/src/compiler/core.ts',
                    'typescript/src/compiler/sys.ts',
                    'typescript/src/compiler/types.ts',
                    'typescript/src/compiler/scanner.ts',
                    'typescript/src/compiler/parser.ts',
                    'typescript/src/compiler/utilities.ts',
                    'typescript/src/compiler/binder.ts',
                    'typescript/src/compiler/checker.ts',
                    'typescript/src/compiler/declarationEmitter.ts',
                    'typescript/src/compiler/emitter.ts',
                    'typescript/src/compiler/program.ts',
                    'typescript/src/compiler/commandLineParser.ts',
                    'typescript/src/compiler/diagnosticInformationMap.generated.ts'
                ],
                out: 'src/typings/typescript/typescript.js'
            }
        },
        'string-replace': {
            version: {
                files: {
                    'dist/lib/application.js': ['dist/lib/application.js']
                },
                options: {
                    replacements: [{
                        pattern: /{{ VERSION }}/g,
                        replacement: '<%= pkg.version %>'
                    }]
                }
            },
            typescript: {
                files: {
                    'src/typings/typescript/typescript.d.ts': ['src/typings/typescript/typescript.d.ts']
                },
                options: {
                    replacements: [{
                        pattern: /\}[\s\n\r]*declare namespace ts \{/g,
                        replacement: ''
                    }, {
                        pattern: /declare namespace ts/g,
                        replacement: 'declare module "typescript"'
                    }]
                }
            }
        },
        clean: {
            specsBefore: ['test/renderer/specs'],
            specsAfter: ['test/renderer/specs/assets']
        },
        watch: {
            source: {
                files: ['src/**/*.ts'],
                tasks: ['ts:typedoc', 'string-replace:version']
            }
        },
        mocha_istanbul: {
            coverage: {
                src: 'test',
                options: {
                    mask: '*.js',
                    timeout: 4000
                }
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-string-replace');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-ts');
    grunt.loadNpmTasks('grunt-mocha-istanbul');

    grunt.registerTask('default', ['ts:typedoc', 'string-replace:version']);
    grunt.registerTask('build_and_test', ['default', 'specs', 'mocha_istanbul:coverage']);
    grunt.registerTask('specs', ['clean:specsBefore', 'build-specs', 'clean:specsAfter']);

    grunt.registerTask('build-specs', function() {
        var FS = require('fs-extra');
        var Path = require('path');
        var TypeDoc = require('./');

        var base = Path.join(__dirname, 'test', 'converter');
        var app = new TypeDoc.Application({
            mode:   'Modules',
            target: 'ES5',
            module: 'CommonJS',
            experimentalDecorators: true,
            jsx: 'react'
        });

        FS.readdirSync(Path.join(base)).forEach(function(directory) {
            console.log(directory);

            var path = Path.join(base, directory);
            if (!FS.lstatSync(path).isDirectory()) return;
            TypeDoc.resetReflectionID();

            var src = app.expandInputFiles([path]);
            var out = Path.join(base, directory, 'specs.json');
            var result = app.convert(src);
            var data = JSON.stringify(result.toObject(), null, '  ');
            data = data.split(TypeDoc.normalizePath(base)).join('%BASE%');
            FS.writeFileSync(out, data);
        });

        var src = Path.join(__dirname, 'examples', 'basic', 'src');
        var out = Path.join(__dirname, 'test', 'renderer', 'specs');

        FS.removeSync(out);
        app.generateDocs(app.expandInputFiles([src]), out);

        function getFileIndex(base, dir, results) {
            results = results || [];
            dir = dir || '';
            var files = FS.readdirSync(Path.join(base, dir));
            files.forEach(function(file) {
                file = Path.join(dir, file);
                if (FS.statSync(Path.join(base, file)).isDirectory()) {
                    getFileIndex(base, file, results);
                } else {
                    results.push(file);
                }
            });

            return results.sort();
        }

        FS.removeSync(Path.join(out, 'assets'));
        var gitHubRegExp = /https:\/\/github.com\/[A-Za-z0-9\-]+\/typedoc\/blob\/[^\/]*\/examples/g;
        getFileIndex(out).forEach(function (file) {
            file = Path.join(out, file);
            FS.writeFileSync(file, FS.readFileSync(file, {encoding:'utf-8'}).replace(gitHubRegExp, 'https://github.com/sebastian-lenz/typedoc/blob/master/examples'));
        });
    });
};
<|endoftext|>


<commit_before>// ==UserScript==
// @name         TruyenFull downloader
// @namespace    https://baivong.github.io/
// @description  Tải truyện từ truyenfull.vn định dạng txt hoặc html. Sau đó, bạn có thể dùng Mobipocket Creator để tạo ebook prc
// @version      2.0.0
// @icon         https://i.imgur.com/FQY8btq.png
// @author       Zzbaivong
// @license      MIT
// @include      http://truyenfull.vn/*
// @exclude      http://truyenfull.vn/
// @exclude      http://truyenfull.vn/*/chuong-*
// @exclude      http://truyenfull.vn/danh-sach/*
// @exclude      http://truyenfull.vn/the-loai/*
// @exclude      http://truyenfull.vn/tac-gia/*
// @exclude      http://truyenfull.vn/contact/
// @exclude      http://truyenfull.vn/tos/
// @exclude      http://truyenfull.vn/sitemap.xml
// @require      https://code.jquery.com/jquery-3.2.0.min.js
// @require      https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.2/handlebars.min.js
// @require      https://greasyfork.org/scripts/20307-jszip-v2/code/jszip-v2.js?version=196156
// @require      https://greasyfork.org/scripts/29904-jszip-utils/code/jszip-utils.js?version=196137
// @require      https://greasyfork.org/scripts/18532-filesaver/code/FileSaver.js?version=164030
// @require      https://greasyfork.org/scripts/29905-js-epub-maker/code/js-epub-maker.js?version=196139
// @noframes
// @connect      self
// @supportURL   https://github.com/baivong/Userscript/issues
// @run-at       document-idle
// @grant        GM_xmlhttpRequest
// ==/UserScript==

/* global EpubMaker */
(function ($, window, document) {
    'use strict';

    function cleanHtml(str) {
        str = str.replace(/&nbsp\;/gm, ' ');
        str = str.replace(/<(br|hr|img)([^>]+)?>/gm, '<$1$2 />');
        return '
' + str + '
';
    }

    function downloadError(err) {
        $downloadStatus('danger');
        titleError.push(chapTitle);
        console.log(err);
    }

    function saveEbook() {
        if (endDownload) return;
        endDownload = true;

        if (titleError.length) {
            titleError = '
Các chương lỗi: ' + titleError.join(', ') + '
';
        } else {
            titleError = '';
        }
        beginEnd = '
Nội dung từ ' + begin + ' đến ' + end + '
';

        epubMaker.withSection(new EpubMaker.Section('note', 'note', {
            content: beginEnd + titleError + '

' + credits,
            title: 'Ghi chú'
        }, false, true));

        epubMaker.downloadEpub(function (epubZipContent, filename) {
            document.title = '[⇓] ' + ebookTitle;
            $win.off('beforeunload');
            $download.attr({
                href: window.URL.createObjectURL(epubZipContent),
                download: filename
            }).text('Tải xong').off('click');
            $downloadStatus('success');
        });
    }

    function getContent() {
        if (endDownload) return;
        chapId = chapList[count];

        GM_xmlhttpRequest({
            method: 'GET',
            url: pathname + chapId + '/',
            onload: function (response) {
                var $data = $(response.responseText),
                    $chapter = $data.find('.chapter-c'),
                    $notContent = $chapter.find('script, style, a'),
                    $referrer = $chapter.find('[style]').filter(function () {
                        return (this.style.fontSize === '1px' || this.style.fontSize === '0px' || this.style.color === 'white');
                    });

                if (endDownload) return;

                chapTitle = $data.find('.chapter-title').text().trim();

                if (!$chapter.length) {
                    downloadError('Missing content.');
                } else {
                    $downloadStatus('warning');

                    var $img = $chapter.find('img');
                    if ($img.length) $img.replaceWith(function () {
                        return '
Click để xem ảnh
';
                    });

                    if ($notContent.length) $notContent.remove();
                    if ($referrer.length) $referrer.remove();

                    epubMaker.withSection(new EpubMaker.Section('chapter', chapId, {
                        content: cleanHtml($chapter.html()),
                        title: chapTitle
                    }, true, false));

                    if (count === 0) begin = chapTitle;
                    end = chapTitle;

                    $download.html('Đang tải: ' + Math.floor((count / chapListSize) * 100) + '%');

                    count++;
                    document.title = '[' + count + '] ' + pageName;
                    if (count >= chapListSize) {
                        saveEbook();
                    } else {
                        getContent();
                    }
                }
            },
            onerror: function (err) {
                downloadError(err);
                saveEbook();
            }
        });
    }

    function downloadEbook() {
        var $ebookType = $('.info a[itemprop="genre"]');

        ebookTitle = $('h1').text().trim();
        ebookAuthor = $('.info a[itemprop="author"]').text().trim();
        ebookCover = $('.books img').attr('src');

        if ($ebookType.length) {
            $ebookType.each(function () {
                ebookType.push($(this).text().trim());
            });
            ebookType = ebookType.join(', ');
            ebookType = '
Thể loại: ' + ebookType + '
';
        } else {
            ebookType = '';
        }

        epubMaker = new EpubMaker()
            .withUuid('github.com/baivong/Userscript::truyenfull::' + pathname.slice(1, -1))
            .withTemplate('idpf-wasteland')
            .withAuthor(ebookAuthor)
            .withLanguage('vi')
            .withModificationDate(new Date)
            .withCover(ebookCover)
            .withTitle(ebookTitle);

        epubMaker.withSection(new EpubMaker.Section('introduction', 'info', {
            content: '
' + ebookTitle + '

Tác giả: ' + ebookAuthor + '
' + ebookType,
            title: 'Giới thiệu'
        }, false, true));

        epubMaker.withSection(new EpubMaker.Section('preamble', 'content', {
            content: cleanHtml($('.desc-text').html()),
            title: 'Nội dung'
        }, false, true));

        $win.on('beforeunload', function () {
            return 'Truyện đang được tải xuống...';
        });

        $download.one('click', function (e) {
            e.preventDefault();
            saveEbook();
        });

        getContent();
    }

    var pageName = document.title,
        $win = $(window),

        $download = $('', {
            class: 'btn btn-primary btn-lg',
            href: '#download',
            text: 'Tải xuống'
        }),
        $downloadStatus = function (status) {
            $download.removeClass('btn-primary btn-success btn-info btn-warning btn-danger').addClass('btn-' + status);
        },

        $novelId = $('#truyen-id'),
        chapList = [],
        chapListSize = 0,
        chapId = '',
        chapTitle = '',
        pathname = location.pathname,
        count = 0,
        begin = '',
        end = '',
        endDownload = false,

        ebookTitle = '',
        ebookAuthor = '',
        ebookCover = '',
        ebookType = [],
        beginEnd = '',
        titleError = [],
        credits = '
Truyện được tải từ TruyenFull

Userscript được viết bởi: Zzbaivong
',

        epubMaker;

    if (!$novelId.length) return;

    $download.insertAfter('.info');
    $download.one('click contextmenu', function (e) {
        e.preventDefault();
        document.title = '[...] Vui lòng chờ trong giây lát';

        $.post('/ajax.php', 'type=chapter_option&data=' + $novelId.val()).done(function (data) {
            chapList = data.match(/chuong-[^"]+(?=")/gm);

            if (e.type === 'contextmenu') {
                var startFrom = prompt('Nhập ID chương truyện bắt đầu tải:', chapList[0]);
                startFrom = chapList.indexOf(startFrom);
                if (startFrom !== -1) chapList = chapList.slice(startFrom);
            }

            chapListSize = chapList.length;
            if (chapListSize > 0) downloadEbook();
        }).fail(function (jqXHR, textStatus) {
            downloadError(textStatus);
        });
    });

})(jQuery, window, document);
<commit_msg>Fix chapter list<commit_after>// ==UserScript==
// @name         TruyenFull downloader
// @namespace    https://baivong.github.io/
// @description  Tải truyện từ truyenfull.vn định dạng txt hoặc html. Sau đó, bạn có thể dùng Mobipocket Creator để tạo ebook prc
// @version      2.0.0
// @icon         https://i.imgur.com/FQY8btq.png
// @author       Zzbaivong
// @license      MIT
// @include      http://truyenfull.vn/*
// @exclude      http://truyenfull.vn/
// @exclude      http://truyenfull.vn/*/chuong-*
// @exclude      http://truyenfull.vn/danh-sach/*
// @exclude      http://truyenfull.vn/the-loai/*
// @exclude      http://truyenfull.vn/tac-gia/*
// @exclude      http://truyenfull.vn/contact/
// @exclude      http://truyenfull.vn/tos/
// @exclude      http://truyenfull.vn/sitemap.xml
// @require      https://code.jquery.com/jquery-3.2.0.min.js
// @require      https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.2/handlebars.min.js
// @require      https://greasyfork.org/scripts/20307-jszip-v2/code/jszip-v2.js?version=196156
// @require      https://greasyfork.org/scripts/29904-jszip-utils/code/jszip-utils.js?version=196137
// @require      https://greasyfork.org/scripts/18532-filesaver/code/FileSaver.js?version=164030
// @require      https://greasyfork.org/scripts/29905-js-epub-maker/code/js-epub-maker.js?version=196139
// @noframes
// @connect      self
// @supportURL   https://github.com/baivong/Userscript/issues
// @run-at       document-idle
// @grant        GM_xmlhttpRequest
// ==/UserScript==

/* global EpubMaker */
(function ($, window, document) {
    'use strict';

    function cleanHtml(str) {
        str = str.replace(/&nbsp\;/gm, ' ');
        str = str.replace(/<(br|hr|img)([^>]+)?>/gm, '<$1$2 />');
        return '
' + str + '
';
    }

    function downloadError(err) {
        $downloadStatus('danger');
        titleError.push(chapTitle);
        console.log(err);
    }

    function saveEbook() {
        if (endDownload) return;
        endDownload = true;

        if (titleError.length) {
            titleError = '
Các chương lỗi: ' + titleError.join(', ') + '
';
        } else {
            titleError = '';
        }
        beginEnd = '
Nội dung từ ' + begin + ' đến ' + end + '
';

        epubMaker.withSection(new EpubMaker.Section('note', 'note', {
            content: beginEnd + titleError + '

' + credits,
            title: 'Ghi chú'
        }, false, true));

        epubMaker.downloadEpub(function (epubZipContent, filename) {
            document.title = '[⇓] ' + ebookTitle;
            $win.off('beforeunload');
            $download.attr({
                href: window.URL.createObjectURL(epubZipContent),
                download: filename
            }).text('Tải xong').off('click');
            $downloadStatus('success');
        });
    }

    function getContent() {
        if (endDownload) return;
        chapId = chapList[count];

        GM_xmlhttpRequest({
            method: 'GET',
            url: pathname + chapId + '/',
            onload: function (response) {
                var $data = $(response.responseText),
                    $chapter = $data.find('.chapter-c'),
                    $notContent = $chapter.find('script, style, a'),
                    $referrer = $chapter.find('[style]').filter(function () {
                        return (this.style.fontSize === '1px' || this.style.fontSize === '0px' || this.style.color === 'white');
                    });

                if (endDownload) return;

                chapTitle = $data.find('.chapter-title').text().trim();

                if (!$chapter.length) {
                    downloadError('Missing content.');
                } else {
                    $downloadStatus('warning');

                    var $img = $chapter.find('img');
                    if ($img.length) $img.replaceWith(function () {
                        return '
Click để xem ảnh
';
                    });

                    if ($notContent.length) $notContent.remove();
                    if ($referrer.length) $referrer.remove();

                    epubMaker.withSection(new EpubMaker.Section('chapter', chapId, {
                        content: cleanHtml($chapter.html()),
                        title: chapTitle
                    }, true, false));

                    if (count === 0) begin = chapTitle;
                    end = chapTitle;

                    $download.html('Đang tải: ' + Math.floor((count / chapListSize) * 100) + '%');

                    count++;
                    document.title = '[' + count + '] ' + pageName;
                    if (count >= chapListSize) {
                        saveEbook();
                    } else {
                        getContent();
                    }
                }
            },
            onerror: function (err) {
                downloadError(err);
                saveEbook();
            }
        });
    }

    function downloadEbook() {
        var $ebookType = $('.info a[itemprop="genre"]');

        ebookTitle = $('h1').text().trim();
        ebookAuthor = $('.info a[itemprop="author"]').text().trim();
        ebookCover = $('.books img').attr('src');

        if ($ebookType.length) {
            $ebookType.each(function () {
                ebookType.push($(this).text().trim());
            });
            ebookType = ebookType.join(', ');
            ebookType = '
Thể loại: ' + ebookType + '
';
        } else {
            ebookType = '';
        }

        epubMaker = new EpubMaker()
            .withUuid('github.com/baivong/Userscript::truyenfull::' + pathname.slice(1, -1))
            .withTemplate('idpf-wasteland')
            .withAuthor(ebookAuthor)
            .withLanguage('vi')
            .withModificationDate(new Date)
            .withCover(ebookCover)
            .withTitle(ebookTitle);

        epubMaker.withSection(new EpubMaker.Section('introduction', 'info', {
            content: '
' + ebookTitle + '

Tác giả: ' + ebookAuthor + '
' + ebookType,
            title: 'Giới thiệu'
        }, false, true));

        epubMaker.withSection(new EpubMaker.Section('preamble', 'content', {
            content: cleanHtml($('.desc-text').html()),
            title: 'Nội dung'
        }, false, true));

        $win.on('beforeunload', function () {
            return 'Truyện đang được tải xuống...';
        });

        $download.one('click', function (e) {
            e.preventDefault();
            saveEbook();
        });

        getContent();
    }

    var pageName = document.title,
        $win = $(window),

        $download = $('', {
            class: 'btn btn-primary btn-lg',
            href: '#download',
            text: 'Tải xuống'
        }),
        $downloadStatus = function (status) {
            $download.removeClass('btn-primary btn-success btn-info btn-warning btn-danger').addClass('btn-' + status);
        },

        $novelId = $('#truyen-id'),
        chapList = [],
        chapListSize = 0,
        chapId = '',
        chapTitle = '',
        pathname = location.pathname,
        count = 0,
        begin = '',
        end = '',
        endDownload = false,

        ebookTitle = '',
        ebookAuthor = '',
        ebookCover = '',
        ebookType = [],
        beginEnd = '',
        titleError = [],
        credits = '
Truyện được tải từ TruyenFull

Userscript được viết bởi: Zzbaivong
',

        epubMaker;

    if (!$novelId.length) return;

    $download.insertAfter('.info');
    $download.one('click contextmenu', function (e) {
        e.preventDefault();
        document.title = '[...] Vui lòng chờ trong giây lát';

        $.post('/ajax.php', 'type=chapter_option&data=' + $novelId.val()).done(function (data) {
            chapList = data.match(/(?:value\=")[^"]+(?=")/g).map(function (val) {
                return val.slice(7);
            });

            if (e.type === 'contextmenu') {
                var startFrom = prompt('Nhập ID chương truyện bắt đầu tải:', chapList[0]);
                startFrom = chapList.indexOf(startFrom);
                if (startFrom !== -1) chapList = chapList.slice(startFrom);
            }

            chapListSize = chapList.length;
            if (chapListSize > 0) downloadEbook();
        }).fail(function (jqXHR, textStatus) {
            downloadError(textStatus);
        });
    });

})(jQuery, window, document);
<|endoftext|>